ensure only the batch's used data (not the allocated data) is sent
()
| 804 | /// ensure only the batch's used data (not the allocated data) is sent |
| 805 | /// <https://github.com/apache/arrow-rs/issues/208> |
| 806 | fn test_encode_flight_data() { |
| 807 | // use 8-byte alignment - default alignment is 64 which produces bigger ipc data |
| 808 | let options = IpcWriteOptions::try_new(8, false, MetadataVersion::V5).unwrap(); |
| 809 | let c1 = UInt32Array::from(vec![1, 2, 3, 4, 5, 6]); |
| 810 | |
| 811 | let batch = RecordBatch::try_from_iter(vec![("a", Arc::new(c1) as ArrayRef)]) |
| 812 | .expect("cannot create record batch"); |
| 813 | let schema = batch.schema_ref(); |
| 814 | |
| 815 | let (_, baseline_flight_batch) = make_flight_data(&batch, &options); |
| 816 | |
| 817 | let big_batch = batch.slice(0, batch.num_rows() - 1); |
| 818 | let optimized_big_batch = |
| 819 | hydrate_dictionaries(&big_batch, Arc::clone(schema)).expect("failed to optimize"); |
| 820 | let (_, optimized_big_flight_batch) = make_flight_data(&optimized_big_batch, &options); |
| 821 | |
| 822 | assert_eq!( |
| 823 | baseline_flight_batch.data_body.len(), |
| 824 | optimized_big_flight_batch.data_body.len() |
| 825 | ); |
| 826 | |
| 827 | let small_batch = batch.slice(0, 1); |
| 828 | let optimized_small_batch = |
| 829 | hydrate_dictionaries(&small_batch, Arc::clone(schema)).expect("failed to optimize"); |
| 830 | let (_, optimized_small_flight_batch) = make_flight_data(&optimized_small_batch, &options); |
| 831 | |
| 832 | assert!( |
| 833 | baseline_flight_batch.data_body.len() > optimized_small_flight_batch.data_body.len() |
| 834 | ); |
| 835 | } |
| 836 | |
| 837 | #[tokio::test] |
| 838 | async fn test_dictionary_hydration() { |
nothing calls this directly
no test coverage detected