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

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

#779 in Filesystem

Download history 19/week @ 2024-07-22 204/week @ 2024-07-29 33/week @ 2024-08-05 31/week @ 2024-08-12 24/week @ 2024-08-19 52/week @ 2024-08-26 11/week @ 2024-09-02 21/week @ 2024-09-09 11/week @ 2024-09-16 104/week @ 2024-09-23 9/week @ 2024-09-30 4/week @ 2024-10-07 15/week @ 2024-10-14 11/week @ 2024-10-21 13/week @ 2024-10-28 15/week @ 2024-11-04

54 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

~0.9–1.4MB
~23K SLoC