From 42efc7f7c84c0c1a3f8b8dee1ff88745bc924ceb Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Fri, 20 Dec 2024 11:00:11 +0100 Subject: [PATCH] clippy --- sstable/src/block_reader.rs | 2 +- sstable/src/sstable_index_v3.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sstable/src/block_reader.rs b/sstable/src/block_reader.rs index 4fac90412..3299c3b4c 100644 --- a/sstable/src/block_reader.rs +++ b/sstable/src/block_reader.rs @@ -23,7 +23,7 @@ impl BlockReader { pub fn from_multiple_blocks(readers: Vec) -> BlockReader { let mut next_readers = readers.into_iter(); - let reader = next_readers.next().unwrap_or_else(|| OwnedBytes::empty()); + let reader = next_readers.next().unwrap_or_else(OwnedBytes::empty); BlockReader { buffer: Vec::new(), reader, diff --git a/sstable/src/sstable_index_v3.rs b/sstable/src/sstable_index_v3.rs index 4308743bc..1c99c36e5 100644 --- a/sstable/src/sstable_index_v3.rs +++ b/sstable/src/sstable_index_v3.rs @@ -176,15 +176,21 @@ impl SSTableIndexV3 { } } +// TODO we iterate over the entire Map to find matching blocks, +// we could manually iterate on the underlying Fst and skip whole branches if our Automaton says +// cannot match. this isn't as bad as it sounds given the fst is a lot smaller than the rest of the +// sstable. +// To do that, we can't use tantivy_fst's Stream with an automaton, as we need to know 2 consecutive +// fst keys to form a proper opinion on whether this is a match, which we wan't translate into a +// single automaton struct GetBlockForAutomaton<'a, A: Automaton> { streamer: tantivy_fst::map::Stream<'a>, - // TODO we could be more efficient by streaming the store block_addr_store: &'a BlockAddrStore, prev_key: Option>, automaton: &'a A, } -impl<'a, A: Automaton> Iterator for GetBlockForAutomaton<'a, A> { +impl Iterator for GetBlockForAutomaton<'_, A> { type Item = (u64, BlockAddr); fn next(&mut self) -> Option { @@ -195,8 +201,6 @@ impl<'a, A: Automaton> Iterator for GetBlockForAutomaton<'a, A> { prev_key.extend_from_slice(new_key); return Some((block_id, self.block_addr_store.get(block_id).unwrap())); } - // actually we could not write here, and it would still be correct, but it might - // lead to checking more keys than necessary which in itself can be a slowdown. prev_key.clear(); prev_key.extend_from_slice(new_key); } else {