public boolean merge(String partial) { try { if (bloomFilter == null) { bloomFilter = BloomFactory.ReadBloomFromString(partial); ///LOG.info(" read bloom from partial " + BloomFactory.WriteBloomToString(bloomFilter)); return true; } else { ///LOG.info(" ORng with merged before " + BloomFactory.WriteBloomToString(bloomFilter) ); Filter other = BloomFactory.ReadBloomFromString(partial); ///LOG.info("ORng with merged other " + BloomFactory.WriteBloomToString(other) ); bloomFilter.or(other); ///LOG.info(" ORing with merged after " + BloomFactory.WriteBloomToString(bloomFilter) ); return true; } } catch (IOException e) { LOG.error(" Error while evaluating Bloom ", e); return false; } }
public String evaluate(String bloom1Str, String bloom2Str) throws IOException { Filter bloom1 = BloomFactory.GetBloomFilter(bloom1Str); Filter bloom2 = BloomFactory.GetBloomFilter(bloom2Str); bloom1.or(bloom2); return BloomFactory.WriteBloomToString(bloom1); } }
public boolean merge(@Nonnull Text partial) throws HiveException { final DynamicBloomFilter other; try { other = BloomFilterUtils.deserialize(partial, new DynamicBloomFilter()); } catch (IOException e) { throw new HiveException(e); } if (filter == null) { this.filter = other; } else { filter.or(other); } return true; }
@Nullable public Text evaluate(@Nullable Text bloom1Str, @Nullable Text bloom2Str) throws HiveException { if (bloom1Str == null || bloom2Str == null) { return null; } final Filter bloom1; final Filter bloom2; try { bloom1 = BloomFilterUtils.deserialize(bloom1Str, new DynamicBloomFilter()); bloom2 = BloomFilterUtils.deserialize(bloom2Str, new DynamicBloomFilter()); } catch (IOException e) { throw new HiveException(e); } bloom1.or(bloom2); try { return BloomFilterUtils.serialize(bloom1, new Text()); } catch (IOException e) { throw new HiveException(e); } }
@Override public void assertWhat(Filter filter, int numInsertions, int hashId, ImmutableSet<Integer> falsePositives) { Filter evenFilter = getSymmetricFilter(filter.getClass(), numInsertions, hashId); // add all even for (int i = 0; i < numInsertions; i += 2) { evenFilter.add(new Key(Integer.toString(i).getBytes())); } // add all odd for (int i = 1; i < numInsertions; i += 2) { filter.add(new Key(Integer.toString(i).getBytes())); } // union odd with even filter.or(evenFilter); // check on present all key for (int i = 0; i < numInsertions; i++) { Assert.assertTrue(" filter might contains " + i, filter.membershipTest(new Key(Integer.toString(i).getBytes()))); } } });
@Override public void assertWhat(Filter filter, int numInsertions, int hashId, ImmutableSet<Integer> falsePositives) { Filter evenFilter = getSymmetricFilter(filter.getClass(), numInsertions, hashId); // add all even for (int i = 0; i < numInsertions; i += 2) { evenFilter.add(new Key(Integer.toString(i).getBytes())); } // add all odd for (int i = 1; i < numInsertions; i += 2) { filter.add(new Key(Integer.toString(i).getBytes())); } // union odd with even filter.or(evenFilter); // check on present all key for (int i = 0; i < numInsertions; i++) { Assert.assertTrue(" filter might contains " + i, filter.membershipTest(new Key(Integer.toString(i).getBytes()))); } } });
filter.or(tfilter); } catch (IllegalArgumentException ex) {
filter.or(tfilter); } catch (IllegalArgumentException ex) {