aetherlight: indexed counts the open-log walk, not only the entries it returns

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-20 07:11:33 +01:00
commit 08d0c26fd8

View file

@ -266,6 +266,9 @@ impl<K: Ord + Clone, V: Clone + PartialEq, P: Projection<V>> Docs<K, V, P> {
.map(|(point, key)| (point.clone(), key.clone()))
.collect();
if !self.touched.is_empty() {
// Every logged key is walked whatever the range, so each is a row read.
#[cfg(test)]
count_rows(self.touched.len() as u64);
let mut points = Vec::new();
for key in self.touched.keys() {
if let Some(value) = self.map.get(key) {
@ -540,6 +543,16 @@ mod tests {
assert_eq!(rows_read() - before, 2);
}
#[test]
fn walking_the_open_log_is_counted_even_when_nothing_matches() {
let mut docs = spread(&[(1, 10), (2, 21), (3, 33)]);
docs.insert(1, 11);
docs.insert(9, 99);
let before = rows_read();
assert!(docs.indexed(5..=5).is_empty());
assert_eq!(rows_read() - before, 2, "two logged keys were walked");
}
#[test]
fn a_damaged_index_is_seen_as_not_derived() {
for stray in [true, false] {