File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ fn bench_decode_schema(
3434 data : & [ u8 ] ,
3535 schema : Arc < Schema > ,
3636 rows : usize ,
37+ projection : bool ,
3738) {
3839 let mut group = c. benchmark_group ( name) ;
3940 group. throughput ( Throughput :: Bytes ( data. len ( ) as u64 ) ) ;
@@ -45,6 +46,7 @@ fn bench_decode_schema(
4546 b. iter ( || {
4647 let mut decoder = ReaderBuilder :: new ( schema. clone ( ) )
4748 . with_batch_size ( rows)
49+ . with_projection ( projection)
4850 . build_decoder ( )
4951 . unwrap ( ) ;
5052
@@ -101,6 +103,7 @@ fn criterion_benchmark(c: &mut Criterion) {
101103 & wide_projection_data,
102104 full_schema,
103105 WIDE_PROJECTION_ROWS ,
106+ false ,
104107 ) ;
105108
106109 // Projected schema: only 3 fields (f0, f10, f50) out of 100
@@ -115,6 +118,7 @@ fn criterion_benchmark(c: &mut Criterion) {
115118 & wide_projection_data,
116119 projected_schema,
117120 WIDE_PROJECTION_ROWS ,
121+ true ,
118122 ) ;
119123}
120124
Original file line number Diff line number Diff line change @@ -518,20 +518,24 @@ impl TapeDecoder {
518518 ) )
519519 } ) ?;
520520
521- if !projection. contains ( field_name) {
522- if self . strict_mode {
521+ match ( projection. contains ( field_name) , self . strict_mode ) {
522+ ( true , _) => { }
523+ ( false , true ) => {
523524 return Err ( ArrowError :: JsonError ( format ! (
524525 "column '{field_name}' missing from schema"
525526 ) ) ) ;
526527 }
527- // Field not in projection: skip its value
528- // Remove field name from tape (must have paired field_name:value)
529- self . elements . pop ( ) ;
530- self . bytes . truncate ( start) ;
531- self . offsets . pop ( ) ;
532-
533- // Replace Value state with SkipValue
534- * self . stack . last_mut ( ) . unwrap ( ) = DecoderState :: SkipValue ( 0 ) ;
528+ ( false , false ) => {
529+ // Field not in projection: skip its value
530+ // Remove field name from tape (must have paired field_name:value)
531+ self . elements . pop ( ) ;
532+ self . bytes . truncate ( start) ;
533+ self . offsets . pop ( ) ;
534+
535+ // Replace Value state with SkipValue
536+ * self . stack . last_mut ( ) . unwrap ( ) =
537+ DecoderState :: SkipValue ( 0 ) ;
538+ }
535539 }
536540 }
537541 }
You can’t perform that action at this time.
0 commit comments