提供基本的ttl测试用例
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

187 行
7.2 KiB

  1. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. #ifndef STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
  5. #define STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
  6. #include <stddef.h>
  7. #include "leveldb/export.h"
  8. namespace leveldb {
  9. class Cache;
  10. class Comparator;
  11. class Env;
  12. class FilterPolicy;
  13. class Logger;
  14. class Snapshot;
  15. // DB contents are stored in a set of blocks, each of which holds a
  16. // sequence of key,value pairs. Each block may be compressed before
  17. // being stored in a file. The following enum describes which
  18. // compression method (if any) is used to compress a block.
  19. enum CompressionType {
  20. // NOTE: do not change the values of existing entries, as these are
  21. // part of the persistent format on disk.
  22. kNoCompression = 0x0,
  23. kSnappyCompression = 0x1
  24. };
  25. // Options to control the behavior of a database (passed to DB::Open)
  26. struct LEVELDB_EXPORT Options {
  27. // Create an Options object with default values for all fields.
  28. Options();
  29. // -------------------
  30. // Parameters that affect behavior
  31. // Comparator used to define the order of keys in the table.
  32. // Default: a comparator that uses lexicographic byte-wise ordering
  33. //
  34. // REQUIRES: The client must ensure that the comparator supplied
  35. // here has the same name and orders keys *exactly* the same as the
  36. // comparator provided to previous open calls on the same DB.
  37. const Comparator* comparator;
  38. // If true, the database will be created if it is missing.
  39. bool create_if_missing = false;
  40. // If true, an error is raised if the database already exists.
  41. bool error_if_exists = false;
  42. // If true, the implementation will do aggressive checking of the
  43. // data it is processing and will stop early if it detects any
  44. // errors. This may have unforeseen ramifications: for example, a
  45. // corruption of one DB entry may cause a large number of entries to
  46. // become unreadable or for the entire DB to become unopenable.
  47. bool paranoid_checks = false;
  48. // Use the specified object to interact with the environment,
  49. // e.g. to read/write files, schedule background work, etc.
  50. // Default: Env::Default()
  51. Env* env;
  52. // Any internal progress/error information generated by the db will
  53. // be written to info_log if it is non-null, or to a file stored
  54. // in the same directory as the DB contents if info_log is null.
  55. Logger* info_log = nullptr;
  56. // -------------------
  57. // Parameters that affect performance
  58. // Amount of data to build up in memory (backed by an unsorted log
  59. // on disk) before converting to a sorted on-disk file.
  60. //
  61. // Larger values increase performance, especially during bulk loads.
  62. // Up to two write buffers may be held in memory at the same time,
  63. // so you may wish to adjust this parameter to control memory usage.
  64. // Also, a larger write buffer will result in a longer recovery time
  65. // the next time the database is opened.
  66. size_t write_buffer_size = 4 * 1024 * 1024;
  67. // Number of open files that can be used by the DB. You may need to
  68. // increase this if your database has a large working set (budget
  69. // one open file per 2MB of working set).
  70. int max_open_files = 1000;
  71. // Control over blocks (user data is stored in a set of blocks, and
  72. // a block is the unit of reading from disk).
  73. // If non-null, use the specified cache for blocks.
  74. // If null, leveldb will automatically create and use an 8MB internal cache.
  75. Cache* block_cache = nullptr;
  76. // Approximate size of user data packed per block. Note that the
  77. // block size specified here corresponds to uncompressed data. The
  78. // actual size of the unit read from disk may be smaller if
  79. // compression is enabled. This parameter can be changed dynamically.
  80. size_t block_size = 4 * 1024;
  81. // Number of keys between restart points for delta encoding of keys.
  82. // This parameter can be changed dynamically. Most clients should
  83. // leave this parameter alone.
  84. int block_restart_interval = 16;
  85. // Leveldb will write up to this amount of bytes to a file before
  86. // switching to a new one.
  87. // Most clients should leave this parameter alone. However if your
  88. // filesystem is more efficient with larger files, you could
  89. // consider increasing the value. The downside will be longer
  90. // compactions and hence longer latency/performance hiccups.
  91. // Another reason to increase this parameter might be when you are
  92. // initially populating a large database.
  93. size_t max_file_size = 2 * 1024 * 1024;
  94. // Compress blocks using the specified compression algorithm. This
  95. // parameter can be changed dynamically.
  96. //
  97. // Default: kSnappyCompression, which gives lightweight but fast
  98. // compression.
  99. //
  100. // Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz:
  101. // ~200-500MB/s compression
  102. // ~400-800MB/s decompression
  103. // Note that these speeds are significantly faster than most
  104. // persistent storage speeds, and therefore it is typically never
  105. // worth switching to kNoCompression. Even if the input data is
  106. // incompressible, the kSnappyCompression implementation will
  107. // efficiently detect that and will switch to uncompressed mode.
  108. CompressionType compression = kSnappyCompression;
  109. // EXPERIMENTAL: If true, append to existing MANIFEST and log files
  110. // when a database is opened. This can significantly speed up open.
  111. //
  112. // Default: currently false, but may become true later.
  113. bool reuse_logs = false;
  114. // If non-null, use the specified filter policy to reduce disk reads.
  115. // Many applications will benefit from passing the result of
  116. // NewBloomFilterPolicy() here.
  117. const FilterPolicy* filter_policy = nullptr;
  118. };
  119. // Options that control read operations
  120. struct LEVELDB_EXPORT ReadOptions {
  121. ReadOptions() = default;
  122. // If true, all data read from underlying storage will be
  123. // verified against corresponding checksums.
  124. bool verify_checksums = false;
  125. // Should the data read for this iteration be cached in memory?
  126. // Callers may wish to set this field to false for bulk scans.
  127. bool fill_cache = true;
  128. // If "snapshot" is non-null, read as of the supplied snapshot
  129. // (which must belong to the DB that is being read and which must
  130. // not have been released). If "snapshot" is null, use an implicit
  131. // snapshot of the state at the beginning of this read operation.
  132. const Snapshot* snapshot = nullptr;
  133. };
  134. // Options that control write operations
  135. struct LEVELDB_EXPORT WriteOptions {
  136. WriteOptions() = default;
  137. // If true, the write will be flushed from the operating system
  138. // buffer cache (by calling WritableFile::Sync()) before the write
  139. // is considered complete. If this flag is true, writes will be
  140. // slower.
  141. //
  142. // If this flag is false, and the machine crashes, some recent
  143. // writes may be lost. Note that if it is just the process that
  144. // crashes (i.e., the machine does not reboot), no writes will be
  145. // lost even if sync==false.
  146. //
  147. // In other words, a DB write with sync==false has similar
  148. // crash semantics as the "write()" system call. A DB write
  149. // with sync==true has similar crash semantics to a "write()"
  150. // system call followed by "fsync()".
  151. bool sync = false;
  152. };
  153. } // namespace leveldb
  154. #endif // STORAGE_LEVELDB_INCLUDE_OPTIONS_H_