2 个版本
使用旧的 Rust 2015
0.1.1 | 2018年7月7日 |
---|---|
0.1.0 | 2018年7月6日 |
在 数据库管理系统实现 中排名第 246
41KB
916 行(不包括注释)
tuple_storage
轻松存储每类元组到文件。每次访问都是类型安全的。
即使集合增长,数据库也是内存映射的,以便快速访问。
示例用法
$ cargo run create target/demo.ts '(u8, i16, u32, i64)'
$ cargo run show target/demo.ts
(u8, i16, u32, i64)
$ cargo run insert target/demo.ts '(1, 2, 3, 4)'
$ cargo run insert target/demo.ts '(6, 7, 8, 9)'
$ cargo run insert target/demo.ts '(3, 4, 5, 6)'
$ cargo run search target/demo.ts
[
(1, 2, 3, 4)
(3, 4, 5, 6)
(6, 7, 8, 9)
]
found 3 Tuples
$ cargo run search target/demo.ts '<3'
[
(1, 2, 3, 4)
]
found 1 Tuples
$ cargo run search target/demo.ts '=3'
[
(3, 4, 5, 6)
]
found 1 Tuples
$ cargo run search target/demo.ts '>3'
[
(6, 7, 8, 9)
]
found 1 Tuples
$ cargo run remove target/demo.ts '>3'
removed 1 Tuples
$ cargo run search target/demo.ts '>3'
[]
found 0 Tuples
# inserting Tuple violating the Schema:
$ cargo run insert target/demo.ts '(-23, 0, 0, 0)'
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
# searching with an invalid search index
$ cargo run search target/demo.ts '=-2'
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
依赖项
~3.5–5.5MB
~97K SLoC