Skip to content

Commit 71dfc54

Browse files
committed
update docs
1 parent c7c635f commit 71dfc54

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/rust/static-btree/docs/implementation_plan.md

+24
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ The structure **allows duplicate keys**. `lower_bound` returns **all** offsets
117117

118118
All search routines keep **only a small, fixed number of nodes in memory**. When descending, a node is fetched via `reader.seek()` + `reader.read_exact()` into a scratch buffer. The maximum resident memory during search is therefore `(H + 2) × B × size_of<Entry<K>>`, typically a few kilobytes even for large trees.
119119

120+
### 3.9 Query Operators
121+
To support a richer query API, the static B+Tree will expose all common comparison operators on keys:
122+
* **Eq**: exact match ⇒ all offsets where `key == target`.
123+
* **Ne**: not equal ⇒ all offsets where `key != target`.
124+
* **Gt**: greater than ⇒ all offsets where `key > target`.
125+
* **Ge**: greater or equal ⇒ all offsets where `key >= target`.
126+
* **Lt**: less than ⇒ all offsets where `key < target`.
127+
* **Le**: less or equal ⇒ all offsets where `key <= target`.
128+
129+
#### Design
130+
1. Create `query.rs` defining:
131+
```rust
132+
#[derive(Copy, Clone, Debug)]
133+
pub enum Comparison { Eq, Ne, Gt, Ge, Lt, Le }
134+
```
135+
2. In `StaticBTree<K, R>` add:
136+
- `fn query(&mut self, cmp: Comparison, key: &K) -> Result<Vec<Offset>>`
137+
- Convenience methods: `find_eq`, `find_ne`, `find_gt`, `find_ge`, `find_lt`, `find_le`.
138+
3. Implementation Strategy:
139+
* **Eq** → call `lower_bound`, return matching offsets or empty vec.
140+
* **Ne** → combine results of `<` and `>` scans.
141+
* **Gt/Ge/Lt/Le** → use `lower_bound_index`/`upper_bound_index` to compute start/end, then scan leaf layer entries via `read_entry`.
142+
4. Each operator incurs at most `O(log_B N)` node reads plus a sequential leaf scan.
143+
120144
## 4. Public Rust API
121145

122146
```rust

src/rust/static-btree/docs/progress.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This file tracks the incremental progress of the `static-btree` crate inside **F
1414
|---|-----------|-------|--------|
1515
| 1 | Core infrastructure | • Define `Key` trait<br>• Implement primitive + custom key types<br>• Implement `Entry` struct | `[x]` Done |
1616
| 2 | Implementation plan | • Draft initial policy<br>• Review feedback & iterate | `[x]` Updated ✅ (see implementation_plan.md) |
17-
| 3 | Tree search API | • Design `StaticBTree` struct & public API<br>• Lower‑bound & range search handling duplicates<br>• Streaming node reads | `[~]` In progress |
17+
| 3 | Tree search API | • Design `StaticBTree` struct & public API<br>• Lower‑bound & range search handling duplicates<br>• Streaming node reads<br>• Extended comparison operators via `query.rs` (Eq, Ne, Gt, Ge, Lt, Le) | `[~]` In progress |
1818
| 4 | Builder |`StaticBTreeBuilder` to serialize trees<br>• Construction algorithm following policy | `[x]` Done |
1919
| 5 | Async / HTTP query |`http_stream_query` mirroring packed_rtree<br>• Feature‑gated under `http` | `[ ]` |
2020
| 6 | Testing & Benchmarks| • Unit tests for all key types & duplicate cases<br>• Criterion benchmark suite | `[~]` In progress |
@@ -28,11 +28,12 @@ This file tracks the incremental progress of the `static-btree` crate inside **F
2828

2929
## Next Steps
3030

31-
1. Implement loop‑based `lower_bound` search loading nodes on‑demand.
32-
2. Add contiguous‑duplicate gathering logic across node boundaries.
33-
3. Integrate `StaticBTreeBuilder` construction following the layer‑by‑layer algorithm.
34-
4. Write unit tests (start with u32 and duplicate scenarios).
35-
5. Prototype `http_stream_query` using packed_rtree's client abstraction.
31+
1. Implement extended query API: add `query.rs` with `Comparison` enum and methods (`query`, `find_eq`, `find_ne`, `find_gt`, `find_ge`, `find_lt`, `find_le`).
32+
2. Implement loop‑based `lower_bound` search loading nodes on‑demand.
33+
3. Add contiguous‑duplicate gathering logic across node boundaries if necessary.
34+
4. Integrate `StaticBTreeBuilder` construction following the layer‑by‑layer algorithm.
35+
5. Write unit tests for all new operator methods.
36+
6. Prototype `http_stream_query` using packed_rtree's client abstraction.
3637

3738
## Task Guidelines for Contributors & LLMs
3839

0 commit comments

Comments
 (0)