9 releases

0.2.0 Feb 15, 2024
0.1.26 Dec 6, 2023
0.1.25 Sep 10, 2023
0.1.23 Aug 3, 2023
0.1.20 Mar 30, 2023

#725 in Filesystem

Download history 137/week @ 2024-02-11 33/week @ 2024-02-18 42/week @ 2024-02-25 15/week @ 2024-03-03 79/week @ 2024-03-10 83/week @ 2024-03-17 43/week @ 2024-03-24 47/week @ 2024-03-31 1/week @ 2024-04-07 7/week @ 2024-04-14

101 downloads per month
Used in 3 crates (via wnfs)

Apache-2.0

190KB
3.5K SLoC

⚠️ Work in progress ⚠️

This Rust crate provides an implementation of a Hash Array Mapped Trie (HAMT) based on IPLD.

HAMT is a data structure that hashes keys and uses increments of the hash at each level to determine placement of the entry or child node in the tree structure.

The number of bits used for index calculation at each level is determined by the bitWidth. Each node can hold up to 2^bitWidth elements, which are stored in an array. Entries are stored in key-sorted order in buckets. If a bucket already contains the maximum number of elements, a new child node is created and entries are inserted into the new node.

The data elements array is only allocated to store actual entries, and a map bitfield is used to determine if an index exists in the data array.

The implementation is based on fvm_ipld_hamt with some modifications for async blockstore access and immutability-by-default.

Usage

use wnfs_hamt::Node;
use wnfs_common::MemoryBlockStore;

let store = &MemoryBlockStore::default();
let scores: Node<String, usize> = Rc::new(Node::default());

scores.set("Mandy", 30, store).await?;
let result = scores.get("Mandy", store).await?;

Dependencies

~8–16MB
~206K SLoC