fn cut_row_v2(data: Vec<u8>, cols: Arc<[ColumnInfo]>) -> Result<RowColsDict> {
    use crate::codec::datum_codec::{ColumnIdDatumEncoder, EvaluableDatumEncoder};
    use crate::codec::row::v2::{RowSlice, V1CompatibleEncoder};

    let mut meta_map = HashMap::with_capacity_and_hasher(cols.len(), Default::default());
    let mut result = Vec::with_capacity(data.len() + cols.len() * 8);

    let row_slice = RowSlice::from_bytes(&data)?;
    for col in cols.iter() {
        let id = col.get_column_id();
        if let Some((start, offset)) = row_slice.search_in_non_null_ids(id)? {
            result.write_column_id_datum(id)?;
            let v2_datum = &row_slice.values()[start..offset];
            let result_offset = result.len();
            result.write_v2_as_datum(v2_datum, col)?;
            meta_map.insert(
                id,
                RowColMeta::new(result_offset, result.len() - result_offset),
            );
        } else if row_slice.search_in_null_ids(id) {
            result.write_column_id_datum(id)?;
            let result_offset = result.len();
            result.write_evaluable_datum_null()?;
            meta_map.insert(
                id,
                RowColMeta::new(result_offset, result.len() - result_offset),
            );
        } else {
            // Otherwise the column does not exist.
        }
    }
    Ok(RowColsDict::new(meta_map, result))
}
/// Cuts a non-empty row in row format v2 and encodes into v1 format.
Cuts a non-empty row in row format v2 and encodes into v1 format.
Cuts a non - empty row in row format v2 and encodes into v1 format .
fn cut_row_v2(data: Vec<u8>, cols: Arc<[ColumnInfo]>) -> Result<RowColsDict> {
    use crate::codec::datum_codec::{ColumnIdDatumEncoder, EvaluableDatumEncoder};
    use crate::codec::row::v2::{RowSlice, V1CompatibleEncoder};
    let mut meta_map = HashMap::with_capacity_and_hasher(cols.len(), Default::default());
    let mut result = Vec::with_capacity(data.len() + cols.len() * 8);
    let row_slice = RowSlice::from_bytes(&data)?;
    for col in cols.iter() {
        let id = col.get_column_id();
        if let Some((start, offset)) = row_slice.search_in_non_null_ids(id)? {
            result.write_column_id_datum(id)?;
            let v2_datum = &row_slice.values()[start..offset];
            let result_offset = result.len();
            result.write_v2_as_datum(v2_datum, col)?;
            meta_map.insert(
                id,
                RowColMeta::new(result_offset, result.len() - result_offset),
            );
        } else if row_slice.search_in_null_ids(id) {
            result.write_column_id_datum(id)?;
            let result_offset = result.len();
            result.write_evaluable_datum_null()?;
            meta_map.insert(
                id,
                RowColMeta::new(result_offset, result.len() - result_offset),
            );
        } else {
            // Otherwise the column does not exist.
        }
    }
    Ok(RowColsDict::new(meta_map, result))
}
fn cut_row_v2 ( data : Vec < u8 > , cols : Arc < [ ColumnInfo ] > ) -> Result < RowColsDict > { use crate :: codec :: datum_codec :: { ColumnIdDatumEncoder , EvaluableDatumEncoder } ; use crate :: codec :: row :: v2 :: { RowSlice , V1CompatibleEncoder } ; let mut meta_map = HashMap :: with_capacity_and_hasher ( cols . len ( ) , Default :: default ( ) ) ; let mut result = Vec :: with_capacity ( data . len ( ) + cols . len ( ) * 8 ) ; let row_slice = RowSlice :: from_bytes ( & data ) ? ; for col in cols . iter ( ) { let id = col . get_column_id ( ) ; if let Some ( ( start , offset ) ) = row_slice . search_in_non_null_ids ( id ) ? { result . write_column_id_datum ( id ) ? ; let v2_datum = & row_slice . values ( ) [ start .. offset ] ; let result_offset = result . len ( ) ; result . write_v2_as_datum ( v2_datum , col ) ? ; meta_map . insert ( id , RowColMeta :: new ( result_offset , result . len ( ) - result_offset ) , ) ; } else if row_slice . search_in_null_ids ( id ) { result . write_column_id_datum ( id ) ? ; let result_offset = result . len ( ) ; result . write_evaluable_datum_null ( ) ? ; meta_map . insert ( id , RowColMeta :: new ( result_offset , result . len ( ) - result_offset ) , ) ; } else { // Otherwise the column does not exist. } } Ok ( RowColsDict :: new ( meta_map , result ) ) }
Cuts a non-empty row in row format v2 and encodes into v1 format.
Cuts a non - empty row in row format v2 and encodes into v1 format .
data
Vec<u8>
cols
Arc<[ColumnInfo]>