feat: set set_total_order_seek true (#474)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2024-05-15 22:58:10 +08:00 committed by GitHub
parent fd1f368601
commit 014eb7fde9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 20 deletions

16
Cargo.lock generated
View File

@ -959,7 +959,7 @@ dependencies = [
[[package]]
name = "dragonfly-client"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"anyhow",
"bytes",
@ -1022,7 +1022,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-backend"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"dragonfly-client-core",
"futures",
@ -1040,7 +1040,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-config"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"dragonfly-client-core",
"home",
@ -1059,7 +1059,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-core"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"libloading",
"reqwest",
@ -1070,7 +1070,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-init"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"anyhow",
"clap",
@ -1086,7 +1086,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-storage"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"base16ct",
"blake3",
@ -1110,7 +1110,7 @@ dependencies = [
[[package]]
name = "dragonfly-client-util"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"dragonfly-api",
"dragonfly-client-core",
@ -1568,7 +1568,7 @@ dependencies = [
[[package]]
name = "hdfs"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"dragonfly-client-backend",
"dragonfly-client-core",

View File

@ -12,7 +12,7 @@ members = [
]
[workspace.package]
version = "0.1.59"
version = "0.1.60"
authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/client.git"
@ -22,13 +22,13 @@ readme = "README.md"
edition = "2021"
[workspace.dependencies]
dragonfly-client = { path = "dragonfly-client", version = "0.1.59" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.59" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.59" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.59" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.59" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.59" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.59" }
dragonfly-client = { path = "dragonfly-client", version = "0.1.60" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.60" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.60" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.60" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.60" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.60" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.60" }
thiserror = "1.0"
dragonfly-api = "2.0.112"
reqwest = { version = "0.11.27", features = ["stream", "native-tls", "default-tls", "rustls-tls"] }

View File

@ -19,7 +19,7 @@ use dragonfly_client_core::{
error::{ErrorType, OrErr},
Error, Result,
};
use rocksdb::WriteOptions;
use rocksdb::{ReadOptions, WriteOptions};
use std::{ops::Deref, path::Path};
use tracing::info;
@ -55,7 +55,7 @@ impl RocksdbStorageEngine {
const DEFAULT_BLOCK_SIZE: usize = 64 * 1024;
/// DEFAULT_CACHE_SIZE is the default cache size for rocksdb.
const DEFAULT_CACHE_SIZE: usize = 16 * 1024 * 1024;
const DEFAULT_CACHE_SIZE: usize = 32 * 1024 * 1024;
/// open opens a rocksdb storage engine with the given directory and column families.
pub fn open(dir: &Path, cf_names: &[&str]) -> Result<Self> {
@ -67,7 +67,7 @@ impl RocksdbStorageEngine {
options.increase_parallelism(num_cpus::get() as i32);
options.set_max_open_files(Self::DEFAULT_MAX_OPEN_FILES);
// Set prefix extractor to reduce the memory usage of bloom filter.
options.set_prefix_extractor(rocksdb::SliceTransform::create_fixed_prefix(128));
options.set_prefix_extractor(rocksdb::SliceTransform::create_fixed_prefix(64));
options.set_memtable_prefix_bloom_ratio(0.2);
// Initialize rocksdb block based table options.
@ -93,7 +93,12 @@ impl Operations for RocksdbStorageEngine {
// get gets the object by key.
fn get<O: DatabaseObject>(&self, key: &[u8]) -> Result<Option<O>> {
let cf = cf_handle::<O>(self)?;
let value = self.get_cf(cf, key).or_err(ErrorType::StorageError)?;
let mut options = ReadOptions::default();
options.set_total_order_seek(true);
let value = self
.get_cf_opt(cf, key, &options)
.or_err(ErrorType::StorageError)?;
match value {
Some(value) => Ok(Some(O::deserialize_from(&value)?)),
None => Ok(None),