Skip to content

Commit

Permalink
Update src/store/writer.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Masurel <paul@quickwit.io>
  • Loading branch information
PSeitz and fulmicoton committed Jun 23, 2022
1 parent ad76d11 commit 9baefbe
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/store/writer.rs
Expand Up @@ -101,17 +101,20 @@ impl StoreWriter {

/// Flushes current uncompressed block and sends to compressor.
fn send_current_block_to_compressor(&mut self) -> io::Result<()> {
// We don't do anything if the current block is empty to begin with.
if self.current_block.is_empty() {
return Ok(());
}
let block = DocumentBlock {
data: self.current_block.to_owned(),
num_docs_in_block: self.num_docs_in_current_block,
};
self.current_block.clear();
self.num_docs_in_current_block = 0;
if !block.is_empty() {
self.compressor_sender
.send(BlockCompressorMessage::AddBlock(block))
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
}
self.compressor_sender
.send(BlockCompressorMessage::AddBlock(block))
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;

Ok(())
}

Expand Down Expand Up @@ -191,12 +194,6 @@ struct DocumentBlock {
num_docs_in_block: DocId,
}

impl DocumentBlock {
fn is_empty(&self) -> bool {
self.data.is_empty()
}
}

impl BlockCompressor {
fn new(compressor: Compressor, writer: WritePtr) -> Self {
Self {
Expand Down

0 comments on commit 9baefbe

Please sign in to comment.