Skip to main content

Module dictionary

Module dictionary 

Source
Expand description

Dictionary encoding for repeated strings.

If your data has lots of repeated strings (like node labels or edge types), dictionary encoding stores each unique string once and references it by a small integer code. A million “Person” labels becomes one string + a million 4-byte codes instead of a million strings.

§Example

let mut builder = DictionaryBuilder::new();
builder.add("Person");
builder.add("Company");
builder.add("Person");  // same as first - reuses code 0
builder.add("Person");  // reuses code 0 again

let dict = builder.build();
// Dictionary: ["Person", "Company"]
// Codes:      [0, 1, 0, 0]
assert_eq!(dict.dictionary_size(), 2);  // Only 2 unique strings stored

Structs§

DictionaryBuilder
Builds a dictionary encoding by streaming values through.
DictionaryEncoding
Stores repeated strings efficiently by referencing them with integer codes.

Traits§

IntoDictionaryEncoding
Extension trait for building dictionary encodings from iterators.