mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 08:38:58 +00:00
0b270bf0cc
Signed-off-by: junxiang Mu <1948535941@qq.com>
33 lines
986 B
Rust
33 lines
986 B
Rust
use std::sync::Arc;
|
|
|
|
use async_trait::async_trait;
|
|
use datafusion::common::Result;
|
|
use datafusion::execution::context::TaskContext;
|
|
use datafusion::physical_plan::{ExecutionPlan, SendableRecordBatchStream};
|
|
|
|
pub type SchedulerRef = Arc<dyn Scheduler + Send + Sync>;
|
|
|
|
#[async_trait]
|
|
pub trait Scheduler {
|
|
/// Schedule the provided [`ExecutionPlan`] on this [`Scheduler`].
|
|
///
|
|
/// Returns a [`ExecutionResults`] that can be used to receive results as they are produced,
|
|
/// as a [`futures::Stream`] of [`RecordBatch`]
|
|
async fn schedule(&self, plan: Arc<dyn ExecutionPlan>, context: Arc<TaskContext>) -> Result<ExecutionResults>;
|
|
}
|
|
|
|
pub struct ExecutionResults {
|
|
stream: SendableRecordBatchStream,
|
|
}
|
|
|
|
impl ExecutionResults {
|
|
pub fn new(stream: SendableRecordBatchStream) -> Self {
|
|
Self { stream }
|
|
}
|
|
|
|
/// Returns a [`SendableRecordBatchStream`] of this execution
|
|
pub fn stream(self) -> SendableRecordBatchStream {
|
|
self.stream
|
|
}
|
|
}
|