Flush the current data block to output.
(&mut self)
| 100 | |
| 101 | /// Flush the current data block to output. |
| 102 | pub async fn flush(&mut self) -> io::Result<()> { |
| 103 | if self.data_block_writer.entry_count() == 0 { |
| 104 | return Ok(()); |
| 105 | } |
| 106 | |
| 107 | let block_handle = self.write_block_data().await?; |
| 108 | let (handle_buf, handle_len) = block_handle.encode_to_buf(); |
| 109 | if let Some(ref last_key) = self.last_key { |
| 110 | self.index_block_writer |
| 111 | .add(last_key, &handle_buf[..handle_len]); |
| 112 | } |
| 113 | Ok(()) |
| 114 | } |
| 115 | |
| 116 | /// Write a data block: compress, compute CRC, write block + trailer. |
| 117 | async fn write_block_data(&mut self) -> io::Result<BlockHandle> { |