public String evaluate(String bloom1Str, String bloom2Str) throws IOException { Filter bloom1 = BloomFactory.GetBloomFilter(bloom1Str); Filter bloom2 = BloomFactory.GetBloomFilter(bloom2Str); bloom1.and(bloom2); return BloomFactory.WriteBloomToString(bloom1); } }
@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.and(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) { int startIntersection = numInsertions - (numInsertions - 100); int endIntersection = numInsertions - 100; Filter partialFilter = getSymmetricFilter(filter.getClass(), numInsertions, hashId); for (int i = 0; i < numInsertions; i++) { String digit = Integer.toString(i); filter.add(new Key(digit.getBytes())); if (i >= startIntersection && i <= endIntersection) { partialFilter.add(new Key(digit.getBytes())); } } // do logic AND filter.and(partialFilter); for (int i = 0; i < numInsertions; i++) { if (i >= startIntersection && i <= endIntersection) { 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) { int startIntersection = numInsertions - (numInsertions - 100); int endIntersection = numInsertions - 100; Filter partialFilter = getSymmetricFilter(filter.getClass(), numInsertions, hashId); for (int i = 0; i < numInsertions; i++) { String digit = Integer.toString(i); filter.add(new Key(digit.getBytes())); if (i >= startIntersection && i <= endIntersection) { partialFilter.add(new Key(digit.getBytes())); } } // do logic AND filter.and(partialFilter); for (int i = 0; i < numInsertions; i++) { if (i >= startIntersection && i <= endIntersection) { Assert.assertTrue(" filter might contains " + i, filter.membershipTest(new Key(Integer.toString(i).getBytes()))); } } } }),
filter.and(tfilter); } catch (IllegalArgumentException ex) {
filter.and(tfilter); } catch (IllegalArgumentException ex) {