idx_file

Crates.ioidx_file
lib.rsidx_file
version0.64.0
sourcesrc
created_at2023-05-10 13:43:22.222562
updated_at2024-02-14 11:39:49.528049
descriptionThis is a library for handling single-dimensional array data. It uses mmap and avltriee.
homepage
repositoryhttps://github.com/OdenShirataki/idx_file
max_upload_size
id861343
size20,432
OdenShirataki (OdenShirataki)

documentation

README

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) });
}
Commit count: 143

cargo fmt