Crates.io | art-tree |
lib.rs | art-tree |
version | 0.2.0 |
source | src |
created_at | 2021-09-27 07:55:26.891245 |
updated_at | 2021-12-27 12:30:12.370811 |
description | The Adaptive Radix Tree |
homepage | |
repository | https://github.com/Lagrang/art-rs |
max_upload_size | |
id | 456844 |
size | 98,450 |
The radix tree based on The Adaptive Radix Tree: ARTful Indexing for Main-Memory Databases paper.
use art_tree::ByteString;
use art_tree::KeyBuilder;
use art_tree::Art;
pub fn art_example() {
let mut art = Art::<u16, u16>::new();
for i in 0..u8::MAX as u16 {
assert!(art.insert(i, i), "{}", i);
assert!(matches!(art.get(&i), Some(val) if val == &i));
}
for i in 0..u8::MAX as u16 {
assert!(matches!(art.remove(&i), Some(val) if val == i));
}
let mut art = Art::<ByteString, u16>::new();
for i in 0..u8::MAX as u16 {
let key = KeyBuilder::new().append(i).append(ByteString::new("abc".to_string().as_bytes())).build();
art.upsert(key.clone(), i + 1);
assert!(matches!(art.get(&key), Some(val) if val == &(i + 1)));
}
let from_key = KeyBuilder::new().append(16u16).append(ByteString::new("abc".to_string().as_bytes())).build();
let until_key = KeyBuilder::new().append(20u16).append(ByteString::new("abc".to_string().as_bytes())).build();
assert_eq!(art.range(from_key..=until_key).count(), 5);
assert_eq!(art.iter().count(), u8::MAX as usize);
}