Skip to content

Commit

Permalink
Merge pull request #79 from Congyuwang/rocksdb-v8.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang authored Sep 27, 2023
2 parents 3431c98 + ec9789a commit 2fba6e8
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "RocksDict"
version = "0.3.3"
version = "0.3.14"
edition = "2021"
description = "Rocksdb Python Binding"

Expand All @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion python/rocksdict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 8 additions & 1 deletion python/rocksdict/rocksdict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ __all__ = ["Rdict",
"AccessType",
"Snapshot",
"CompactOptions",
"BottommostLevelCompaction"]
"BottommostLevelCompaction",
"KeyEncodingType"]

class DataBlockIndexType:
@staticmethod
Expand Down Expand Up @@ -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: ...
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<CompactOptionsPy>()?;
m.add_class::<BottommostLevelCompactionPy>()?;
m.add_class::<ChecksumTypePy>()?;
m.add_class::<KeyEncodingTypePy>()?;
pyo3_log::init();
Ok(())
}
40 changes: 40 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")]
Expand Down Expand Up @@ -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,
}
}
}
Expand All @@ -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,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rdict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2fba6e8

Please sign in to comment.