Module string_interner

Module string_interner 

Source
Expand description

String Interning for Path Segments

This module implements string interning to reduce memory usage when storing repeated path segments in the PathTrie and other data structures.

§Memory Savings

For paths like “users.profile.settings.theme”, the segment “users” may appear thousands of times across different paths. String interning ensures each unique segment is stored only once.

§Example

use sochdb_core::string_interner::StringInterner;

let mut interner = StringInterner::new();

// Intern a string - returns a small integer symbol
let sym1 = interner.get_or_intern("users");
let sym2 = interner.get_or_intern("users"); // Same symbol returned

assert_eq!(sym1, sym2); // Same string = same symbol

// Resolve back to string
let s = interner.resolve(sym1);
assert_eq!(s, Some("users"));

§Thread Safety

The ConcurrentStringInterner variant is thread-safe and uses a sharded lock design for concurrent access.

Modules§

global
Global string interner for path segments

Structs§

ConcurrentStringInterner
Thread-safe string interner using sharded locks
StringInterner
A string interner that stores unique strings and returns symbols
Symbol
A symbol representing an interned string