Expand description
High-performance, thread-safe read-only reader for COI (.coi) v1.0 columnar IP databases.
§Features
mmap(default): zero-copy memory-mapped file opening viaReader::openserde(default): direct zero-intermediate-allocation streaming deserialization viaReader::lookupandReader::lookup_with_projectionzstd-c(optional): switch from pure-Rustruzstdto Clibzstdfor maximum cold throughput
§Example
use std::collections::BTreeMap;
use std::net::{IpAddr, Ipv4Addr};
use coip_builder::{BuildOptions, CoipBuilder};
use coip_reader::{Reader, Value};
let mut builder = CoipBuilder::new(BuildOptions::compact());
let mut rec = BTreeMap::new();
rec.insert("iso_code".into(), Value::Utf8("US".into()));
rec.insert("asn".into(), Value::U32(15169));
builder.insert_ipv4_cidr(Ipv4Addr::new(8, 8, 8, 0), 24, rec).unwrap();
let (bytes, _) = builder.build().unwrap();
let reader = Reader::from_bytes(&bytes).unwrap();
let proj = reader.compile_projection(["iso_code"]).unwrap();
let hit = reader
.lookup_projected(IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), &proj)
.unwrap()
.unwrap();
assert_eq!(hit.as_map().unwrap().get("iso_code"), Some(&Value::Utf8("US".into())));
assert!(!hit.as_map().unwrap().contains_key("asn"));Re-exports§
pub use error::ReaderError;pub use error::Result;pub use projection::Projection;pub use reader::Reader;pub use reader::ReaderOptions;
Modules§
- cache
- Lock-sharded concurrent LRU cache for high-throughput multi-threaded reads.
- codec
- Block/section decompression with pure-Rust
ruzstd+lz4_flexdefault, optionalzstd-cfeature, andSection 3: ZstdDictssupport. - error
- index_
reader - IPv4 (
Section 5) and IPv6 (Section 6) index readers with L1 direct buckets,Section 3: ZstdDicts, all 5RidModes, and 16-shard concurrent LRU block cache. - projection
- Compiled Column Projection for skipping unrequested columns and dictionaries.
- reader
- High-level
.coidatabase reader (Reader). - serde_
de - Direct streaming
serde::Deserializerover columnar RowGroups & Dictionaries (zero intermediateBTreeMap/Valueallocation) plusfrom_valuehelper. - source
- Backing storage abstractions (
&[u8],Vec<u8>,mmap,File). - table_
reader - ColumnTable & DictTables readers with rank-indexed validity bitmaps and LRU chunk caches.
Structs§
- File
Header - Fixed 64-byte COI file header at offset 0.
- Schema
- Complete self-describing Schema stored in Section 2.
- Section
Entry - 32-byte entry in the Section Directory.
Enums§
- Section
Kind - Section kind identifier in the Section Directory.
- Value
- Lossless, self-describing dynamic value supporting all COI / MMDB types.