diff --git a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java index c77c12a..8843d86 100644 --- a/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java +++ b/fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java @@ -147,7 +147,19 @@ 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 - break; + 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(); + continue; } reverseOrderPos = 0; @@ -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