Skip to content

Options while opening a database

Zohaib Sibte Hassan edited this page Mar 11, 2016 · 1 revision

LevelDBWinRT Options object let's you configure your database while you are opening a database. Again sticking to leveldb::Options object you can do stuff like creating database if missing or panic if missing etc. Here is prototype of Options object for LevelDBWinRT

class Options {
  bool CreateIfMissing;
  bool ErrorIfExists;
  bool ParanoidChecks;
  uint32 WriteBufferSize;
  int MaximumOpenFiles;
  uint32 BlockCacheSize;
  uint32 BlockSize;
  int BlockRestartInterval;
  FilterType Filter;
  CompressorType Compressor;
  IKeyComparator Comparator;
};

Where, following options are directly mapped to leveldb::Options:

  • CreateIfMissing (false by default) creates database if missing; directly maps to create_if_missing option of leveldb::Options
  • ErrorIfExists (false by default) fails open if database already exists; directly maps to fail_if_exists of leveldb::Options
  • ParanoidChecks (false by default) corresponds to paranoid_checks in leveldb::Options; see [official documentation] 1 for more details.
  • WriteBufferSize (4MB by default) corresponds to write_buffer_size in leveldb::Options; see [official documentation] 1 for more details.
  • MaximumOpenFiles (1K by default) corresponds to `maximum_open_filesinleveldb::Options``; see [official documentation] 1 for more details.
  • BlockSize (4K by default) corresponds to `block_sizeinleveldb::Options``; see [official documentation] 1 for more details.
  • BlockRestartInterval (16 by default) corresponds to `block_restart_intervalinleveldb::Options``; see [official documentation] 1 for more details.

In addition to above options, following options add some more goodness:

  • BlockCacheSize (8MB by default) the in-memory cache size of LRU cache. This cache is same as leveldb::NewLRUCache
  • Filter (default value is None) defines the type of filter to be used, right now there is only one filter supported BloomFilter. With BloomFilter you should pass BloomFilterParams specifying BitsPerKey. Using filters can greatly improve your read speed, for more information read Bloom filters and LevelDB official documentation.
  • Compressor (default value is None) right now only two options are supported None and Snappy. Snappy is a compression algorithm by Google well integrated into LevelDB. Future might include more options.
  • Comparator (default is null) a custom comparator implementing IKeyComparator interface. Note, comparators are experimental yet; so use them with extreme care.
Clone this wiki locally