|
@@ -132,6 +132,34 @@ public class SetBackedScalingCuckooFilterTests extends AbstractWireSerializingTe
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public void testMergeBigSmall() {
|
|
|
+ int threshold = 1000;
|
|
|
+
|
|
|
+ // Setup the first filter
|
|
|
+ SetBackedScalingCuckooFilter filter = new SetBackedScalingCuckooFilter(threshold, Randomness.get(), 0.01);
|
|
|
+ int counter = 0;
|
|
|
+ Set<Long> values = new HashSet<>();
|
|
|
+ while (counter < threshold + 1) {
|
|
|
+ long value = randomLong();
|
|
|
+ filter.add(value);
|
|
|
+ boolean newValue = values.add(value);
|
|
|
+ if (newValue) {
|
|
|
+ counter += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SetBackedScalingCuckooFilter filter2 = new SetBackedScalingCuckooFilter(threshold, Randomness.get(), 0.01);
|
|
|
+ long value = randomLong();
|
|
|
+ while (filter.mightContain(value)) {
|
|
|
+ value = randomLong();
|
|
|
+ }
|
|
|
+
|
|
|
+ filter2.add(value);
|
|
|
+
|
|
|
+ filter.merge(filter2);
|
|
|
+ assertTrue(filter.mightContain(value));
|
|
|
+ }
|
|
|
+
|
|
|
public void testMergeSmall() {
|
|
|
int threshold = 1000;
|
|
|
|