Class AbstractFilter

java.lang.Object
org.aoju.bus.core.bloom.filter.AbstractFilter
All Implemented Interfaces:
Serializable, BloomFilter
Direct Known Subclasses:
DefaultFilter, ELFFilter, FNVFilter, HfFilter, HfIpFilter, JSFilter, PJWFilter, RSFilter, SDBMFilter, TianlFilter

public abstract class AbstractFilter extends Object implements BloomFilter
抽象Bloom过滤器
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    容量
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractFilter(long maxValue)
    构造32位
    AbstractFilter(long maxValue, int machineNum)
    构造
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(String text)
    在boolean的bitMap中增加一个字符串 如果存在就返回false如果不存在先增加这个字符串.再返回true
    boolean
     
    abstract long
    hash(String text)
    自定义Hash方法
    void
    init(long maxValue, int machineNum)
    初始化

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • size

      protected long size
      容量
  • Constructor Details

    • AbstractFilter

      public AbstractFilter(long maxValue, int machineNum)
      构造
      Parameters:
      maxValue - 最大值
      machineNum - 机器位数
    • AbstractFilter

      public AbstractFilter(long maxValue)
      构造32位
      Parameters:
      maxValue - 最大值
  • Method Details

    • init

      public void init(long maxValue, int machineNum)
      初始化
      Parameters:
      maxValue - 最大值
      machineNum - 机器位数
    • contains

      public boolean contains(String text)
      Specified by:
      contains in interface BloomFilter
      Parameters:
      text - 字符串
      Returns:
      判断一个字符串是否bitMap中存在
    • add

      public boolean add(String text)
      Description copied from interface: BloomFilter
      在boolean的bitMap中增加一个字符串 如果存在就返回false如果不存在先增加这个字符串.再返回true
      Specified by:
      add in interface BloomFilter
      Parameters:
      text - 字符串
      Returns:
      是否加入成功,如果存在就返回false如果不存在返回true
    • hash

      public abstract long hash(String text)
      自定义Hash方法
      Parameters:
      text - 字符串
      Returns:
      the long