Skip to content

Commit bc4d79b

Browse files
authored
Merge pull request #50 from vprus/xor-binary-fuse-error-reporting
XorBinaryFuse: throw on failure
2 parents f786517 + 97f8749 commit bc4d79b

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ private void addAll(long[] keys) {
200200

201201
if (hashIndex > 100) {
202202
// if construction doesn't succeed eventually,
203-
// then there is likely a problem with the hash function
204-
// let us not crash the system:
205-
for(int i = 0; i < fingerprints.length; i++) {
206-
fingerprints[i] = (short)0xFFFF;
207-
}
208-
return;
203+
// then there is likely a problem with the hash function.
204+
// It's better fail that either produce non-functional or incorrect filter.
205+
throw new IllegalArgumentException("could not construct filter");
209206
}
210207
// use a new random numbers
211208
seed = Hash.randomSeed();

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ private void addAll(long[] keys) {
200200

201201
if (hashIndex > 100) {
202202
// if construction doesn't succeed eventually,
203-
// then there is likely a problem with the hash function
204-
// let us not crash the system:
205-
for (int i = 0; i < fingerprints.length; i++) {
206-
fingerprints[i] = (int) 0xFFFFFFFF;
207-
}
208-
return;
203+
// then there is likely a problem with the hash function.
204+
// It's better fail that either produce non-functional or incorrect filter.
205+
throw new IllegalArgumentException("could not construct filter");
209206
}
210207
// use a new random numbers
211208
seed = Hash.randomSeed();

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ private void addAll(long[] keys) {
200200

201201
if (hashIndex > 100) {
202202
// if construction doesn't succeed eventually,
203-
// then there is likely a problem with the hash function
204-
// let us not crash the system:
205-
for(int i = 0; i < fingerprints.length; i++) {
206-
fingerprints[i] = (byte)0xFF;
207-
}
208-
return;
203+
// then there is likely a problem with the hash function.
204+
// It's better fail that either produce non-functional or incorrect filter.
205+
throw new IllegalArgumentException("could not construct filter");
209206
}
210207
// use a new random numbers
211208
seed = Hash.randomSeed();

0 commit comments

Comments
 (0)