MCPcopy Create free account
hub / github.com/apache/datafusion / execute

Method execute

datafusion/physical-plan/src/analyze.rs:164–227  ·  view source on GitHub ↗
(
        &self,
        partition: usize,
        context: Arc<TaskContext>,
    )

Source from the content-addressed store, hash-verified

162 }
163
164 fn execute(
165 &self,
166 partition: usize,
167 context: Arc<TaskContext>,
168 ) -> Result<SendableRecordBatchStream> {
169 assert_eq_or_internal_err!(
170 partition,
171 0,
172 "AnalyzeExec invalid partition. Expected 0, got {partition}"
173 );
174
175 // Gather futures that will run each input partition in
176 // parallel (on a separate tokio task) using a JoinSet to
177 // cancel outstanding futures on drop
178 let num_input_partitions = self.input.output_partitioning().partition_count();
179 let mut builder =
180 RecordBatchReceiverStream::builder(self.schema(), num_input_partitions);
181
182 for input_partition in 0..num_input_partitions {
183 builder.run_input(
184 Arc::clone(&self.input),
185 input_partition,
186 Arc::clone(&context),
187 );
188 }
189
190 // Create future that computes the final output
191 let start = Instant::now();
192 let captured_input = Arc::clone(&self.input);
193 let captured_schema = Arc::clone(&self.schema);
194 let verbose = self.verbose;
195 let show_statistics = self.show_statistics;
196 let metric_types = self.metric_types.clone();
197 let metric_categories = self.metric_categories.clone();
198
199 // future that gathers the results from all the tasks in the
200 // JoinSet that computes the overall row count and final
201 // record batch
202 let mut input_stream = builder.build();
203 let output = async move {
204 let mut total_rows = 0;
205 while let Some(batch) = input_stream.next().await.transpose()? {
206 total_rows += batch.num_rows();
207 }
208 drop(input_stream);
209
210 let duration = Instant::now() - start;
211 create_output_batch(
212 verbose,
213 show_statistics,
214 total_rows,
215 duration,
216 &captured_input,
217 &captured_schema,
218 &metric_types,
219 metric_categories.as_deref(),
220 )
221 };

Callers

nothing calls this directly

Calls 9

create_output_batchFunction · 0.85
newFunction · 0.85
partition_countMethod · 0.80
run_inputMethod · 0.80
output_partitioningMethod · 0.45
schemaMethod · 0.45
cloneMethod · 0.45
buildMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected