Skip to content

Commit c3d062e

Browse files
committed
Follow SlateDb style of method naming
1 parent 2a35f5f commit c3d062e

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

open-log/rfcs/0001-storage.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ struct Record {
9797
value: Bytes,
9898
}
9999

100+
#[derive(Default)]
100101
struct WriteOptions {
101102
await_durable: bool,
102103
}
103104

104105
impl Log {
105-
async fn append(&self, record: Record, options: WriteOptions) -> Result<(), Error>;
106-
async fn append_batch(&self, records: Vec<Record>, options: WriteOptions) -> Result<(), Error>;
106+
async fn append(&self, records: Vec<Record>) -> Result<(), Error>;
107+
async fn append_with_options(&self, records: Vec<Record>, options: WriteOptions) -> Result<(), Error>;
107108
}
108109
```
109110

@@ -119,6 +120,7 @@ struct LogEntry {
119120
}
120121

121122
// TODO: decide which SlateDB ScanOptions parameters to pass through
123+
#[derive(Default)]
122124
struct ScanOptions {
123125
}
124126

@@ -129,27 +131,37 @@ impl ScanIterator {
129131
}
130132

131133
impl Log {
132-
fn scan(&self, key: Bytes, seq_range: impl RangeBounds<u64>, options: ScanOptions) -> ScanIterator;
134+
fn scan(&self, key: Bytes, seq_range: impl RangeBounds<u64>) -> ScanIterator;
135+
fn scan_with_options(&self, key: Bytes, seq_range: impl RangeBounds<u64>, options: ScanOptions) -> ScanIterator;
133136
}
134137
```
135138

136139
### Count API (under consideration)
137140

138-
Lag is a critical metric for tracking progress reading from a log. Without contiguous sequence numbers, computing lag requires the SST enhancements described in [SST Representation](#sst-representation).
141+
Lag is a critical metric for tracking progress reading from a log. Without contiguous sequence numbers, computing lag requires the SST enhancements described in [SST Representation](#sst-representation). This proposal adds an explicit API to count the number of records that are present within any range of the log for a key.
139142

140143
```rust
141144
// TODO: decide which SlateDB ScanOptions parameters to pass through
145+
#[derive(Default)]
142146
struct CountOptions {
143-
approximate: bool,
147+
approximate: bool, // default: false (precise counts)
144148
}
145149

146150
impl Log {
147-
async fn count(&self, key: Bytes, seq_range: impl RangeBounds<u64>, options: CountOptions) -> Result<u64, Error>;
151+
async fn count(&self, key: Bytes, seq_range: impl RangeBounds<u64>) -> Result<u64, Error>;
152+
async fn count_with_options(&self, key: Bytes, seq_range: impl RangeBounds<u64>, options: CountOptions) -> Result<u64, Error>;
148153
}
149154
```
150155

151156
This mirrors the scan API but returns a count rather than entries. The `approximate` option allows counting from the index alone without reading boundary blocks.
152157

158+
For example, to compute the current lag for a key from a given sequence number:
159+
160+
```rust
161+
let current_seq: u64 = 1000;
162+
let lag = log.count(key, current_seq..).await?;
163+
```
164+
153165
## Alternatives
154166

155167
### KeyMapper Abstraction

0 commit comments

Comments
 (0)