Skip to content

0.3.0 - New crates, new architecture

Pre-release
Pre-release
Compare
Choose a tag to compare
@marvin-j97 marvin-j97 released this 12 Jan 13:37
· 719 commits to main since this release
ec2ab25

All this is breaking and unstable!!!

New architecture

lsm-tree is now a much more simple, primitive, commit-log agnostic LSM-KV crate. It serves as the foundation for fjall which will take its place of a full-featured LSM-based storage engine akin to RocksDB. See details below.

Bloom filters #12

Implemented bloom filters for point lookups.

Migration

Change

lsm-tree = "0.2.3"

to

fjall = "0.3.0"

Simple example, old:

use lsm_tree::Config;

fn main() -> lsm_tree::Result<()> {
    let tree = Config::default().open()?;

    tree.insert("abc", "def")?;
    tree.flush()?;

    let item = tree.get("abc")?;

    Ok(())
}

new:

use fjall::{Config, PartitionCreateOptions};

fn main() -> fjall::Result<()> {
    let keyspace = Config::default().open()?;
    let tree = keyspace.open_partition("default", PartitionCreateOptions::default())?;

    tree.insert("abc", "def")?;
    keyspace.persist()?;

    let item = tree.get("abc")?;

    Ok(())
}

Instead of a single tree, there is now a top-level keyspace that may contain multiple partitions. Use open_partition to get a handle to a partition. It will be created on the fly it it didn't exist before. A partition then has the same API as Tree used to have.

A partition should only be opened once. Opening a partition is not expensive, but it can be avoided by keeping the partition handle around. Keyspace and PartitionHandle are both thread-safe and can be cloned around freely. A Keyspace should be only be opened once, and one keyspace should be enough for any application (it is the equivalent of a RocksDB Database, each partition being a Column Family).

PartitionCreateOptions allows adjusting some settings like the block size and the levels of the LSM-tree. Once a partition is created, these options are fixed and will not be taken into account after recovery.

There are some runtime partition options that can be changed during runtime on demand however, like:

use fjall::compaction::Levelled;

partition
  .set_compaction_strategy(Arc::new(Levelled::default()))
  .set_max_memtable_size(/* 16 MiB */ 16 * 1_024 * 1_024);

More documentation to follow.