pub fn read_batch<R: Read + Seek>(
    reader: &mut R,
    metadata: &FileMetadata,
    projection: Option<&[usize]>,
    block: usize,
    block_data: &mut Vec<u8>,
) -> Result<Chunk<Arc<dyn Array>>> {
    let block = metadata.blocks[block];

    // read length
    reader.seek(SeekFrom::Start(block.offset as u64))?;
    let mut meta_buf = [0; 4];
    reader.read_exact(&mut meta_buf)?;
    if meta_buf == CONTINUATION_MARKER {
        // continuation marker encountered, read message next
        reader.read_exact(&mut meta_buf)?;
    }
    let meta_len = i32::from_le_bytes(meta_buf) as usize;

    block_data.clear();
    block_data.resize(meta_len, 0);
    reader.read_exact(block_data)?;

    let message = arrow_format::ipc::MessageRef::read_as_root(&block_data[..])
        .map_err(|err| ArrowError::oos(format!("Unable parse message: {:?}", err)))?;

    let batch = get_serialized_batch(&message)?;

    read_record_batch(
        batch,
        &metadata.schema.fields,
        &metadata.ipc_schema,
        projection,
        &metadata.dictionaries,
        message.version()?,
        reader,
        block.offset as u64 + block.meta_data_length as u64,
    )
}
/// Read a batch from the reader.
Read a batch from the reader.
Read a batch from the reader .
pub fn read_batch<R: Read + Seek>(
    reader: &mut R,
    metadata: &FileMetadata,
    projection: Option<&[usize]>,
    block: usize,
    block_data: &mut Vec<u8>,
) -> Result<Chunk<Arc<dyn Array>>> {
    let block = metadata.blocks[block];
    // read length
    reader.seek(SeekFrom::Start(block.offset as u64))?;
    let mut meta_buf = [0; 4];
    reader.read_exact(&mut meta_buf)?;
    if meta_buf == CONTINUATION_MARKER {
        // continuation marker encountered, read message next
        reader.read_exact(&mut meta_buf)?;
    }
    let meta_len = i32::from_le_bytes(meta_buf) as usize;
    block_data.clear();
    block_data.resize(meta_len, 0);
    reader.read_exact(block_data)?;
    let message = arrow_format::ipc::MessageRef::read_as_root(&block_data[..])
        .map_err(|err| ArrowError::oos(format!("Unable parse message: {:?}", err)))?;
    let batch = get_serialized_batch(&message)?;
    read_record_batch(
        batch,
        &metadata.schema.fields,
        &metadata.ipc_schema,
        projection,
        &metadata.dictionaries,
        message.version()?,
        reader,
        block.offset as u64 + block.meta_data_length as u64,
    )
}
pub fn read_batch < R : Read + Seek > ( reader : & mut R , metadata : & FileMetadata , projection : Option < & [ usize ] > , block : usize , block_data : & mut Vec < u8 > , ) -> Result < Chunk < Arc < dyn Array > > > { let block = metadata . blocks [ block ] ; // read length reader . seek ( SeekFrom :: Start ( block . offset as u64 ) ) ? ; let mut meta_buf = [ 0 ; 4 ] ; reader . read_exact ( & mut meta_buf ) ? ; if meta_buf == CONTINUATION_MARKER { // continuation marker encountered, read message next reader . read_exact ( & mut meta_buf ) ? ; } let meta_len = i32 :: from_le_bytes ( meta_buf ) as usize ; block_data . clear ( ) ; block_data . resize ( meta_len , 0 ) ; reader . read_exact ( block_data ) ? ; let message = arrow_format :: ipc :: MessageRef :: read_as_root ( & block_data [ .. ] ) . map_err ( | err | ArrowError :: oos ( format ! ( " " err ) ) ) ? ; let batch = get_serialized_batch ( & message ) ? ; read_record_batch ( batch , & metadata . schema . fields , & metadata . ipc_schema , projection , & metadata . dictionaries , message . version ( ) ? , reader , block . offset as u64 + block . meta_data_length as u64 , ) }
Read a batch from the reader.
Read a batch from the reader .
reader
&mut R
metadata
&FileMetadata
projection
Option<&[usize]>
block
usize
block_data
&mut Vec<u8>
reader
&mut R
metadata
&FileMetadata
projection
Option<&[usize]>
block
usize
block_data
&mut Vec<u8>