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

Function roundtrip_with_encoder

arrow-flight/tests/encode_decode.rs:440–461  ·  view source on GitHub ↗
(
    encoder: FlightDataEncoderBuilder,
    input_batches: Vec<RecordBatch>,
    expected_batches: Vec<RecordBatch>,
)

Source from the content-addressed store, hash-verified

438}
439
440async fn roundtrip_with_encoder(
441 encoder: FlightDataEncoderBuilder,
442 input_batches: Vec<RecordBatch>,
443 expected_batches: Vec<RecordBatch>,
444) {
445 println!("Round tripping with encoder:\n{encoder:#?}");
446
447 let input_batch_stream = futures::stream::iter(input_batches.clone()).map(Ok);
448
449 let encode_stream = encoder.build(input_batch_stream);
450
451 let decode_stream = FlightRecordBatchStream::new_from_flight_data(encode_stream);
452 let output_batches: Vec<_> = decode_stream.try_collect().await.expect("encode / decode");
453
454 // remove any empty batches from input as they are not transmitted
455 let expected_batches: Vec<_> = expected_batches
456 .into_iter()
457 .filter(|b| b.num_rows() > 0)
458 .collect();
459
460 assert_eq!(expected_batches, output_batches);
461}
462
463/// Workaround for https://github.com/apache/arrow-rs/issues/1206
464fn prepare_schema_for_flight(schema: &Schema) -> Schema {

Callers 2

roundtripFunction · 0.85
roundtrip_dictionaryFunction · 0.85

Calls 6

collectMethod · 0.80
filterMethod · 0.80
cloneMethod · 0.45
buildMethod · 0.45
into_iterMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected