Expand description

Rocksdb support for OpenDAL

Note

The storage format for this service is not stable yet.

PLEASE DON’T USE THIS SERVICE FOR PERSIST DATA.

Configuration

  • root: Set the working directory of OpenDAL
  • datadir: Set the path to the rocksdb data directory

You can refer to Builder’s docs for more information

Environment

  • OPENDAL_ROCKSDB_ROOT optional
  • OPENDAL_ROCKSDB_DATADIR required

Example

Initiate via environment variables:

Set environment correctly:

export OPENDAL_ROCKSDB_ROOT=/path/to/root
export OPENDAL_ROCKSDB_DATADIR=/path/to/data
use anyhow::Result;
use opendal::Object;
use opendal::Operator;
use opendal::Scheme;

#[tokio::main]
async fn main() -> Result<()> {
    let op = Operator::from_env(Scheme::Rocksdb)?;

    // create an object handler to start operation on rocksdb!
    let _op: Object = op.object("hello_rocksdb!");

    Ok(())
}

Via Builder

use anyhow::Result;
use opendal::services::rocksdb;
use opendal::Object;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let accessor = rocksdb::Builder::default()
        .datadir("/tmp/opendal/rocksdb")
        .build()?;

    let op: Operator = Operator::new(accessor);
    let _: Object = op.object("test_file");
    Ok(())
}

Structs

Rocksdb backend builder