Skip to content

Commit 11a4199

Browse files
committed
Round array length down to a multiple of 3
1 parent 435a4e3 commit 11a4199

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ public long getBitCount() {
6767
}
6868

6969
/**
70-
* Calculate the table (array) length. This is 1.23 times the size, plus an offset of 32 (see paper, Fig. 1)
70+
* Calculate the table (array) length. This is 1.23 times the size, plus an offset of 32 (see paper, Fig. 1).
71+
* We round down to a multiple of HASHES, as any excess entries couldn't be used.
7172
*
7273
* @param size the number of entries
7374
* @return the table length
7475
*/
7576
private static int getArrayLength(int size) {
76-
return (int) (OFFSET + (long) FACTOR_TIMES_100 * size / 100);
77+
int arrayLength = (int) (OFFSET + (long) FACTOR_TIMES_100 * size / 100);
78+
return arrayLength - (arrayLength % HASHES);
7779
}
7880

7981
public static XorPlus8 construct(long[] keys) {

0 commit comments

Comments
 (0)