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 |
|
#779 in Filesystem
54 downloads per month
Used in 12 crates
(2 directly)
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);
search
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