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

Function read_ipc_with_decoder_inner

arrow-ipc/src/reader.rs:2437–2468  ·  view source on GitHub ↗
(
        buf: Vec<u8>,
        skip_validation: bool,
    )

Source from the content-addressed store, hash-verified

2435 }
2436
2437 fn read_ipc_with_decoder_inner(
2438 buf: Vec<u8>,
2439 skip_validation: bool,
2440 ) -> Result<RecordBatch, ArrowError> {
2441 let buffer = Buffer::from_vec(buf);
2442 let trailer_start = buffer.len() - 10;
2443 let footer_len = read_footer_length(buffer[trailer_start..].try_into().unwrap())?;
2444 let footer = root_as_footer(&buffer[trailer_start - footer_len..trailer_start])
2445 .map_err(|e| ArrowError::InvalidArgumentError(format!("Invalid footer: {e}")))?;
2446
2447 let schema = fb_to_schema(footer.schema().unwrap());
2448
2449 let mut decoder = unsafe {
2450 FileDecoder::new(Arc::new(schema), footer.version())
2451 .with_skip_validation(skip_validation)
2452 };
2453 // Read dictionaries
2454 for block in footer.dictionaries().iter().flatten() {
2455 let block_len = block.bodyLength() as usize + block.metaDataLength() as usize;
2456 let data = buffer.slice_with_length(block.offset() as _, block_len);
2457 decoder.read_dictionary(block, &data)?
2458 }
2459
2460 // Read record batch
2461 let batches = footer.recordBatches().unwrap();
2462 assert_eq!(batches.len(), 1); // Only wrote a single batch
2463
2464 let block = batches.get(0);
2465 let block_len = block.bodyLength() as usize + block.metaDataLength() as usize;
2466 let data = buffer.slice_with_length(block.offset() as _, block_len);
2467 Ok(decoder.read_record_batch(block, &data)?.unwrap())
2468 }
2469
2470 /// Write the record batch to an in-memory buffer in IPC Stream format
2471 fn write_stream(rb: &RecordBatch) -> Vec<u8> {

Callers 2

read_ipc_with_decoderFunction · 0.85

Calls 15

read_footer_lengthFunction · 0.85
root_as_footerFunction · 0.85
fb_to_schemaFunction · 0.85
flattenMethod · 0.80
dictionariesMethod · 0.80
metaDataLengthMethod · 0.80
slice_with_lengthMethod · 0.80
read_dictionaryMethod · 0.80
recordBatchesMethod · 0.80
read_record_batchMethod · 0.80
lenMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected