Esempio n. 1
0
  public void testPutAllDifferentSizes() {
    BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
    BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 10);

    try {
      assertFalse(bf1.isCompatible(bf2));
      bf1.putAll(bf2);
      fail();
    } catch (IllegalArgumentException expected) {
    }

    try {
      assertFalse(bf2.isCompatible(bf1));
      bf2.putAll(bf1);
      fail();
    } catch (IllegalArgumentException expected) {
    }
  }
Esempio n. 2
0
 public void testPutAllWithSelf() {
   BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
   try {
     assertFalse(bf1.isCompatible(bf1));
     bf1.putAll(bf1);
     fail();
   } catch (IllegalArgumentException expected) {
   }
 }
 @Override
 public AccessTracker union(AccessTracker tracker) {
   if (filter == null) {
     throw new IllegalStateException(
         "Unable to union access tracker, because this tracker is not initialized.");
   }
   if (tracker instanceof BloomAccessTracker) {
     filter.putAll(((BloomAccessTracker) tracker).getFilter());
     return this;
   } else {
     throw new IllegalStateException(
         "Unable to union access tracker, because it's not of the right type (BloomAccessTracker)");
   }
 }
Esempio n. 4
0
  public void testPutAll() {
    int element1 = 1;
    int element2 = 2;

    BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 100);
    bf1.put(element1);
    assertTrue(bf1.mightContain(element1));
    assertFalse(bf1.mightContain(element2));

    BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 100);
    bf2.put(element2);
    assertFalse(bf2.mightContain(element1));
    assertTrue(bf2.mightContain(element2));

    assertTrue(bf1.isCompatible(bf2));
    bf1.putAll(bf2);
    assertTrue(bf1.mightContain(element1));
    assertTrue(bf1.mightContain(element2));
    assertFalse(bf2.mightContain(element1));
    assertTrue(bf2.mightContain(element2));
  }