Skip to content

Commit 6832088

Browse files
committed
fix: partitioned filter if no items were written
1 parent bc542fb commit 6832088

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/table/writer/filter/full.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<W: std::io::Write + std::io::Seek> FilterWriter<W> for FullFilterWriter {
5050
file_writer: &mut sfa::Writer<ChecksummedWriter<BufWriter<File>>>,
5151
) -> crate::Result<usize> {
5252
if self.bloom_hash_buffer.is_empty() {
53-
log::trace!("Filter write has no buffered hashes - not building filter");
53+
log::trace!("Filter writer has no buffered hashes - not building filter");
5454
} else {
5555
file_writer.start("filter")?;
5656

src/table/writer/filter/partitioned.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,24 @@ impl<W: std::io::Write + std::io::Seek> FilterWriter<W> for PartitionedFilterWri
170170
mut self: Box<Self>,
171171
file_writer: &mut sfa::Writer<ChecksummedWriter<BufWriter<File>>>,
172172
) -> crate::Result<usize> {
173-
if !self.bloom_hash_buffer.is_empty() {
173+
if self.bloom_hash_buffer.is_empty() {
174+
log::trace!("Filter writer has no buffered hashes - not building filter");
175+
Ok(0)
176+
} else {
174177
let last_key = self.last_key.take().expect("last key should exist");
175178
self.spill_filter_partition(&last_key)?;
176-
}
177179

178-
let index_base_offset = BlockOffset(file_writer.get_mut().stream_position()?);
180+
let index_base_offset = BlockOffset(file_writer.get_mut().stream_position()?);
179181

180-
file_writer.start("filter")?;
181-
file_writer.write_all(&self.final_filter_buffer)?;
182-
log::trace!("Concatted filter partitions onto blocks file");
182+
file_writer.start("filter")?;
183+
file_writer.write_all(&self.final_filter_buffer)?;
184+
log::trace!("Concatted filter partitions onto blocks file");
183185

184-
let block_count = self.tli_handles.len();
186+
let block_count = self.tli_handles.len();
185187

186-
self.write_top_level_index(file_writer, index_base_offset)?;
188+
self.write_top_level_index(file_writer, index_base_offset)?;
187189

188-
Ok(block_count)
190+
Ok(block_count)
191+
}
189192
}
190193
}

src/table/writer/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,11 @@ impl Writer {
359359
}
360360

361361
// Write index
362+
log::trace!("Finishing index writer");
362363
let index_block_count = self.index_writer.finish(&mut self.file_writer)?;
363364

364365
// Write filter
366+
log::trace!("Finishing filter writer");
365367
let filter_block_count = self.filter_writer.finish(&mut self.file_writer)?;
366368

367369
if !self.linked_blob_files.is_empty() {

0 commit comments

Comments
 (0)