@@ -45,11 +45,9 @@ use parquet::file::properties::WriterProperties;
4545use parquet:: format:: FileMetaData ;
4646use parquet:: schema:: types:: SchemaDescriptor ;
4747use snafu:: { OptionExt , ResultExt } ;
48- use store_api:: storage:: ChunkReader ;
4948use table:: predicate:: Predicate ;
5049use tokio:: io:: BufReader ;
5150
52- use crate :: chunk:: ChunkReaderImpl ;
5351use crate :: error:: {
5452 self , DecodeParquetTimeRangeSnafu , NewRecordBatchSnafu , ReadObjectSnafu , ReadParquetSnafu ,
5553 Result , WriteObjectSnafu , WriteParquetSnafu ,
@@ -320,7 +318,6 @@ impl<'a> ParquetReader<'a> {
320318 // checks if converting time range unit into ts col unit will result into rounding error.
321319 if time_unit_lossy ( & self . time_range , ts_col_unit) {
322320 let filter = RowFilter :: new ( vec ! [ Box :: new( PlainTimestampRowFilter :: new(
323- ts_col_idx,
324321 self . time_range,
325322 projection,
326323 ) ) ] ) ;
@@ -342,15 +339,9 @@ impl<'a> ParquetReader<'a> {
342339 . and_then ( |s| s. convert_to ( ts_col_unit) )
343340 . map ( |t| t. value ( ) ) ,
344341 ) {
345- Box :: new ( FastTimestampRowFilter :: new (
346- ts_col_idx, projection, lower, upper,
347- ) ) as _
342+ Box :: new ( FastTimestampRowFilter :: new ( projection, lower, upper) ) as _
348343 } else {
349- Box :: new ( PlainTimestampRowFilter :: new (
350- ts_col_idx,
351- self . time_range ,
352- projection,
353- ) ) as _
344+ Box :: new ( PlainTimestampRowFilter :: new ( self . time_range , projection) ) as _
354345 } ;
355346 let filter = RowFilter :: new ( vec ! [ row_filter] ) ;
356347 Some ( filter)
@@ -371,21 +362,14 @@ fn time_unit_lossy(range: &TimestampRange, ts_col_unit: TimeUnit) -> bool {
371362/// `FastTimestampRowFilter` is used to filter rows within given timestamp range when reading
372363/// row groups from parquet files, while avoids fetching all columns from SSTs file.
373364struct FastTimestampRowFilter {
374- timestamp_index : usize ,
375365 lower_bound : i64 ,
376366 upper_bound : i64 ,
377367 projection : ProjectionMask ,
378368}
379369
380370impl FastTimestampRowFilter {
381- fn new (
382- ts_col_idx : usize ,
383- projection : ProjectionMask ,
384- lower_bound : i64 ,
385- upper_bound : i64 ,
386- ) -> Self {
371+ fn new ( projection : ProjectionMask , lower_bound : i64 , upper_bound : i64 ) -> Self {
387372 Self {
388- timestamp_index : ts_col_idx,
389373 lower_bound,
390374 upper_bound,
391375 projection,
@@ -400,7 +384,7 @@ impl ArrowPredicate for FastTimestampRowFilter {
400384
401385 /// Selects the rows matching given time range.
402386 fn evaluate ( & mut self , batch : RecordBatch ) -> std:: result:: Result < BooleanArray , ArrowError > {
403- let ts_col = batch. column ( self . timestamp_index ) ;
387+ let ts_col = batch. column ( 0 ) ;
404388
405389 macro_rules! downcast_and_compute {
406390 ( $typ: ty) => {
@@ -442,15 +426,13 @@ impl ArrowPredicate for FastTimestampRowFilter {
442426/// [PlainTimestampRowFilter] iterates each element in timestamp column, build a [Timestamp] struct
443427/// and checks if given time range contains the timestamp.
444428struct PlainTimestampRowFilter {
445- timestamp_index : usize ,
446429 time_range : TimestampRange ,
447430 projection : ProjectionMask ,
448431}
449432
450433impl PlainTimestampRowFilter {
451- fn new ( timestamp_index : usize , time_range : TimestampRange , projection : ProjectionMask ) -> Self {
434+ fn new ( time_range : TimestampRange , projection : ProjectionMask ) -> Self {
452435 Self {
453- timestamp_index,
454436 time_range,
455437 projection,
456438 }
@@ -463,7 +445,7 @@ impl ArrowPredicate for PlainTimestampRowFilter {
463445 }
464446
465447 fn evaluate ( & mut self , batch : RecordBatch ) -> std:: result:: Result < BooleanArray , ArrowError > {
466- let ts_col = batch. column ( self . timestamp_index ) ;
448+ let ts_col = batch. column ( 0 ) ;
467449
468450 macro_rules! downcast_and_compute {
469451 ( $array_ty: ty, $unit: ident) => { {
@@ -531,33 +513,6 @@ impl BatchReader for ChunkStream {
531513 }
532514}
533515
534- /// Parquet writer data source.
535- pub enum Source {
536- /// Writes rows from memtable to parquet
537- Iter ( BoxedBatchIterator ) ,
538- /// Writes row from ChunkReaderImpl (maybe a set of SSTs) to parquet.
539- Reader ( ChunkReaderImpl ) ,
540- }
541-
542- impl Source {
543- async fn next_batch ( & mut self ) -> Result < Option < Batch > > {
544- match self {
545- Source :: Iter ( iter) => iter. next ( ) . transpose ( ) ,
546- Source :: Reader ( reader) => reader
547- . next_chunk ( )
548- . await
549- . map ( |p| p. map ( |chunk| Batch :: new ( chunk. columns ) ) ) ,
550- }
551- }
552-
553- fn projected_schema ( & self ) -> ProjectedSchemaRef {
554- match self {
555- Source :: Iter ( iter) => iter. schema ( ) ,
556- Source :: Reader ( reader) => reader. projected_schema ( ) . clone ( ) ,
557- }
558- }
559- }
560-
561516#[ cfg( test) ]
562517mod tests {
563518 use std:: sync:: Arc ;
0 commit comments