@@ -485,6 +485,35 @@ impl<'a> ArrayReader<'a> {
485
485
}
486
486
}
487
487
488
+ pub fn read_record_batch (
489
+ buf : & Buffer ,
490
+ batch : crate :: RecordBatch ,
491
+ schema : SchemaRef ,
492
+ dictionaries_by_id : & HashMap < i64 , ArrayRef > ,
493
+ projection : Option < & [ usize ] > ,
494
+ metadata : & MetadataVersion ,
495
+ ) -> Result < RecordBatch , ArrowError > {
496
+ read_record_batch2 (
497
+ buf,
498
+ batch,
499
+ schema,
500
+ dictionaries_by_id,
501
+ projection,
502
+ metadata,
503
+ false ,
504
+ )
505
+ }
506
+
507
+ pub fn read_dictionary (
508
+ buf : & Buffer ,
509
+ batch : crate :: DictionaryBatch ,
510
+ schema : & Schema ,
511
+ dictionaries_by_id : & mut HashMap < i64 , ArrayRef > ,
512
+ metadata : & MetadataVersion ,
513
+ ) -> Result < ( ) , ArrowError > {
514
+ read_dictionary2 ( buf, batch, schema, dictionaries_by_id, metadata, false )
515
+ }
516
+
488
517
/// Creates a record batch from binary data using the `crate::RecordBatch` indexes and the `Schema`.
489
518
///
490
519
/// If `require_alignment` is true, this function will return an error if any array data in the
@@ -495,7 +524,7 @@ impl<'a> ArrayReader<'a> {
495
524
/// and copy over the data if any array data in the input `buf` is not properly aligned.
496
525
/// (Properly aligned array data will remain zero-copy.)
497
526
/// Under the hood it will use [`arrow_data::ArrayDataBuilder::build_aligned`] to construct [`arrow_data::ArrayData`].
498
- pub fn read_record_batch (
527
+ fn read_record_batch2 (
499
528
buf : & Buffer ,
500
529
batch : crate :: RecordBatch ,
501
530
schema : SchemaRef ,
@@ -564,7 +593,7 @@ pub fn read_record_batch(
564
593
565
594
/// Read the dictionary from the buffer and provided metadata,
566
595
/// updating the `dictionaries_by_id` with the resulting dictionary
567
- pub fn read_dictionary (
596
+ fn read_dictionary2 (
568
597
buf : & Buffer ,
569
598
batch : crate :: DictionaryBatch ,
570
599
schema : & Schema ,
@@ -593,7 +622,7 @@ pub fn read_dictionary(
593
622
let value = value_type. as_ref ( ) . clone ( ) ;
594
623
let schema = Schema :: new ( vec ! [ Field :: new( "" , value, true ) ] ) ;
595
624
// Read a single column
596
- let record_batch = read_record_batch (
625
+ let record_batch = read_record_batch2 (
597
626
buf,
598
627
batch. data ( ) . unwrap ( ) ,
599
628
Arc :: new ( schema) ,
@@ -781,7 +810,7 @@ impl FileDecoder {
781
810
match message. header_type ( ) {
782
811
crate :: MessageHeader :: DictionaryBatch => {
783
812
let batch = message. header_as_dictionary_batch ( ) . unwrap ( ) ;
784
- read_dictionary (
813
+ read_dictionary2 (
785
814
& buf. slice ( block. metaDataLength ( ) as _ ) ,
786
815
batch,
787
816
& self . schema ,
@@ -812,7 +841,7 @@ impl FileDecoder {
812
841
ArrowError :: IpcError ( "Unable to read IPC message as record batch" . to_string ( ) )
813
842
} ) ?;
814
843
// read the block that makes up the record batch into a buffer
815
- read_record_batch (
844
+ read_record_batch2 (
816
845
& buf. slice ( block. metaDataLength ( ) as _ ) ,
817
846
batch,
818
847
self . schema . clone ( ) ,
@@ -1255,7 +1284,7 @@ impl<R: Read> StreamReader<R> {
1255
1284
let mut buf = MutableBuffer :: from_len_zeroed ( message. bodyLength ( ) as usize ) ;
1256
1285
self . reader . read_exact ( & mut buf) ?;
1257
1286
1258
- read_record_batch (
1287
+ read_record_batch2 (
1259
1288
& buf. into ( ) ,
1260
1289
batch,
1261
1290
self . schema ( ) ,
@@ -1276,7 +1305,7 @@ impl<R: Read> StreamReader<R> {
1276
1305
let mut buf = MutableBuffer :: from_len_zeroed ( message. bodyLength ( ) as usize ) ;
1277
1306
self . reader . read_exact ( & mut buf) ?;
1278
1307
1279
- read_dictionary (
1308
+ read_dictionary2 (
1280
1309
& buf. into ( ) ,
1281
1310
batch,
1282
1311
& self . schema ,
@@ -2048,7 +2077,7 @@ mod tests {
2048
2077
assert_ne ! ( b. as_ptr( ) . align_offset( 8 ) , 0 ) ;
2049
2078
2050
2079
let ipc_batch = message. header_as_record_batch ( ) . unwrap ( ) ;
2051
- let roundtrip = read_record_batch (
2080
+ let roundtrip = read_record_batch2 (
2052
2081
& b,
2053
2082
ipc_batch,
2054
2083
batch. schema ( ) ,
@@ -2085,7 +2114,7 @@ mod tests {
2085
2114
assert_ne ! ( b. as_ptr( ) . align_offset( 8 ) , 0 ) ;
2086
2115
2087
2116
let ipc_batch = message. header_as_record_batch ( ) . unwrap ( ) ;
2088
- let result = read_record_batch (
2117
+ let result = read_record_batch2 (
2089
2118
& b,
2090
2119
ipc_batch,
2091
2120
batch. schema ( ) ,
0 commit comments