Commit f08c155
Add complete B+ tree redistribution and Vec-compatible interface to CompressedLeafNode
- Implement borrowing methods for node redistribution:
- borrow_last(): Remove and return last key-value pair for left sibling donation
- borrow_first(): Remove and return first key-value pair for right sibling donation
- Both methods respect can_donate() constraints and maintain sorted order
- Implement acceptance methods for receiving redistributed items:
- accept_from_left(): Insert item at beginning from left sibling
- accept_from_right(): Insert item at end from right sibling
- Both maintain internal sorted order through proper insertion
- Implement merge_from() for node consolidation:
- Efficiently merge all content from another node using ptr::copy_nonoverlapping
- Preserve next pointer chain for linked list integrity
- Clear source node after merge
- Add Vec-compatible interface with wrapper types:
- CompressedKeyView: Read-only Vec-like access to keys with indexing
- CompressedValueView: Read-only Vec-like access to values with indexing
- CompressedValueViewMut: Mutable Vec-like access to values with indexing
- All support len(), is_empty(), get(), and Index/IndexMut traits
- Add comprehensive test coverage (50 total tests):
- Borrowing scenarios: basic functionality, donation constraints, edge cases
- Redistribution simulation: realistic left-to-right donation scenario
- Merging functionality: content consolidation and next pointer handling
- Vec interface: indexing, bounds checking, mutable operations, panic behavior
- All tests pass: 50 CompressedLeafNode tests + 81 library tests + 81 integration tests
- Maintains 256-byte (4 cache lines) memory footprint
- Full API compatibility with LeafNode for B+ tree operations
Co-authored-by: Ona <no-reply@ona.com>1 parent 17511fe commit f08c155
1 file changed
+661
-0
lines changed
0 commit comments