fn refill_block_buffer(
    decoder: &mut impl BlockDecoder,
    field_blocks: &mut FieldKeyBlocks,
    dst: &mut BTreeMap<String, BlockData>,
) -> Result<(), TsmError> {
    // Determine for each input block if the destination container needs
    // refilling.
    for (field, blocks) in field_blocks.iter_mut() {
        if blocks.is_empty() {
            continue; // drained all blocks for this field
        }

        // in this case the destination buffer does not need refilling yet
        if let Some(dst_block) = dst.get(field) {
            if !dst_block.is_empty() {
                continue; // not ready to be replaced with next block yet
            }
        };

        // Either there is no block data in the destination buffer for field,
        // or the block data that is there has been completely consumed. Refill
        // the buffer by getting the next block(s), decoding them and making
        // the block data available for consumption.

        // It is possible for fields to have multiple overlapping blocks, e.g.,
        // if the data has been built up from multiple data sources (TSM files).
        //
        // Determine how many overlapping blocks need to be decoded and merged
        // together
        let mut i = 0; // track which blocks are overlapping in the vector
        while i < blocks.len() - 1 {
            if !blocks[i].overlaps(&blocks[i + 1]) {
                break;
            }
            i += 1;
        }

        // materialise all the blocks to be merged. Note, a single block is valid
        // here - the merge will simply return the block data.
        let decoded_blocks = blocks
            .drain(..i + 1)
            .map(|b| decoder.decode(&b))
            .collect::<Result<Vec<_>, _>>()?;

        dst.insert(field.clone(), BlockData::merge(decoded_blocks));
    }
    Ok(())
}
// Ensures that the next available block for a field is materialised in the
// destination container.
Ensures that the next available block for a field is materialised in the
destination container.
Ensures that the next available block for a field is materialised in the destination container .
fn refill_block_buffer(
    decoder: &mut impl BlockDecoder,
    field_blocks: &mut FieldKeyBlocks,
    dst: &mut BTreeMap<String, BlockData>,
) -> Result<(), TsmError> {
    // Determine for each input block if the destination container needs
    // refilling.
    for (field, blocks) in field_blocks.iter_mut() {
        if blocks.is_empty() {
            continue; // drained all blocks for this field
        }
        // in this case the destination buffer does not need refilling yet
        if let Some(dst_block) = dst.get(field) {
            if !dst_block.is_empty() {
                continue; // not ready to be replaced with next block yet
            }
        };
        // Either there is no block data in the destination buffer for field,
        // or the block data that is there has been completely consumed. Refill
        // the buffer by getting the next block(s), decoding them and making
        // the block data available for consumption.
        // It is possible for fields to have multiple overlapping blocks, e.g.,
        // if the data has been built up from multiple data sources (TSM files).
        //
        // Determine how many overlapping blocks need to be decoded and merged
        // together
        let mut i = 0; // track which blocks are overlapping in the vector
        while i < blocks.len() - 1 {
            if !blocks[i].overlaps(&blocks[i + 1]) {
                break;
            }
            i += 1;
        }
        // materialise all the blocks to be merged. Note, a single block is valid
        // here - the merge will simply return the block data.
        let decoded_blocks = blocks
            .drain(..i + 1)
            .map(|b| decoder.decode(&b))
            .collect::<Result<Vec<_>, _>>()?;
        dst.insert(field.clone(), BlockData::merge(decoded_blocks));
    }
    Ok(())
}
fn refill_block_buffer ( decoder : & mut impl BlockDecoder , field_blocks : & mut FieldKeyBlocks , dst : & mut BTreeMap < String , BlockData > , ) -> Result < ( ) , TsmError > { // Determine for each input block if the destination container needs // refilling. for ( field , blocks ) in field_blocks . iter_mut ( ) { if blocks . is_empty ( ) { continue ; // drained all blocks for this field } // in this case the destination buffer does not need refilling yet if let Some ( dst_block ) = dst . get ( field ) { if ! dst_block . is_empty ( ) { continue ; // not ready to be replaced with next block yet } } ; // Either there is no block data in the destination buffer for field, // or the block data that is there has been completely consumed. Refill // the buffer by getting the next block(s), decoding them and making // the block data available for consumption. // It is possible for fields to have multiple overlapping blocks, e.g., // if the data has been built up from multiple data sources (TSM files). // // Determine how many overlapping blocks need to be decoded and merged // together let mut i = 0 ; // track which blocks are overlapping in the vector while i < blocks . len ( ) - 1 { if ! blocks [ i ] . overlaps ( & blocks [ i + 1 ] ) { break ; } i += 1 ; } // materialise all the blocks to be merged. Note, a single block is valid // here - the merge will simply return the block data. let decoded_blocks = blocks . drain ( .. i + 1 ) . map ( | b | decoder . decode ( & b ) ) . collect :: < Result < Vec < _ > , _ > > ( ) ? ; dst . insert ( field . clone ( ) , BlockData :: merge ( decoded_blocks ) ) ; } Ok ( ( ) ) }
Ensures that the next available block for a field is materialised in the
destination container.
Ensures that the next available block for a field is materialised in the destination container .
decoder
&mut impl BlockDecoder
field_blocks
&mut FieldKeyBlocks
dst
&mut BTreeMap<String, BlockData>
decoder
&mut impl BlockDecoder
field_blocks
&mut FieldKeyBlocks
dst
&mut BTreeMap<String, BlockData>