zoukankan      html  css  js  c++  java
  • Bloom Filter

    Bloom Filter是一种概率数据结构(probabilistic data structure),对外提供的是一个set的接口。参见http://en.wikipedia.org/wiki/Bloom_filter

    -----------------------------------------------------
    注:set、map这些,通常称作是抽象数据结构,也即它们只是规定了一组可能的操作作为其接口,而不限制内部的具体实现。set的接口通常包括:

    a) 元素与集合的运算,test for in or not in;

    b) 集合与集合的运算,intersection、union etc.

    而set的实现可能会是基于binary search tree、skip list、hash-table等等。
    ------------------------------------------------------------

    Bloom filter可以看作是一个多重映射的bitmap,一个元素通过数个hash function映射到多个位置。

    1.1, 元素插入的时候,元素对应的这些位置的bit被置位;

    1.2, 测试元素是不是在bloom filter中时,计算对应的位置,然后看这些位置是不是都已置位,如果有至少一个没有置位,则元素不在集合中;

    1.3, 经典的bloom filter不支持删除操作,不过有变种(counting bloom filter)可以支持。

    1.4, bloom filter所表示的集合之间的运算十分便捷(和bitmap一样),intersection是and操作,union是or操作。

    bloom filter的特性(缺陷)是存在false positive,即:如果bloom filter回答说某个元素不在集合中,那么它一定不在;如果bloom filter回答说某个元素在这个集合中,那么这个元素也有可能事实上不在这个集合中(代表这个元素的那些bit位可能被其他多个元素置位了)。

    典型应用: 

    2.1, Google的bigtable用bloom filter来过滤“确实不存在”的row和column;

    2.2, squid用来过滤“确实不存在”的cache。

    更多参见wiki页面的examples。

  • 相关阅读:
    vue中封装公共方法,全局使用
    element-ui table 最后一行合计,单元格合并
    vuex 进行封装
    vue生命周期
    (转)no terminal library found
    解压
    (转)bash: make: command not found
    (转)linux 批量删除文件命令
    python
    Session
  • 原文地址:https://www.cnblogs.com/qsort/p/2039223.html
Copyright © 2011-2022 走看看