Skip to content

Commit 9cac300

Browse files
fix OOBE in SuccinctCountingBlockedBloom
1 parent 011e9f3 commit 9cac300

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fastfilter/src/main/java/org/fastfilter/bloom/count/SuccinctCountingBlockedBloom.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public long getBitCount() {
6161
this.seed = Hash.randomSeed();
6262
long bits = (long) entryCount * bitsPerKey;
6363
this.buckets = (int) bits / 64;
64-
int arrayLength = (int) (buckets + 16);
64+
int arrayLength = (buckets + 16);
6565
data = new long[arrayLength];
6666
counts = new long[arrayLength];
6767
overflow = new long[100 + arrayLength * 10 / 100];
@@ -87,7 +87,7 @@ public void add(long key) {
8787
if (a2 != a1) {
8888
increment(start, a2);
8989
}
90-
int second = start + 1 + (int) (hash >>> 60);
90+
int second = start + (int) (hash >>> 60);
9191
int a3 = (int) ((hash >> 12) & 63);
9292
int a4 = (int) ((hash >> 18) & 63);
9393
increment(second, a3);
@@ -112,7 +112,7 @@ public void remove(long key) {
112112
if (a2 != a1) {
113113
decrement(start, a2);
114114
}
115-
int second = start + 1 + (int) (hash >>> 60);
115+
int second = start + (int) (hash >>> 60);
116116
int a3 = (int) ((hash >> 12) & 63);
117117
int a4 = (int) ((hash >> 18) & 63);
118118
decrement(second, a3);
@@ -142,7 +142,7 @@ public boolean mayContain(long key) {
142142
int start = Hash.reduce((int) hash, buckets);
143143
hash = hash ^ Long.rotateLeft(hash, 32);
144144
long a = data[start];
145-
long b = data[start + 1 + (int) (hash >>> 60)];
145+
long b = data[start + (int) (hash >>> 60)];
146146
long m1 = (1L << hash) | (1L << (hash >> 6));
147147
long m2 = (1L << (hash >> 12)) | (1L << (hash >> 18));
148148
return ((m1 & a) == m1) && ((m2 & b) == m2);

0 commit comments

Comments
 (0)