#avl-tree #data #file #index-file #index #memmap

idx_file

This is a library for handling single-dimensional array data. It uses mmap and avltriee.

43 releases (28 breaking)

0.64.0 Feb 14, 2024
0.62.0 Feb 9, 2024
0.48.0 Dec 27, 2023
0.46.2 Oct 11, 2023
0.34.0 Jul 14, 2023

#365 in Filesystem

Download history 269/week @ 2023-12-18 243/week @ 2023-12-25 155/week @ 2024-01-01 69/week @ 2024-01-08 50/week @ 2024-01-15 111/week @ 2024-01-22 83/week @ 2024-01-29 99/week @ 2024-02-05 229/week @ 2024-02-12 9/week @ 2024-02-19 249/week @ 2024-02-26 9/week @ 2024-03-04 18/week @ 2024-03-11 3/week @ 2024-03-18 4/week @ 2024-03-25 105/week @ 2024-04-01

132 downloads per month
Used in 12 crates (2 directly)

MIT/Apache

8KB
110 lines

idx_file

Features

This is a library for handling single-dimensional array data. It uses mmap and avltriee.

Basically, the data that can be handled must be fixed-length data, but we also have a trait for handling variable-length data.

Array data is a balanced tree algorithm that iterates from the minimum value to the maximum value, but the inserted value is always added to the end of the file and stays in the same position all the time. In other words, sorting, searching, and obtaining values ​​by specifying rows can all be processed at high speed. Also, since I'm using mmap, when I update the value it's automatically saved to the file.

This crate is forked from https://crates.io/crates/idx_sized

Usage

init

use idx_file::IdxFile;

let mut idx=IdxFile::<i64>::new("hoge.idx").unwrap();

insert

idx.insert(&100);
idx.insert(&300);
idx.insert(&100);
idx.insert(&150);

update

idx.update(2, &50);

delete

idx.delete(1);
for row in idx.iter() {
    println!(" {} : {}", row, **unsafe { idx.get_unchecked(row) });
}

for row in idx.iter_by(&100) {
    println!(" {} : {}", row, **unsafe { idx.get_unchecked(row) });
}
for row in idx.iter_from(&100) {
    println!(" {} : {}", row, **unsafe { idx.get_unchecked(row) });
}
for row in idx.iter_to(&200) {
    println!(" {} : {}", row, **unsafe { idx.get_unchecked(row) });
}
for row in idx.iter_range(&100, &200) {
    println!(" {} : {}", row, **unsafe { idx.get_unchecked(row) });
}

Dependencies

~1–1.4MB
~23K SLoC