Struct datafusion::physical_plan::repartition::RepartitionExec
source · pub struct RepartitionExec { /* private fields */ }
Expand description
Maps N
input partitions to M
output partitions based on a
Partitioning
scheme.
Background
DataFusion, like most other commercial systems, with the the notable exception of DuckDB, uses the “Exchange Operator” based approach to parallelism which works well in practice given sufficient care in implementation.
DataFusion’s planner picks the target number of partitions and
then RepartionExec
redistributes RecordBatch
es to that number
of output partitions.
For example, given target_partitions=3
(trying to use 3 cores)
but scanning an input with 2 partitions, RepartitionExec
can be
used to get 3 even streams of RecordBatch
es
▲ ▲ ▲
│ │ │
│ │ │
│ │ │
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ GroupBy │ │ GroupBy │ │ GroupBy │
│ (Partial) │ │ (Partial) │ │ (Partial) │
└───────────────┘ └───────────────┘ └───────────────┘
▲ ▲ ▲
└──────────────────┼──────────────────┘
│
┌─────────────────────────┐
│ RepartitionExec │
│ (hash/round robin) │
└─────────────────────────┘
▲ ▲
┌───────────┘ └───────────┐
│ │
│ │
.─────────. .─────────.
,─' '─. ,─' '─.
; Input : ; Input :
: Partition 0 ; : Partition 1 ;
╲ ╱ ╲ ╱
'─. ,─' '─. ,─'
`───────' `───────'
Output Ordering
No guarantees are made about the order of the resulting
partitions unless preserve_order
is set.
Footnote
The “Exchange Operator” was first described in the 1989 paper Encapsulation of parallelism in the Volcano query processing system Paper which uses the term “Exchange” for the concept of repartitioning data across threads.
Implementations§
source§impl RepartitionExec
impl RepartitionExec
sourcepub fn input(&self) -> &Arc<dyn ExecutionPlan>
pub fn input(&self) -> &Arc<dyn ExecutionPlan>
Input execution plan
sourcepub fn partitioning(&self) -> &Partitioning
pub fn partitioning(&self) -> &Partitioning
Partitioning scheme to use
sourcepub fn preserve_order(&self) -> bool
pub fn preserve_order(&self) -> bool
Get preserve_order flag of the RepartitionExecutor
true
means SortPreservingRepartitionExec
, false
means RepartitionExec
source§impl RepartitionExec
impl RepartitionExec
sourcepub fn try_new(
input: Arc<dyn ExecutionPlan>,
partitioning: Partitioning
) -> Result<Self>
pub fn try_new( input: Arc<dyn ExecutionPlan>, partitioning: Partitioning ) -> Result<Self>
Create a new RepartitionExec
sourcepub fn with_preserve_order(self, preserve_order: bool) -> Self
pub fn with_preserve_order(self, preserve_order: bool) -> Self
Set Order preserving flag
Trait Implementations§
source§impl Debug for RepartitionExec
impl Debug for RepartitionExec
source§impl DisplayAs for RepartitionExec
impl DisplayAs for RepartitionExec
source§impl ExecutionPlan for RepartitionExec
impl ExecutionPlan for RepartitionExec
source§fn unbounded_output(&self, children: &[bool]) -> Result<bool>
fn unbounded_output(&self, children: &[bool]) -> Result<bool>
Specifies whether this plan generates an infinite stream of records. If the plan does not support pipelining, but its input(s) are infinite, returns an error to indicate this.
source§fn children(&self) -> Vec<Arc<dyn ExecutionPlan>>
fn children(&self) -> Vec<Arc<dyn ExecutionPlan>>
source§fn with_new_children(
self: Arc<Self>,
children: Vec<Arc<dyn ExecutionPlan>>
) -> Result<Arc<dyn ExecutionPlan>>
fn with_new_children( self: Arc<Self>, children: Vec<Arc<dyn ExecutionPlan>> ) -> Result<Arc<dyn ExecutionPlan>>
source§fn benefits_from_input_partitioning(&self) -> Vec<bool>
fn benefits_from_input_partitioning(&self) -> Vec<bool>
true
, this indicates that the
operator would benefit from partitioning its corresponding child
(and thus from more parallelism). For operators that do very little work
the overhead of extra parallelism may outweigh any benefits Read moresource§fn output_partitioning(&self) -> Partitioning
fn output_partitioning(&self) -> Partitioning
source§fn output_ordering(&self) -> Option<&[PhysicalSortExpr]>
fn output_ordering(&self) -> Option<&[PhysicalSortExpr]>
Some(keys)
with the description of how it was sorted. Read moresource§fn maintains_input_order(&self) -> Vec<bool>
fn maintains_input_order(&self) -> Vec<bool>
false
if this operator’s implementation may reorder
rows within or between partitions. Read moresource§fn equivalence_properties(&self) -> EquivalenceProperties
fn equivalence_properties(&self) -> EquivalenceProperties
source§fn ordering_equivalence_properties(&self) -> OrderingEquivalenceProperties
fn ordering_equivalence_properties(&self) -> OrderingEquivalenceProperties
source§fn execute(
&self,
partition: usize,
context: Arc<TaskContext>
) -> Result<SendableRecordBatchStream>
fn execute( &self, partition: usize, context: Arc<TaskContext> ) -> Result<SendableRecordBatchStream>
source§fn metrics(&self) -> Option<MetricsSet>
fn metrics(&self) -> Option<MetricsSet>
source§fn statistics(&self) -> Statistics
fn statistics(&self) -> Statistics
ExecutionPlan
node.source§fn required_input_distribution(&self) -> Vec<Distribution>
fn required_input_distribution(&self) -> Vec<Distribution>
source§fn required_input_ordering(&self) -> Vec<Option<Vec<PhysicalSortRequirement>>>
fn required_input_ordering(&self) -> Vec<Option<Vec<PhysicalSortRequirement>>>
source§fn file_scan_config(&self) -> Option<&FileScanConfig>
fn file_scan_config(&self) -> Option<&FileScanConfig>
FileScanConfig
in case this is a data source scanning execution plan or None
otherwise.