| Crates.io | astrie |
| lib.rs | astrie |
| version | 0.2.0 |
| created_at | 2025-02-09 08:02:19.284174+00 |
| updated_at | 2025-02-10 12:03:12.281638+00 |
| description | High-performance hybrid data structure that combines the benefits of tries and B+ trees to provide efficient key-value storage with adaptive behavior based on data patterns. |
| homepage | |
| repository | https://github.com/BoogieBlitz/ASTrie |
| max_upload_size | |
| id | 1548745 |
| size | 98,077 |
A hybrid data structure that efficiently supports fast lookups, insertions, and range queries with an adaptive mechanism to balance memory usage and performance.
1. Trie & B+ Tree Hybrid
2. Adaptive Segmentation
3. Parallelization with Rust’s Ownership Model
4. Efficient Range Queries
5. Cache-aware Structure
1. Hybrid Structure
2. Node Types
enum NodeType {
Trie(TrieNode), // For sparse/prefix-heavy data
BTree(BTreeNode) // For dense data ranges
}
1. Insertion
insert(key, value):
1. Start at root node
2. For each node encountered:
If Trie Node:
- If depth > TRIE_DEPTH_THRESHOLD:
→ Convert to B+ tree (convert_to_btree)
- Otherwise:
→ Navigate using key bytes
→ Create child nodes as needed
If B+ Tree Node:
- If leaf node:
→ Insert key-value pair
→ If too full: split node
→ If too sparse: convert to trie (convert_to_trie)
- If internal node:
→ Navigate to correct child
2. Lookup
get(key):
1. Start at root node
2. For each node encountered:
If Trie Node:
→ Use key bytes to navigate
→ Return value if found at leaf
If B+ Tree Node:
→ Binary search for key
→ Navigate to child if internal node
→ Return value if found at leaf
3. Range Query
range(start_key, end_key):
1. Find path to start_key
2. For each node in path:
If Trie Node:
→ Collect all values in range via DFS
If B+ Tree Node:
→ Use B+ tree's natural ordering
→ Scan leaf nodes using links
1. Trie → B+ Tree Conversion
convert_to_btree(trie_node):
1. Recursively collect all key-value pairs
2. Sort pairs by key
3. Create B+ tree leaf node
4. If too many keys:
→ Split into multiple nodes
→ Create parent nodes as needed
2. B+ Tree → Trie Conversion
convert_to_trie(btree_node):
1. Create empty trie root
2. For each key-value pair:
→ Convert key to byte path
→ Create trie path
→ Store value at leaf
3. Balance if needed
1. Insertions
2. Lookups
3. Range Queries