RocksDB
RocksDB service support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
-
list -
presign - blocking
Note
OpenDAL will build rocksdb from source by default.
To link with existing rocksdb lib, please set one of the following:
ROCKSDB_LIB_DIR
to the dir that containslibrocksdb.so
ROCKSDB_STATIC
to the dir that containslibrocksdb.a
If the version of RocksDB is below 6.0, you may encounter compatibility
issues. It is advisable to follow the steps provided in the INSTALL
file to build rocksdb, rather than relying on system libraries that
may be outdated and incompatible.
Configuration
root
: Set the working directory ofOpenDAL
datadir
: Set the path to the rocksdb data directory
You can refer to [RocksdbBuilder
]'s docs for more information.
Example
Via Builder
use anyhow::Result;
use opendal::services::Rocksdb;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Rocksdb::default();
builder.datadir("/tmp/opendal/rocksdb");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("datadir".to_string(), "/tmp/opendal/rocksdb".to_string());
let op: Operator = Operator::via_map(Scheme::Rocksdb, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("rocksdb", {
datadir: "/tmp/opendal/rocksdb",
});
}
import opendal
op = opendal.Operator("rocksdb",
datadir="/tmp/opendal/rocksdb",
)