@@ -520,20 +520,17 @@ impl Morsel for ParquetStreamMorsel {
520520 }
521521}
522522
523- /// Stateful planner for opening a single parquet file via the morsel APIs.
524- enum ParquetMorselPlanner {
523+ /// Planner for opening a single parquet file via the morsel APIs.
524+ struct ParquetMorselPlanner {
525525 /// Ready to perform CPU-only planning work.
526- Ready ( ParquetOpenState ) ,
526+ state : ParquetOpenState ,
527527}
528528
529529impl fmt:: Debug for ParquetMorselPlanner {
530530 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
531- match self {
532- Self :: Ready ( state) => f
533- . debug_tuple ( "ParquetMorselPlanner::Ready" )
534- . field ( state)
535- . finish ( ) ,
536- }
531+ f. debug_tuple ( "ParquetMorselPlanner::Ready" )
532+ . field ( & self . state )
533+ . finish ( )
537534 }
538535}
539536
@@ -549,7 +546,7 @@ impl ParquetMorselPlanner {
549546 let state = ParquetOpenState :: Start {
550547 prepared : Box :: new ( prepared) ,
551548 } ;
552- Ok ( Self :: Ready ( state) )
549+ Ok ( Self { state } )
553550 }
554551
555552 /// Schedule an I/O future that resolves to the next planner to run.
@@ -567,23 +564,19 @@ impl ParquetMorselPlanner {
567564 {
568565 let io_future = async move {
569566 let next_state = future. await ?;
570- Ok ( Box :: new ( ParquetMorselPlanner :: Ready ( next_state) ) as _ )
567+ Ok ( Box :: new ( ParquetMorselPlanner { state : next_state } ) as _ )
571568 } ;
572569 MorselPlan :: new ( ) . with_pending_planner ( io_future)
573570 }
574571}
575572
576573impl MorselPlanner for ParquetMorselPlanner {
577574 fn plan ( self : Box < Self > ) -> Result < Option < MorselPlan > > {
578- let state = match * self {
579- ParquetMorselPlanner :: Ready ( state) => state,
580- } ;
581-
582- if let ParquetOpenState :: Done = state {
575+ if let ParquetOpenState :: Done = self . state {
583576 return Ok ( None ) ;
584577 }
585578
586- let state = state. transition ( ) ?;
579+ let state = self . state . transition ( ) ?;
587580
588581 match state {
589582 #[ cfg( feature = "parquet_encryption" ) ]
@@ -617,11 +610,10 @@ impl MorselPlanner for ParquetMorselPlanner {
617610 Ok ( Some ( MorselPlan :: new ( ) . with_morsels ( morsels) ) )
618611 }
619612 ParquetOpenState :: Done => Ok ( None ) ,
620- cpu_state => {
621- Ok ( Some ( MorselPlan :: new ( ) . with_planners ( vec ! [ Box :: new(
622- ParquetMorselPlanner :: Ready ( cpu_state) ,
623- ) ] ) ) )
624- }
613+ cpu_state => Ok ( Some (
614+ MorselPlan :: new ( )
615+ . with_planners ( vec ! [ Box :: new( Self { state: cpu_state } ) ] ) ,
616+ ) ) ,
625617 }
626618 }
627619}
0 commit comments