Skip to content

Commit 4c8d4eb

Browse files
authored
docs: specify the updated LsmIterator::new constructor signature (#150)
1 parent 47ad080 commit 4c8d4eb

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

mini-lsm-book/src/week1-05-read-path.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ In this chapter, you will:
1212
* Implement LSM read path `get` with SSTs.
1313
* Implement LSM read path `scan` with SSTs.
1414

15-
1615
To copy the test cases into the starter code and run them,
1716

1817
```
@@ -22,7 +21,6 @@ cargo x scheck
2221

2322
## Task 1: Two Merge Iterator
2423

25-
2624
In this task, you will need to modify:
2725

2826
```
@@ -51,7 +49,13 @@ type LsmIteratorInner =
5149

5250
So that our internal iterator of the LSM storage engine will be an iterator combining both data from the memtables and the SSTs.
5351

54-
Note that our SST iterator does not support passing an end bound to it. Therefore, you will need to handle the `end_bound` manually in `LsmIterator`. You will need to modify your `LsmIterator` logic to stop when the key from the inner iterator reaches the end boundary.
52+
Currently, our SST iterator doesn't support an end bound for scans. To address this, you'll need to implement this boundary check within the `LsmIterator` itself. This involves updating the `LsmIterator::new` constructor to accept an `end_bound` parameter:
53+
54+
```rust,no_run
55+
pub(crate) fn new(iter: LsmIteratorInner, end_bound: Bound<Bytes>) -> Result<Self> {}
56+
```
57+
58+
You will then need to modify the `LsmIterator`'s iteration logic to ensure it stops when the keys from the inner iterator reach or exceed this specified `end_bound`.
5559

5660
Our test cases will generate some memtables and SSTs in `l0_sstables`, and you will need to scan all of these data out correctly in this task. You do not need to flush SSTs until next chapter. Therefore, you can go ahead and modify your `LsmStorageInner::scan` interface to create a merge iterator over all memtables and SSTs, so as to finish the read path of your storage engine.
5761

mini-lsm-starter/src/block/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl BlockBuilder {
3838
}
3939

4040
/// Adds a key-value pair to the block. Returns false when the block is full.
41+
/// You may find the `bytes::BufMut` trait useful for manipulating binary data.
4142
#[must_use]
4243
pub fn add(&mut self, key: KeySlice, value: &[u8]) -> bool {
4344
unimplemented!()

mini-lsm-starter/src/table/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl SsTableBuilder {
5757

5858
/// Builds the SSTable and writes it to the given path. Use the `FileObject` structure to manipulate the disk objects.
5959
pub fn build(
60-
self,
60+
mut self,
6161
id: usize,
6262
block_cache: Option<Arc<BlockCache>>,
6363
path: impl AsRef<Path>,

0 commit comments

Comments
 (0)