Skip to content

Commit 2fba6e8

Browse files
authored
Merge pull request #79 from Congyuwang/rocksdb-v8.5.3
2 parents 3431c98 + ec9789a commit 2fba6e8

File tree

7 files changed

+56
-7
lines changed

7 files changed

+56
-7
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "RocksDict"
3-
version = "0.3.3"
3+
version = "0.3.14"
44
edition = "2021"
55
description = "Rocksdb Python Binding"
66

@@ -11,8 +11,8 @@ name = "rocksdict"
1111
crate-type = ["cdylib"]
1212

1313
[dependencies]
14-
rocksdb = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.1.1" }
15-
librocksdb-sys = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.1.1" }
14+
rocksdb = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.5.3" }
15+
librocksdb-sys = { git = "https://github.com/Congyuwang/rust-rocksdb", tag = "v0.21.0+8.5.3" }
1616
pyo3-log = "0.8"
1717
log = "0.4"
1818
serde = { version = "1", features = ["derive"] }

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "rocksdict"
3-
version = "0.3.13"
3+
version = "0.3.14"
44
description = "Rocksdb Python Binding"
55
long_description_content_type="text/markdown"
66
readme = "README.md"

python/rocksdict/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"Env",
3232
"FifoCompactOptions",
3333
"CompactOptions",
34-
"BottommostLevelCompaction"]
34+
"BottommostLevelCompaction",
35+
"KeyEncodingType"]
3536

3637
Rdict.__enter__ = lambda self: self
3738
Rdict.__exit__ = lambda self, exc_type, exc_val, exc_tb: self.close()

python/rocksdict/rocksdict.pyi

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ __all__ = ["Rdict",
2929
"AccessType",
3030
"Snapshot",
3131
"CompactOptions",
32-
"BottommostLevelCompaction"]
32+
"BottommostLevelCompaction",
33+
"KeyEncodingType"]
3334

3435
class DataBlockIndexType:
3536
@staticmethod
@@ -538,3 +539,9 @@ class CompactOptions:
538539
def set_bottommost_level_compaction(self, lvl: BottommostLevelCompaction) -> None: ...
539540
def set_change_level(self, v: bool) -> None: ...
540541
def set_target_level(self, lvl: int) -> None: ...
542+
543+
class KeyEncodingType:
544+
@staticmethod
545+
def none() -> KeyEncodingType: ...
546+
@staticmethod
547+
def prefix() -> KeyEncodingType: ...

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
139139
m.add_class::<CompactOptionsPy>()?;
140140
m.add_class::<BottommostLevelCompactionPy>()?;
141141
m.add_class::<ChecksumTypePy>()?;
142+
m.add_class::<KeyEncodingTypePy>()?;
142143
pyo3_log::init();
143144
Ok(())
144145
}

src/options.rs

+40
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,26 @@ pub(crate) struct BlockBasedOptionsPy(BlockBasedOptions);
208208
#[pyclass(name = "CuckooTableOptions")]
209209
pub(crate) struct CuckooTableOptionsPy(CuckooTableOptions);
210210

211+
/// Used in `PlainTableFactoryOptions`.
212+
#[derive(Clone)]
213+
#[pyclass(name = "KeyEncodingType")]
214+
pub(crate) struct KeyEncodingTypePy(KeyEncodingType);
215+
216+
#[pymethods]
217+
impl KeyEncodingTypePy {
218+
/// Always write full keys.
219+
#[staticmethod]
220+
pub fn plain() -> Self {
221+
KeyEncodingTypePy(KeyEncodingType::Plain)
222+
}
223+
224+
/// Find opportunities to write the same prefix for multiple rows.
225+
#[staticmethod]
226+
pub fn prefix() -> Self {
227+
KeyEncodingTypePy(KeyEncodingType::Prefix)
228+
}
229+
}
230+
211231
///
212232
/// Used with DBOptions::set_plain_table_factory.
213233
/// See official [wiki](https://github.com/facebook/rocksdb/wiki/PlainTable-Format) for more
@@ -232,6 +252,18 @@ pub(crate) struct PlainTableFactoryOptionsPy {
232252

233253
#[pyo3(get, set)]
234254
index_sparseness: usize,
255+
256+
#[pyo3(get, set)]
257+
huge_page_tlb_size: usize,
258+
259+
#[pyo3(get, set)]
260+
encoding_type: KeyEncodingTypePy,
261+
262+
#[pyo3(get, set)]
263+
full_scan_mode: bool,
264+
265+
#[pyo3(get, set)]
266+
store_index_in_file: bool,
235267
}
236268

237269
#[pyclass(name = "Cache")]
@@ -2391,6 +2423,10 @@ impl PlainTableFactoryOptionsPy {
23912423
bloom_bits_per_key: 10,
23922424
hash_table_ratio: 0.75,
23932425
index_sparseness: 16,
2426+
huge_page_tlb_size: 0,
2427+
encoding_type: KeyEncodingTypePy(KeyEncodingType::Plain),
2428+
full_scan_mode: false,
2429+
store_index_in_file: false,
23942430
}
23952431
}
23962432
}
@@ -2409,6 +2445,10 @@ impl PlainTableFactoryOptionsPy {
24092445
bloom_bits_per_key: self.bloom_bits_per_key,
24102446
hash_table_ratio: self.hash_table_ratio,
24112447
index_sparseness: self.index_sparseness,
2448+
huge_page_tlb_size: self.huge_page_tlb_size,
2449+
encoding_type: self.encoding_type.0,
2450+
full_scan_mode: self.full_scan_mode,
2451+
store_index_in_file: self.store_index_in_file,
24122452
}
24132453
}
24142454
}

src/rdict.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ fn get_batch_inner<'a>(
13131313
for key in key_list {
13141314
keys.push(encode_key(key, raw_mode)?);
13151315
}
1316-
db.batched_multi_get_cf_opt(cf.deref(), keys, false, read_opt)
1316+
db.batched_multi_get_cf_opt(cf.deref(), &keys, false, read_opt)
13171317
};
13181318
let result = PyList::empty(py);
13191319
for v in values {

0 commit comments

Comments
 (0)