Static succinct index primitives for MoonBit
| Package | Purpose |
|---|---|
| bitvector | Packed bits, rank/select, navigation, codec, space report |
| packed | Internal fixed-width unsigned integer storage |
| eliasfano | Monotone integer index and set/range queries |
| louds | Rooted topology and static byte trie |
| frontcoded | Restart-block compressed sorted byte dictionary |
| binary | Bounded canonical reader and writer |
| support | Errors, limits, byte helpers, and space reports |
| conformance | Cross-structure embeddable smoke check and test suite |
moon add binhongcha/moonsuccinct@0.1.0///|
import {
"binhongcha/moonsuccinct/eliasfano",
"binhongcha/moonsuccinct/louds",
"binhongcha/moonsuccinct/frontcoded",
}let postings = @eliasfano.from_values([
2UL, 5UL, 5UL, 21UL, 144UL, 1000UL,
])
assert_true(postings.contains(144UL))
assert_eq(postings.predecessor(500UL), Some(144UL))
assert_eq(postings.values_in_range(5UL, 1000UL, 10), [5UL, 5UL, 21UL, 144UL])
let restored = @eliasfano.decode(@eliasfano.encode(postings))
assert_eq(restored.to_values(), postings.to_values())let terms : Array[Bytes] = [
b"api/admin", b"api/catalog", b"api/catalog/items", b"docs",
]
let trie = @louds.trie_from_terms(terms)
assert_true(trie.contains(b"api/admin"))
assert_eq(
trie.terms_with_prefix(b"api/catalog", 10),
[b"api/catalog", b"api/catalog/items"],
)let dictionary = @frontcoded.from_terms(
[b"compile.module", b"compile.package", b"config.debug"],
block_size=2,
)
assert_eq(dictionary.term_number(b"compile.package"), Some(1))
assert_eq(dictionary.terms_with_prefix(b"compile.", 10).length(), 2)moon run examples/postings --target wasm-gc
moon run examples/taxonomy --target wasm-gc
moon run examples/dictionary --target wasm-gc
moon run examples/routing --target wasm-gcmoon fmt --check
moon check --target all --deny-warn --warn-list '-implicit_impl_as_method-test_unqualified_package'
moon test --target all --deny-warn --warn-list '-implicit_impl_as_method-test_unqualified_package'
moon build --target all --deny-warn --warn-list '-implicit_impl_as_method-test_unqualified_package'
python tools/count_moonbit.py --minimum 4001Install
Download zipStatic succinct index primitives for MoonBit