From 6e2e14575a4b9c0fa1b957025683b160fcbe6fa3 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 23 Mar 2022 11:45:20 -0400 Subject: [PATCH 1/2] Minor fix. --- .../java/org/fastfilter/xor/XorBinaryFuse8.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java index c77c12a..6d3e97d 100644 --- a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java +++ b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java @@ -147,6 +147,18 @@ private void addAll(long[] keys) { // we have a possible counter overflow // this branch is never taken except if there is a problem in the hash code // in which case construction fails + hashIndex++; + Arrays.fill(t2count, (byte) 0); + Arrays.fill(t2hash, 0); + Arrays.fill(reverseOrder, 0); + + if (hashIndex > 100) { + // if construction doesn't succeed eventually, + // then there is likely a problem with the hash function + throw new IllegalArgumentException("Construction failed after " + hashIndex + " retries for size " + size); + } + // use a new random numbers + seed = Hash.randomSeed(); break; } @@ -199,11 +211,6 @@ private void addAll(long[] keys) { Arrays.fill(t2hash, 0); Arrays.fill(reverseOrder, 0); - // TODO - // if (hashIndex > 10) { - // System.out.println("WARNING: hashIndex " + hashIndex + "\n"); - // System.out.println(size + " keys; arrayLength " + arrayLength + " reverseOrderPos " + reverseOrderPos + " segmentLength " + segmentLength + " segmentCount " + segmentCount); - // } if (hashIndex > 100) { // if construction doesn't succeed eventually, // then there is likely a problem with the hash function From 8d6680465fac9bdedcd59cfaa5e394bcf916c0a6 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 23 Mar 2022 13:03:15 -0400 Subject: [PATCH 2/2] Switch to continue. --- fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java index 6d3e97d..8843d86 100644 --- a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java +++ b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java @@ -159,7 +159,7 @@ private void addAll(long[] keys) { } // use a new random numbers seed = Hash.randomSeed(); - break; + continue; } reverseOrderPos = 0;