public static final int computeBloomFilter(String s, int prefixLength) {
int cnt = Math.min(prefixLength, s.length());
if (cnt <= 0) return 0;
int filter = 0;
int bitpos = 0;
long hash = Fnv1Hash32.FNV_BASIS;
for(int i = 0; i < cnt; i++) {
char c = s.charAt(i);
hash ^= 0xFF & c;
hash *= Fnv1Hash32.FNV_PRIME;
hash &= Fnv1Hash32.BITS_MASK;
hash ^= 0xFF & (c >> 8);
hash *= Fnv1Hash32.FNV_PRIME;
hash &= Fnv1Hash32.BITS_MASK;
bitpos = (int)(hash % NUM_BITS);
if(bitpos < 0) bitpos += NUM_BITS;
filter |= 1 << bitpos;
}
return filter;
}
Why are you using the prefixLen? This goes against what I understood to be how we use the bloom filter after we match from the inverted index.