pub fn read_dictionary<R: Read + Seek>(
    batch: arrow_format::ipc::DictionaryBatchRef,
    fields: &[Field],
    ipc_schema: &IpcSchema,
    dictionaries: &mut Dictionaries,
    reader: &mut R,
    block_offset: u64,
) -> Result<()> {
    if batch.is_delta()? {
        return Err(ArrowError::NotYetImplemented(
            "delta dictionary batches not supported".to_string(),
        ));
    }

    let id = batch.id()?;
    let (first_field, first_ipc_field) = first_dict_field(id, fields, &ipc_schema.fields)?;

    // As the dictionary batch does not contain the type of the
    // values array, we need to retrieve this from the schema.
    // Get an array representing this dictionary's values.
    let dictionary_values: ArrayRef = match &first_field.data_type {
        DataType::Dictionary(_, ref value_type, _) => {
            // Make a fake schema for the dictionary batch.
            let fields = vec![Field::new("", value_type.as_ref().clone(), false)];
            let ipc_schema = IpcSchema {
                fields: vec![first_ipc_field.clone()],
                is_little_endian: ipc_schema.is_little_endian,
            };
            let columns = read_record_batch(
                batch
                    .data()?
                    .ok_or_else(|| ArrowError::oos("The dictionary batch must have data."))?,
                &fields,
                &ipc_schema,
                None,
                dictionaries,
                arrow_format::ipc::MetadataVersion::V5,
                reader,
                block_offset,
            )?;
            let mut arrays = columns.into_arrays();
            Some(arrays.pop().unwrap())
        }
        _ => None,
    }
    .ok_or_else(|| {
        ArrowError::InvalidArgumentError("dictionary id not found in schema".to_string())
    })?;

    dictionaries.insert(id, dictionary_values);

    Ok(())
}
/// Read the dictionary from the buffer and provided metadata,
/// updating the `dictionaries` with the resulting dictionary
Read the dictionary from the buffer and provided metadata,
updating the `dictionaries` with the resulting dictionary
Read the dictionary from the buffer and provided metadata updating the ` dictionaries ` with the resulting dictionary
pub fn read_dictionary<R: Read + Seek>(
    batch: arrow_format::ipc::DictionaryBatchRef,
    fields: &[Field],
    ipc_schema: &IpcSchema,
    dictionaries: &mut Dictionaries,
    reader: &mut R,
    block_offset: u64,
) -> Result<()> {
    if batch.is_delta()? {
        return Err(ArrowError::NotYetImplemented(
            "delta dictionary batches not supported".to_string(),
        ));
    }
    let id = batch.id()?;
    let (first_field, first_ipc_field) = first_dict_field(id, fields, &ipc_schema.fields)?;
    // As the dictionary batch does not contain the type of the
    // values array, we need to retrieve this from the schema.
    // Get an array representing this dictionary's values.
    let dictionary_values: ArrayRef = match &first_field.data_type {
        DataType::Dictionary(_, ref value_type, _) => {
            // Make a fake schema for the dictionary batch.
            let fields = vec![Field::new("", value_type.as_ref().clone(), false)];
            let ipc_schema = IpcSchema {
                fields: vec![first_ipc_field.clone()],
                is_little_endian: ipc_schema.is_little_endian,
            };
            let columns = read_record_batch(
                batch
                    .data()?
                    .ok_or_else(|| ArrowError::oos("The dictionary batch must have data."))?,
                &fields,
                &ipc_schema,
                None,
                dictionaries,
                arrow_format::ipc::MetadataVersion::V5,
                reader,
                block_offset,
            )?;
            let mut arrays = columns.into_arrays();
            Some(arrays.pop().unwrap())
        }
        _ => None,
    }
    .ok_or_else(|| {
        ArrowError::InvalidArgumentError("dictionary id not found in schema".to_string())
    })?;
    dictionaries.insert(id, dictionary_values);
    Ok(())
}
pub fn read_dictionary < R : Read + Seek > ( batch : arrow_format :: ipc :: DictionaryBatchRef , fields : & [ Field ] , ipc_schema : & IpcSchema , dictionaries : & mut Dictionaries , reader : & mut R , block_offset : u64 , ) -> Result < ( ) > { if batch . is_delta ( ) ? { return Err ( ArrowError :: NotYetImplemented ( " " . to_string ( ) , ) ) ; } let id = batch . id ( ) ? ; let ( first_field , first_ipc_field ) = first_dict_field ( id , fields , & ipc_schema . fields ) ? ; // As the dictionary batch does not contain the type of the // values array, we need to retrieve this from the schema. // Get an array representing this dictionary's values. let dictionary_values : ArrayRef = match & first_field . data_type { DataType :: Dictionary ( _ , ref value_type , _ ) => { // Make a fake schema for the dictionary batch. let fields = vec ! [ Field new ( " " value_type as_ref ( ) clone ( ) false ) ] ; let ipc_schema = IpcSchema { fields : vec ! [ first_ipc_field clone ( ) ] , is_little_endian : ipc_schema . is_little_endian , } ; let columns = read_record_batch ( batch . data ( ) ? . ok_or_else ( | | ArrowError :: oos ( " " ) ) ? , & fields , & ipc_schema , None , dictionaries , arrow_format :: ipc :: MetadataVersion :: V5 , reader , block_offset , ) ? ; let mut arrays = columns . into_arrays ( ) ; Some ( arrays . pop ( ) . unwrap ( ) ) } _ => None , } . ok_or_else ( | | { ArrowError :: InvalidArgumentError ( " " . to_string ( ) ) } ) ? ; dictionaries . insert ( id , dictionary_values ) ; Ok ( ( ) ) }
Read the dictionary from the buffer and provided metadata,
updating the `dictionaries` with the resulting dictionary
Read the dictionary from the buffer and provided metadata updating the ` dictionaries ` with the resulting dictionary
batch
arrow_format::ipc::DictionaryBatchRef
fields
&[Field]
ipc_schema
&IpcSchema
dictionaries
&mut Dictionaries
reader
&mut R
block_offset
u64
batch
arrow_format::ipc::DictionaryBatchRef
fields
&[Field]
ipc_schema
&IpcSchema
dictionaries
&mut Dictionaries
reader
&mut R
block_offset
u64