@@ -117,6 +117,7 @@ use vortex::io::session::RuntimeSessionExt;
117117use vortex:: scan:: DataSourceRef ;
118118use vortex:: scan:: ScanRequest ;
119119use vortex:: session:: VortexSession ;
120+ use vortex_utils:: parallelism:: get_available_parallelism;
120121
121122use crate :: convert:: exprs:: DefaultExpressionConvertor ;
122123use crate :: convert:: exprs:: ExpressionConvertor ;
@@ -277,9 +278,7 @@ impl VortexDataSourceBuilder {
277278 filter : None ,
278279 limit : None ,
279280 ordered : false ,
280- num_partitions : std:: thread:: available_parallelism ( ) . unwrap_or_else ( |_| {
281- NonZero :: new ( 1 ) . vortex_expect ( "available parallelism must be non-zero" )
282- } ) ,
281+ num_partitions : get_available_parallelism ( ) . unwrap_or ( 1 ) ,
283282 } )
284283 }
285284}
@@ -360,7 +359,7 @@ pub struct VortexDataSource {
360359 /// We use this as a hint for how many splits to execute concurrently in `open()`, but we
361360 /// always declare to DataFusion that we only have a single partition so that we can
362361 /// internally manage concurrency and fix the problem of partition skew.
363- num_partitions : NonZeroUsize ,
362+ num_partitions : usize ,
364363}
365364
366365impl fmt:: Debug for VortexDataSource {
@@ -428,7 +427,7 @@ impl DataSource for VortexDataSource {
428427
429428 let handle = session. handle ( ) ;
430429 let stream = scan_streams
431- . try_flatten_unordered ( Some ( num_partitions. get ( ) * 2 ) )
430+ . try_flatten_unordered ( Some ( num_partitions * 2 ) )
432431 . map ( move |result| {
433432 let session = session. clone ( ) ;
434433 let schema = Arc :: clone ( & projected_schema) ;
@@ -437,7 +436,7 @@ impl DataSource for VortexDataSource {
437436 result. and_then ( |chunk| chunk. execute_record_batch ( & schema, & mut ctx) )
438437 } )
439438 } )
440- . buffered ( num_partitions. get ( ) )
439+ . buffered ( num_partitions)
441440 . map ( |result| result. map_err ( |e| DataFusionError :: External ( Box :: new ( e) ) ) ) ;
442441
443442 // Apply leftover projection (expressions that couldn't be pushed into Vortex).
@@ -488,8 +487,7 @@ impl DataSource for VortexDataSource {
488487 ) -> DFResult < Option < Arc < dyn DataSource > > > {
489488 // Vortex handles parallelism internally — always use a single partition.
490489 let mut this = self . clone ( ) ;
491- this. num_partitions = NonZero :: new ( target_partitions)
492- . ok_or_else ( || DataFusionError :: Internal ( "non-zero partitions" . to_string ( ) ) ) ?;
490+ this. num_partitions = target_partitions;
493491 this. ordered |= output_ordering. is_some ( ) ;
494492 Ok ( Some ( Arc :: new ( this) ) )
495493 }
0 commit comments