|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.xiaoleilu.hutool.bloomFilter.BloomFilter2
public class BloomFilter2
BloomFilter实现方式2,此方式使用BitSet存储。
Hash算法的使用使用固定顺序,只需指定个数既可
| 构造方法摘要 | |
|---|---|
BloomFilter2(int c,
int n,
int k)
构造一个布隆过滤器,过滤器的容量为c * n 个bit. |
|
| 方法摘要 | |
|---|---|
boolean |
contains(String str)
判定是否包含指定字符串 |
static int[] |
createHashes(String str,
int hashNumber)
将字符串的字节表示进行多哈希编码. |
double |
getFalsePositiveProbability()
|
static int |
hash(String str,
int k)
计算Hash值 |
void |
init(String path,
String charset)
通过文件初始化过滤器. |
static void |
main(String[] args)
|
void |
put(String str)
将字符串加入到BloomFilter中 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public BloomFilter2(int c,
int n,
int k)
c - 当前过滤器预先开辟的最大包含记录,通常要比预计存入的记录多一倍.n - 当前过滤器预计所要包含的记录.k - 哈希函数的个数,等同每条记录要占用的bit数.| 方法详细信息 |
|---|
public void init(String path,
String charset)
throws IOException
path - 文件路径charset - 字符集
IOExceptionpublic void put(String str)
str - 字符串public boolean contains(String str)
str - 字符串
public double getFalsePositiveProbability()
public static int[] createHashes(String str,
int hashNumber)
str - 待添加进过滤器的字符串字节表示.hashNumber - 要经过的哈希个数.
public static int hash(String str,
int k)
str - 被计算Hash的字符串k - Hash算法序号
public static void main(String[] args)
throws Exception
Exception
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||