@@ -74,6 +74,12 @@ pub trait ArrayBatchDecoder: Send {
7474 batch_size : usize ,
7575 parent_present : Option < & NullBuffer > ,
7676 ) -> Result < ArrayRef > ;
77+
78+ /// Skip the next `n` values without decoding them, failing if it cannot skip the enough values.
79+ fn skip_values ( & mut self , n : usize ) -> Result < ( ) > {
80+ // TODO: implement
81+ Ok ( ( ) )
82+ }
7783}
7884
7985struct PrimitiveArrayDecoder < T : ArrowPrimitiveType > {
@@ -122,6 +128,24 @@ impl<T: ArrowPrimitiveType> ArrayBatchDecoder for PrimitiveArrayDecoder<T> {
122128 let array = Arc :: new ( array) as ArrayRef ;
123129 Ok ( array)
124130 }
131+
132+ fn skip_rows ( & mut self , row_count : usize ) -> Result < ( ) > {
133+ // If we have a present stream, we need to decode it to know how many
134+ // non-null values to skip in the data stream
135+ let non_null_count = if let Some ( ref mut present) = self . present {
136+ let mut present_buffer = vec ! [ false ; row_count] ;
137+ present. inner . decode ( & mut present_buffer) ?;
138+ // Count non-null values (where present is true)
139+ present_buffer. iter ( ) . filter ( |& & v| v) . count ( )
140+ } else {
141+ // No nulls, so all rows have values
142+ row_count
143+ } ;
144+
145+ // Skip the data stream for non-null values only
146+ self . iter . skip ( non_null_count) ?;
147+ Ok ( ( ) )
148+ }
125149}
126150
127151type Int64ArrayDecoder = PrimitiveArrayDecoder < Int64Type > ;
@@ -167,6 +191,24 @@ impl ArrayBatchDecoder for BooleanArrayDecoder {
167191 } ;
168192 Ok ( Arc :: new ( array) )
169193 }
194+
195+ fn skip_rows ( & mut self , row_count : usize ) -> Result < ( ) > {
196+ // If we have a present stream, we need to decode it to know how many
197+ // non-null values to skip in the data stream
198+ let non_null_count = if let Some ( ref mut present) = self . present {
199+ let mut present_buffer = vec ! [ false ; row_count] ;
200+ present. inner . decode ( & mut present_buffer) ?;
201+ // Count non-null values (where present is true)
202+ present_buffer. iter ( ) . filter ( |& & v| v) . count ( )
203+ } else {
204+ // No nulls, so all rows have values
205+ row_count
206+ } ;
207+
208+ // Skip the data stream for non-null values only
209+ self . iter . skip ( non_null_count) ?;
210+ Ok ( ( ) )
211+ }
170212}
171213
172214struct PresentDecoder {
@@ -514,14 +556,11 @@ impl NaiveStripeDecoder {
514556 } )
515557 }
516558
517- /// Skip the specified number of rows by decoding and discarding them
559+ /// Skip the specified number of rows by calling skip_rows on each decoder
518560 fn skip_rows ( & mut self , count : usize ) -> Result < ( ) > {
519- // Decode in batches to avoid large memory allocations
520- let mut remaining = count;
521- while remaining > 0 {
522- let chunk = self . batch_size . min ( remaining) ;
523- let _ = self . inner_decode_next_batch ( chunk) ?;
524- remaining -= chunk;
561+ // Call skip_rows on each decoder to efficiently skip rows
562+ for decoder in & mut self . decoders {
563+ decoder. skip_rows ( count) ?;
525564 }
526565 Ok ( ( ) )
527566 }
0 commit comments