diff --git a/Cargo.toml b/Cargo.toml index e371df2..a907456 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "RocksDict" -version = "0.3.3" +version = "0.3.14" edition = "2021" description = "Rocksdb Python Binding" @@ -11,8 +11,8 @@ name = "rocksdict" crate-type = ["cdylib"] [dependencies] -rocksdb = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.1.1" } -librocksdb-sys = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.1.1" } +rocksdb = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.5.3" } +librocksdb-sys = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.5.3" } pyo3-log = "0.8" log = "0.4" serde = { version = "1", features = ["derive"] } diff --git a/pyproject.toml b/pyproject.toml index 7c83629..5829212 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rocksdict" -version = "0.3.13" +version = "0.3.14" description = "Rocksdb Python Binding" long_description_content_type="text/markdown" readme = "README.md" diff --git a/python/rocksdict/__init__.py b/python/rocksdict/__init__.py index eb60db1..91167b8 100644 --- a/python/rocksdict/__init__.py +++ b/python/rocksdict/__init__.py @@ -31,7 +31,8 @@ "Env", "FifoCompactOptions", "CompactOptions", - "BottommostLevelCompaction"] + "BottommostLevelCompaction", + "KeyEncodingType"] Rdict.__enter__ = lambda self: self Rdict.__exit__ = lambda self, exc_type, exc_val, exc_tb: self.close() diff --git a/python/rocksdict/rocksdict.pyi b/python/rocksdict/rocksdict.pyi index 86d9c54..58919b4 100644 --- a/python/rocksdict/rocksdict.pyi +++ b/python/rocksdict/rocksdict.pyi @@ -29,7 +29,8 @@ __all__ = ["Rdict", "AccessType", "Snapshot", "CompactOptions", - "BottommostLevelCompaction"] + "BottommostLevelCompaction", + "KeyEncodingType"] class DataBlockIndexType: @staticmethod @@ -538,3 +539,9 @@ class CompactOptions: def set_bottommost_level_compaction(self, lvl: BottommostLevelCompaction) -> None: ... def set_change_level(self, v: bool) -> None: ... def set_target_level(self, lvl: int) -> None: ... + +class KeyEncodingType: + @staticmethod + def none() -> KeyEncodingType: ... + @staticmethod + def prefix() -> KeyEncodingType: ... diff --git a/src/lib.rs b/src/lib.rs index 5075a3e..1ccde39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,7 @@ fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; + m.add_class::()?; pyo3_log::init(); Ok(()) } diff --git a/src/options.rs b/src/options.rs index 8818af1..1546e7f 100644 --- a/src/options.rs +++ b/src/options.rs @@ -208,6 +208,26 @@ pub(crate) struct BlockBasedOptionsPy(BlockBasedOptions); #[pyclass(name = "CuckooTableOptions")] pub(crate) struct CuckooTableOptionsPy(CuckooTableOptions); +/// Used in `PlainTableFactoryOptions`. +#[derive(Clone)] +#[pyclass(name = "KeyEncodingType")] +pub(crate) struct KeyEncodingTypePy(KeyEncodingType); + +#[pymethods] +impl KeyEncodingTypePy { + /// Always write full keys. + #[staticmethod] + pub fn plain() -> Self { + KeyEncodingTypePy(KeyEncodingType::Plain) + } + + /// Find opportunities to write the same prefix for multiple rows. + #[staticmethod] + pub fn prefix() -> Self { + KeyEncodingTypePy(KeyEncodingType::Prefix) + } +} + /// /// Used with DBOptions::set_plain_table_factory. /// See official [wiki](https://github.com/facebook/rocksdb/wiki/PlainTable-Format) for more @@ -232,6 +252,18 @@ pub(crate) struct PlainTableFactoryOptionsPy { #[pyo3(get, set)] index_sparseness: usize, + + #[pyo3(get, set)] + huge_page_tlb_size: usize, + + #[pyo3(get, set)] + encoding_type: KeyEncodingTypePy, + + #[pyo3(get, set)] + full_scan_mode: bool, + + #[pyo3(get, set)] + store_index_in_file: bool, } #[pyclass(name = "Cache")] @@ -2391,6 +2423,10 @@ impl PlainTableFactoryOptionsPy { bloom_bits_per_key: 10, hash_table_ratio: 0.75, index_sparseness: 16, + huge_page_tlb_size: 0, + encoding_type: KeyEncodingTypePy(KeyEncodingType::Plain), + full_scan_mode: false, + store_index_in_file: false, } } } @@ -2409,6 +2445,10 @@ impl PlainTableFactoryOptionsPy { bloom_bits_per_key: self.bloom_bits_per_key, hash_table_ratio: self.hash_table_ratio, index_sparseness: self.index_sparseness, + huge_page_tlb_size: self.huge_page_tlb_size, + encoding_type: self.encoding_type.0, + full_scan_mode: self.full_scan_mode, + store_index_in_file: self.store_index_in_file, } } } diff --git a/src/rdict.rs b/src/rdict.rs index b4fb6c3..057bf76 100644 --- a/src/rdict.rs +++ b/src/rdict.rs @@ -1313,7 +1313,7 @@ fn get_batch_inner<'a>( for key in key_list { keys.push(encode_key(key, raw_mode)?); } - db.batched_multi_get_cf_opt(cf.deref(), keys, false, read_opt) + db.batched_multi_get_cf_opt(cf.deref(), &keys, false, read_opt) }; let result = PyList::empty(py); for v in values {