zoukankan      html  css  js  c++  java
  • LevelDB Filters

    LevelDB Filters

      Because of the way leveldb data is organized on disk, a single Get() call may involve multiple reads from disk. The optional FilterPolicy mechanism can be used to reduce the number of disk reads substantially.

       leveldb::Options options;
       options.filter_policy = NewBloomFilterPolicy(10);
       leveldb::DB* db;
       leveldb::DB::Open(options, "/tmp/testdb", &db);
       ... use the database ...
       delete db;
       delete options.filter_policy;
    

      The preceding code associates a Bloom filter based filtering policy with the database. Bloom filter based filtering relies on keeping some number of bits of data in memory per key (in this case 10 bits per key since that is the argument we passed to NewBloomFilterPolicy). This filter will reduce the number of unnecessary disk reads needed for Get() calls by a factor of approximately a 100. Increasing the bits per key will lead to a larger reduction at the cost of more memory usage.

      We recommend that applications whose working set does not fit in memory and that do a lot of random reads set a filter policy.

  • 相关阅读:
    小注意1
    javascript求相对路径
    js网页返回顶部和楼层跳跃的实现原理
    函数传值的学习笔记
    每日一题——归并排序
    python文件处理
    Docker数据卷
    Docker镜像原理
    Docker可视化之Portainer
    Docker部署Nginx、Tomcat
  • 原文地址:https://www.cnblogs.com/tekkaman/p/4873949.html
Copyright © 2011-2022 走看看