Skip to main content

Crate leveldb

Crate leveldb 

Source
Expand description

Rust interface for Google’s LevelDB key-value storage library.

§Crate Features

§snappy (enabled by default)

Enables Snappy compression support for data compression. When enabled, LevelDB can use Snappy to compress data before writing to disk, reducing storage space at the cost of additional CPU overhead during compression and decompression.

§zstd (enabled by default)

Enables Zstd compression support for data compression. When enabled, LevelDB can use Zstd to compress data before writing to disk.

The compression level can be set during compilation only, using the LEVELDB_RS_BINDING_OPTIONS_ZSTD_DEFAULT_COMPRESSION_LEVEL environment variable. See the Compilation Environment Variables section for details.

§enable_lto

Enables Link-Time Optimization (LTO) for the underlying third-party libraries compilation. It should improve performance by allowing the compiler to perform optimizations across compilation units, at the cost of longer compilation times.

§logger

Enables custom logging functionality for LevelDB operations. When enabled, custom log handlers can be used to capture and process LevelDB’s internal info log messages. Check module logger for more information.

§Environment Variables for Compilation

§LEVELDB_RS_BINDING_FORMAT_NUM_LEVELS

Customizes the number of LSM-tree levels in LevelDB. The default value is 7. It changes the value of kNumLevels in both deps/leveldb/db/dbformat.h and deps/leveldb/db/version_set.cc.

Example:

LEVELDB_RS_BINDING_FORMAT_NUM_LEVELS=10 cargo build

§LEVELDB_RS_BINDING_FORMAT_L0_COMPACTION_TRIGGER

Customizes the number of Level-0 files that trigger compaction. The default value is 4. It changes the value of kL0_CompactionTrigger in deps/leveldb/db/dbformat.h.

Example:

LEVELDB_RS_BINDING_FORMAT_L0_COMPACTION_TRIGGER=8 cargo build

§LEVELDB_RS_BINDING_FORMAT_L0_SLOWDOWN_WRITES_TRIGGER

Customizes the number of Level-0 files that trigger write slowdown. The default value is 8. It changes the value of kL0_SlowdownWritesTrigger in deps/leveldb/db/dbformat.h.

Example:

LEVELDB_RS_BINDING_FORMAT_L0_SLOWDOWN_WRITES_TRIGGER=12 cargo build

§LEVELDB_RS_BINDING_FORMAT_L0_STOP_WRITES_TRIGGER

Customizes the number of Level-0 files that trigger write stop. The default value is 12. It changes the value of kL0_StopWritesTrigger in deps/leveldb/db/dbformat.h.

Example:

LEVELDB_RS_BINDING_FORMAT_L0_STOP_WRITES_TRIGGER=16 cargo build

§LEVELDB_RS_BINDING_FORMAT_MAX_MEM_COMPACT_LEVEL

Customizes the maximum level for memory compaction. The default value is 2. It changes the value of kMaxMemCompactLevel in deps/leveldb/db/dbformat.h.

Example:

LEVELDB_RS_BINDING_FORMAT_MAX_MEM_COMPACT_LEVEL=3 cargo build

§LEVELDB_RS_BINDING_FORMAT_READ_BYTES_PERIOD

Customizes the read bytes period for rate limiting. The default value is 1048576. It changes the value of kReadBytesPeriod in deps/leveldb/db/dbformat.h.

Example:

LEVELDB_RS_BINDING_FORMAT_READ_BYTES_PERIOD=2097152 cargo build

§LEVELDB_RS_BINDING_OPTIONS_ZSTD_DEFAULT_COMPRESSION_LEVEL

Customizes the default Zstd compression level. The default value is 1. It changes the value of zstd_compression_level in deps/leveldb/include/leveldb/options.h.

Example:

LEVELDB_RS_BINDING_OPTIONS_ZSTD_DEFAULT_COMPRESSION_LEVEL=3 cargo build

§LEVELDB_RS_BINDING_CLEAR_CODE_CHANGES

When set, it automatically resets the LevelDB source code to the original state after build completion. This is useful to keep the source code clean after building with custom configurations.

Example:

LEVELDB_RS_BINDING_FORMAT_NUM_LEVELS=8 LEVELDB_RS_BINDING_CLEAR_CODE_CHANGES=y cargo build

§Examples

Check here.

Re-exports§

pub use crate::database::batch;
pub use crate::database::compaction;
pub use crate::database::comparator;
pub use crate::database::error;
pub use crate::database::iterator;
pub use crate::database::kv;
pub use crate::database::management;
pub use crate::database::options;
pub use crate::database::property;
pub use crate::database::snapshots;
pub use crate::database::statistics;

Modules§

database
The main database module, allowing to interact with LevelDB on a key-value basis.

Traits§

Version
Library version information