feat: set set_total_order_seek true (#474)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
fd1f368601
commit
014eb7fde9
|
|
@ -959,7 +959,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client"
|
name = "dragonfly-client"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
@ -1022,7 +1022,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-backend"
|
name = "dragonfly-client-backend"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dragonfly-client-core",
|
"dragonfly-client-core",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
@ -1040,7 +1040,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-config"
|
name = "dragonfly-client-config"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dragonfly-client-core",
|
"dragonfly-client-core",
|
||||||
"home",
|
"home",
|
||||||
|
|
@ -1059,7 +1059,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-core"
|
name = "dragonfly-client-core"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libloading",
|
"libloading",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
|
@ -1070,7 +1070,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-init"
|
name = "dragonfly-client-init"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
@ -1086,7 +1086,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-storage"
|
name = "dragonfly-client-storage"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct",
|
"base16ct",
|
||||||
"blake3",
|
"blake3",
|
||||||
|
|
@ -1110,7 +1110,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dragonfly-client-util"
|
name = "dragonfly-client-util"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dragonfly-api",
|
"dragonfly-api",
|
||||||
"dragonfly-client-core",
|
"dragonfly-client-core",
|
||||||
|
|
@ -1568,7 +1568,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hdfs"
|
name = "hdfs"
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dragonfly-client-backend",
|
"dragonfly-client-backend",
|
||||||
"dragonfly-client-core",
|
"dragonfly-client-core",
|
||||||
|
|
|
||||||
16
Cargo.toml
16
Cargo.toml
|
|
@ -12,7 +12,7 @@ members = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.59"
|
version = "0.1.60"
|
||||||
authors = ["The Dragonfly Developers"]
|
authors = ["The Dragonfly Developers"]
|
||||||
homepage = "https://d7y.io/"
|
homepage = "https://d7y.io/"
|
||||||
repository = "https://github.com/dragonflyoss/client.git"
|
repository = "https://github.com/dragonflyoss/client.git"
|
||||||
|
|
@ -22,13 +22,13 @@ readme = "README.md"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
dragonfly-client = { path = "dragonfly-client", version = "0.1.59" }
|
dragonfly-client = { path = "dragonfly-client", version = "0.1.60" }
|
||||||
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.59" }
|
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.60" }
|
||||||
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.59" }
|
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.60" }
|
||||||
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.59" }
|
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.60" }
|
||||||
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.59" }
|
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.60" }
|
||||||
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.59" }
|
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.60" }
|
||||||
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.59" }
|
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.60" }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
dragonfly-api = "2.0.112"
|
dragonfly-api = "2.0.112"
|
||||||
reqwest = { version = "0.11.27", features = ["stream", "native-tls", "default-tls", "rustls-tls"] }
|
reqwest = { version = "0.11.27", features = ["stream", "native-tls", "default-tls", "rustls-tls"] }
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use dragonfly_client_core::{
|
||||||
error::{ErrorType, OrErr},
|
error::{ErrorType, OrErr},
|
||||||
Error, Result,
|
Error, Result,
|
||||||
};
|
};
|
||||||
use rocksdb::WriteOptions;
|
use rocksdb::{ReadOptions, WriteOptions};
|
||||||
use std::{ops::Deref, path::Path};
|
use std::{ops::Deref, path::Path};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ impl RocksdbStorageEngine {
|
||||||
const DEFAULT_BLOCK_SIZE: usize = 64 * 1024;
|
const DEFAULT_BLOCK_SIZE: usize = 64 * 1024;
|
||||||
|
|
||||||
/// DEFAULT_CACHE_SIZE is the default cache size for rocksdb.
|
/// 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.
|
/// open opens a rocksdb storage engine with the given directory and column families.
|
||||||
pub fn open(dir: &Path, cf_names: &[&str]) -> Result<Self> {
|
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.increase_parallelism(num_cpus::get() as i32);
|
||||||
options.set_max_open_files(Self::DEFAULT_MAX_OPEN_FILES);
|
options.set_max_open_files(Self::DEFAULT_MAX_OPEN_FILES);
|
||||||
// Set prefix extractor to reduce the memory usage of bloom filter.
|
// 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);
|
options.set_memtable_prefix_bloom_ratio(0.2);
|
||||||
|
|
||||||
// Initialize rocksdb block based table options.
|
// Initialize rocksdb block based table options.
|
||||||
|
|
@ -93,7 +93,12 @@ impl Operations for RocksdbStorageEngine {
|
||||||
// get gets the object by key.
|
// get gets the object by key.
|
||||||
fn get<O: DatabaseObject>(&self, key: &[u8]) -> Result<Option<O>> {
|
fn get<O: DatabaseObject>(&self, key: &[u8]) -> Result<Option<O>> {
|
||||||
let cf = cf_handle::<O>(self)?;
|
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 {
|
match value {
|
||||||
Some(value) => Ok(Some(O::deserialize_from(&value)?)),
|
Some(value) => Ok(Some(O::deserialize_from(&value)?)),
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue