mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
add BoomFilter to reduce the burden of database
This commit is contained in:
parent
19feadfd3d
commit
cecf9db7e1
@ -23,7 +23,8 @@ public class BoomFilter {
|
||||
}
|
||||
|
||||
public static void add(String value) {
|
||||
for (int i = 0; i < hashFuncs.size(); i++) {
|
||||
int len = hashFuncs.size();
|
||||
for (int i = 0; i <len ; i++) {
|
||||
BiFunction<String, Integer, Integer> hashFunc = hashFuncs.get(i);
|
||||
int hashSeed = hashSeeds[i];
|
||||
Integer bitHash = hashFunc.apply(value, hashSeed);
|
||||
@ -32,7 +33,8 @@ public class BoomFilter {
|
||||
}
|
||||
|
||||
public static boolean exists(String value) {
|
||||
for (int i = 0; i < hashFuncs.size(); i++) {
|
||||
int len = hashFuncs.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
BiFunction<String, Integer, Integer> hashFunc = hashFuncs.get(i);
|
||||
int hashSeed = hashSeeds[i];
|
||||
Integer bitHash = hashFunc.apply(value, hashSeed);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user