MCPcopy Create free account
hub / github.com/apache/arrow-rs / encode

Method encode

arrow-ipc/src/writer.rs:470–498  ·  view source on GitHub ↗

Encodes a batch to a number of [EncodedData] items (dictionary batches + the record batch). The [DictionaryTracker] keeps track of dictionaries with new `dict_id`s (so they are only sent once) Make sure the [DictionaryTracker] is initialized at the start of the stream.

(
        &self,
        batch: &RecordBatch,
        dictionary_tracker: &mut DictionaryTracker,
        write_options: &IpcWriteOptions,
        compression_context: &mut CompressionContext,
    )

Source from the content-addressed store, hash-verified

468 /// The [DictionaryTracker] keeps track of dictionaries with new `dict_id`s (so they are only sent once)
469 /// Make sure the [DictionaryTracker] is initialized at the start of the stream.
470 pub fn encode(
471 &self,
472 batch: &RecordBatch,
473 dictionary_tracker: &mut DictionaryTracker,
474 write_options: &IpcWriteOptions,
475 compression_context: &mut CompressionContext,
476 ) -> Result<(Vec<EncodedData>, EncodedData), ArrowError> {
477 let schema = batch.schema();
478 let mut encoded_dictionaries = Vec::with_capacity(schema.flattened_fields().len());
479
480 let mut dict_id = dictionary_tracker.dict_ids.clone().into_iter();
481
482 for (i, field) in schema.fields().iter().enumerate() {
483 let column = batch.column(i);
484 self.encode_dictionaries(
485 field,
486 column,
487 &mut encoded_dictionaries,
488 dictionary_tracker,
489 write_options,
490 &mut dict_id,
491 compression_context,
492 )?;
493 }
494
495 let encoded_message =
496 self.record_batch_to_bytes(batch, write_options, compression_context)?;
497 Ok((encoded_dictionaries, encoded_message))
498 }
499
500 /// Encodes a batch to a number of [EncodedData] items (dictionary batches + the record batch).
501 /// The [DictionaryTracker] keeps track of dictionaries with new `dict_id`s (so they are only sent once)

Callers 14

batches_to_flight_dataFunction · 0.45
encode_batchMethod · 0.45
handshakeMethod · 0.45
do_getMethod · 0.45
send_batchFunction · 0.45
authenticateFunction · 0.45
encoded_batchMethod · 0.45
writeMethod · 0.45
track_union_nested_dictFunction · 0.45
track_struct_nested_dictFunction · 0.45

Calls 10

flattened_fieldsMethod · 0.80
encode_dictionariesMethod · 0.80
record_batch_to_bytesMethod · 0.80
schemaMethod · 0.45
lenMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45
fieldsMethod · 0.45
columnMethod · 0.45

Tested by 7

do_getMethod · 0.36
send_batchFunction · 0.36
track_union_nested_dictFunction · 0.36
track_struct_nested_dictFunction · 0.36
test_unalignedFunction · 0.36