Skip to content

Commit 5dfd4c5

Browse files
committed
Fixes
1 parent ee55724 commit 5dfd4c5

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

fastfilter/src/main/java/org/fastfilter/xor/Xor16.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public Xor16(long[] keys) {
4444
byte[] reverseH = new byte[size];
4545
int reverseOrderPos;
4646
long seed;
47+
mainloop:
4748
do {
4849
seed = Hash.randomSeed();
4950
byte[] t2count = new byte[arrayLength];
@@ -54,11 +55,7 @@ public Xor16(long[] keys) {
5455
t2[h] ^= k;
5556
if (t2count[h] > 120) {
5657
// probably something wrong with the hash function
57-
// let us not crash the system:
58-
for(int i = 0; i < fingerprints.length; i++) {
59-
fingerprints[i] = (short)0xFFFF;
60-
}
61-
return;
58+
continue mainloop;
6259
}
6360
t2count[h]++;
6461
}

fastfilter/src/main/java/org/fastfilter/xor/Xor8.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public Xor8(long[] keys) {
4949
byte[] reverseH = new byte[size];
5050
int reverseOrderPos;
5151
long seed;
52+
mainloop:
5253
do {
5354
seed = Hash.randomSeed();
5455
byte[] t2count = new byte[m];
@@ -59,11 +60,7 @@ public Xor8(long[] keys) {
5960
t2[h] ^= k;
6061
if (t2count[h] > 120) {
6162
// probably something wrong with the hash function
62-
// let us not crash the system:
63-
for(int i = 0; i < fingerprints.length; i++) {
64-
fingerprints[i] = (byte)0xFF;
65-
}
66-
return;
63+
continue mainloop;
6764
}
6865
t2count[h]++;
6966
}

fastfilter/src/main/java/org/fastfilter/xor/XorBinaryFuse8.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ private void addAll(long[] keys) {
111111
blockBits++;
112112
}
113113
int block = 1 << blockBits;
114+
mainloop:
114115
while (true) {
115116
reverseOrder[size] = 1;
116117
int[] startPos = new int[block];
@@ -145,12 +146,7 @@ private void addAll(long[] keys) {
145146
startPos = null;
146147
if (countMask < 0) {
147148
// we have a possible counter overflow
148-
// this branch is never taken except if there is a problem in the hash code
149-
// in which case construction fails
150-
for(int i = 0; i < fingerprints.length; i++) {
151-
fingerprints[i] = (byte)0xFF;
152-
}
153-
return;
149+
continue mainloop;
154150
}
155151

156152
reverseOrderPos = 0;

fastfilter/src/main/java/org/fastfilter/xorplus/XorPlus8.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public XorPlus8(long[] keys) {
119119
// then we try again, with a new random seed.
120120
long seed = 0;
121121
int attempts = 0;
122+
mainloop:
122123
do {
123124
attempts++;
124125
if (attempts >= 100) {
@@ -145,9 +146,7 @@ public XorPlus8(long[] keys) {
145146
int h = getHash(k, seed, hi);
146147
t2[h] ^= k;
147148
if (t2count[h] > 120) {
148-
// probably something wrong with the hash function; or, the keys[] array contains many copies
149-
// of the same value
150-
throw new IllegalArgumentException("More than 120 keys hashed to the same location; indicates duplicate keys, or a bad hash function");
149+
continue mainloop;
151150
}
152151
t2count[h]++;
153152
}

0 commit comments

Comments
 (0)