(root: P) -> anyhow::Result>
diff --git a/crates/bimm-firehose/src/core/mod.rs b/crates/bimm-firehose/src/core/mod.rs
index 035750b6..61a7a080 100644
--- a/crates/bimm-firehose/src/core/mod.rs
+++ b/crates/bimm-firehose/src/core/mod.rs
@@ -12,8 +12,12 @@ pub mod values;
// TODO: Work out what the `$crate::core::*` re-exports should be.
pub use rows::{
- FirehoseBatchTransaction, FirehoseRow, FirehoseRowBatch, FirehoseRowReader,
- FirehoseRowTransaction, FirehoseRowWriter,
+ FirehoseBatchTransaction,
+ FirehoseRow,
+ FirehoseRowBatch,
+ FirehoseRowReader,
+ FirehoseRowTransaction,
+ FirehoseRowWriter,
};
pub use schema::FirehoseTableSchema;
pub use values::FirehoseValue;
diff --git a/crates/bimm-firehose/src/core/operations/environment.rs b/crates/bimm-firehose/src/core/operations/environment.rs
index 6273a647..7c32a66b 100644
--- a/crates/bimm-firehose/src/core/operations/environment.rs
+++ b/crates/bimm-firehose/src/core/operations/environment.rs
@@ -1,14 +1,33 @@
-use crate::core::operations::factory::{FirehoseOperatorFactory, FirehoseOperatorInitContext};
-use crate::core::operations::operator::FirehoseOperator;
-use crate::core::operations::planner::OperationPlan;
-use crate::core::operations::signature::FirehoseOperatorSignature;
-use crate::core::schema::{BuildPlan, DataTypeDescription, FirehoseTableSchema};
-use anyhow::{Context, bail};
-use std::collections::BTreeMap;
-use std::fmt::Debug;
-use std::sync::Arc;
-
-/// `OpEnvironment` is a trait that provides access to a collection of operator bindings.
+use std::{
+ collections::BTreeMap,
+ fmt::Debug,
+ sync::Arc,
+};
+
+use anyhow::{
+ Context,
+ bail,
+};
+
+use crate::core::{
+ operations::{
+ factory::{
+ FirehoseOperatorFactory,
+ FirehoseOperatorInitContext,
+ },
+ operator::FirehoseOperator,
+ planner::OperationPlan,
+ signature::FirehoseOperatorSignature,
+ },
+ schema::{
+ BuildPlan,
+ DataTypeDescription,
+ FirehoseTableSchema,
+ },
+};
+
+/// `OpEnvironment` is a trait that provides access to a collection of operator
+/// bindings.
pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
/// Returns a reference to the map of operator bindings.
// TODO: This should be an iterator.
@@ -24,7 +43,8 @@ pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
///
/// # Returns
///
- /// An `anyhow::Result>` containing the operator factory.
+ /// An `anyhow::Result>` containing the
+ /// operator factory.
fn lookup_operator_factory(
&self,
operator_id: &str,
@@ -43,7 +63,8 @@ pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
///
/// # Arguments
///
- /// * `context` - The context containing the build plan and input/output types.
+ /// * `context` - The context containing the build plan and input/output
+ /// types.
///
/// # Returns
///
@@ -59,11 +80,13 @@ pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
///
/// # Arguments
///
- /// * `plan_context` - The context containing the build plan and input/output types.
+ /// * `plan_context` - The context containing the build plan and
+ /// input/output types.
///
/// # Returns
///
- /// An `anyhow::Result>` containing the initialized operator.
+ /// An `anyhow::Result>` containing the
+ /// initialized operator.
fn init_operator(
&self,
plan_context: BuildPlanContext,
@@ -84,11 +107,13 @@ pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
/// # Arguments
///
/// * `schema` - A mutable reference to the `TableSchema` to be extended.
- /// * `planner` - An `OperationPlanner` that contains the details of the operation to be planned.
+ /// * `planner` - An `OperationPlanner` that contains the details of the
+ /// operation to be planned.
///
/// # Returns
///
- /// An `anyhow::Result` containing the build plan for the operation.
+ /// An `anyhow::Result` containing the build plan for the
+ /// operation.
fn apply_plan_to_schema(
&self,
schema: &mut FirehoseTableSchema,
@@ -115,7 +140,8 @@ pub trait FirehoseOperatorEnvironment: Debug + Send + Sync {
}
}
-/// `MapOpEnvironment` is a simple implementation of `OpEnvironment` that uses a `BTreeMap` to store operators.
+/// `MapOpEnvironment` is a simple implementation of `OpEnvironment` that uses a
+/// `BTreeMap` to store operators.
#[derive(Debug)]
pub struct MapOpEnvironment {
/// A map of operator IDs to their corresponding operator factories.
@@ -161,7 +187,8 @@ impl MapOpEnvironment {
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if the binding already exists.
+ /// An `anyhow::Result<()>` indicating success or containing an error if the
+ /// binding already exists.
pub fn add_operator(
&mut self,
factory: Arc,
@@ -182,7 +209,8 @@ impl MapOpEnvironment {
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if any binding fails to be added.
+ /// An `anyhow::Result<()>` indicating success or containing an error if any
+ /// binding fails to be added.
pub fn add_all_operators(
&mut self,
factories: Vec>,
@@ -215,7 +243,8 @@ pub struct BuildPlanContext {
}
impl BuildPlanContext {
- /// Creates a new `OperationInitPlanContext` with the given table schema and build plan.
+ /// Creates a new `OperationInitPlanContext` with the given table schema and
+ /// build plan.
pub fn new(
table_schema: Arc,
build_plan: Arc,
@@ -245,7 +274,8 @@ impl BuildPlanContext {
///
/// # Returns
///
- /// An `anyhow::Result` containing the bound context.
+ /// An `anyhow::Result` containing the bound
+ /// context.
pub fn bind_signature(
self,
signature: &FirehoseOperatorSignature,
@@ -253,7 +283,8 @@ impl BuildPlanContext {
OperationInitializationContext::init(self, signature.clone())
}
- /// Computes the input types for the operator based on the build plan and table schema.
+ /// Computes the input types for the operator based on the build plan and
+ /// table schema.
pub fn input_types(&self) -> BTreeMap {
self.build_plan
.inputs
@@ -267,7 +298,8 @@ impl BuildPlanContext {
.collect()
}
- /// Computes the output types for the operator based on the build plan and table schema.
+ /// Computes the output types for the operator based on the build plan and
+ /// table schema.
pub fn output_types(&self) -> BTreeMap {
self.build_plan
.outputs
@@ -312,7 +344,8 @@ impl FirehoseOperatorInitContext for OperationInitializationContext {
}
impl OperationInitializationContext {
- /// Creates a new `OperationInitSignatureContext` with the given plan context and signature.
+ /// Creates a new `OperationInitSignatureContext` with the given plan
+ /// context and signature.
///
/// # Returns
///
diff --git a/crates/bimm-firehose/src/core/operations/executor.rs b/crates/bimm-firehose/src/core/operations/executor.rs
index 15cc2909..b04fc4ca 100644
--- a/crates/bimm-firehose/src/core/operations/executor.rs
+++ b/crates/bimm-firehose/src/core/operations/executor.rs
@@ -1,9 +1,16 @@
-use crate::core::operations::environment::FirehoseOperatorEnvironment;
-use crate::core::operations::operator::OperationRunner;
-use crate::core::rows::FirehoseRowBatch;
-use crate::core::schema::FirehoseTableSchema;
-use std::fmt::Debug;
-use std::sync::Arc;
+use std::{
+ fmt::Debug,
+ sync::Arc,
+};
+
+use crate::core::{
+ operations::{
+ environment::FirehoseOperatorEnvironment,
+ operator::OperationRunner,
+ },
+ rows::FirehoseRowBatch,
+ schema::FirehoseTableSchema,
+};
/// Trait for executing a batch of operations on a `RowBatch`.
pub trait FirehoseBatchExecutor: Debug + Send + Sync {
@@ -37,7 +44,8 @@ pub struct SequentialBatchExecutor {
}
impl SequentialBatchExecutor {
- /// Creates a new `DefaultBatchExecutor` with the given operator environment.
+ /// Creates a new `DefaultBatchExecutor` with the given operator
+ /// environment.
pub fn new(
schema: Arc,
environment: Arc,
diff --git a/crates/bimm-firehose/src/core/operations/factory.rs b/crates/bimm-firehose/src/core/operations/factory.rs
index 7ba5a69e..f5742596 100644
--- a/crates/bimm-firehose/src/core/operations/factory.rs
+++ b/crates/bimm-firehose/src/core/operations/factory.rs
@@ -1,10 +1,21 @@
-use crate::core::operations::operator::FirehoseOperator;
-use crate::core::operations::signature::FirehoseOperatorSignature;
-use crate::core::schema::{BuildPlan, FirehoseTableSchema};
+use std::{
+ fmt::Debug,
+ marker::PhantomData,
+};
+
use anyhow::Context;
use serde::de::DeserializeOwned;
-use std::fmt::Debug;
-use std::marker::PhantomData;
+
+use crate::core::{
+ operations::{
+ operator::FirehoseOperator,
+ signature::FirehoseOperatorSignature,
+ },
+ schema::{
+ BuildPlan,
+ FirehoseTableSchema,
+ },
+};
/// A factory for creating `FirehoseOperator` instances from a specification.
pub trait FirehoseOperatorFactory: Debug + Send + Sync {
@@ -19,16 +30,19 @@ pub trait FirehoseOperatorFactory: Debug + Send + Sync {
/// Returns the operator specification.
fn signature(&self) -> &FirehoseOperatorSignature;
- /// Inits a build plan against the input and output types using an `OpInitContext`.
+ /// Inits a build plan against the input and output types using an
+ /// `OpInitContext`.
///
/// # Arguments
///
- /// * `context` - The context containing the build plan and input/output types.
+ /// * `context` - The context containing the build plan and input/output
+ /// types.
///
/// # Returns
///
/// A `Result, String>` where:
- /// * `Ok` contains a boxed operator that implements the `BuildOperator` trait,
+ /// * `Ok` contains a boxed operator that implements the `BuildOperator`
+ /// trait,
/// * `Err` contains an error message if the initialization fails.
fn init(
&self,
@@ -51,7 +65,8 @@ pub trait FirehoseOperatorInitContext {
fn signature(&self) -> &FirehoseOperatorSignature;
}
-/// A simple operator factory for types implementing `DeserializeOwned` and `FirehoseOperator`.
+/// A simple operator factory for types implementing `DeserializeOwned` and
+/// `FirehoseOperator`.
#[derive(Debug)]
pub struct SimpleConfigOperatorFactory
where
@@ -68,7 +83,8 @@ impl SimpleConfigOperatorFactory
where
T: DeserializeOwned + FirehoseOperator,
{
- /// Creates a new `SpecConfigOpBinding` with the given operator specification.
+ /// Creates a new `SpecConfigOpBinding` with the given operator
+ /// specification.
pub fn new(spec: FirehoseOperatorSignature) -> Self {
if spec.operator_id.is_none() {
panic!("OperatorSpec must have an operator_id");
@@ -106,12 +122,25 @@ where
#[cfg(test)]
mod tests {
- use crate::core::operations::factory::SimpleConfigOperatorFactory;
- use crate::core::operations::operator::FirehoseOperator;
- use crate::core::operations::signature::{FirehoseOperatorSignature, ParameterSpec};
- use crate::core::rows::FirehoseRowTransaction;
- use crate::define_firehose_operator_id;
- use serde::{Deserialize, Serialize};
+ use serde::{
+ Deserialize,
+ Serialize,
+ };
+
+ use crate::{
+ core::{
+ operations::{
+ factory::SimpleConfigOperatorFactory,
+ operator::FirehoseOperator,
+ signature::{
+ FirehoseOperatorSignature,
+ ParameterSpec,
+ },
+ },
+ rows::FirehoseRowTransaction,
+ },
+ define_firehose_operator_id,
+ };
define_firehose_operator_id!(TEST_OP);
diff --git a/crates/bimm-firehose/src/core/operations/mod.rs b/crates/bimm-firehose/src/core/operations/mod.rs
index 266da069..9f106e15 100644
--- a/crates/bimm-firehose/src/core/operations/mod.rs
+++ b/crates/bimm-firehose/src/core/operations/mod.rs
@@ -17,9 +17,10 @@ pub mod signature;
///
/// # Arguments
///
-/// * `$name`: The name of the operator ID to define;
-/// will create a self-referential static string constant.
-/// * `$constructor`: A closure that returns an `Arc`.
+/// * `$name`: The name of the operator ID to define; will create a
+/// self-referential static string constant.
+/// * `$constructor`: A closure that returns an `Arc`.
///
/// This macro combines the functionality of `define_firehose_operator_id`
/// and `register_firehose_operator_factory`.
@@ -33,12 +34,12 @@ macro_rules! define_firehose_operator {
/// Define a self-referential operator ID.
///
-/// The id will be defined as a static string constant that refers to its own namespace path.
+/// The id will be defined as a static string constant that refers to its own
+/// namespace path.
///
/// # Arguments
///
/// * `$name`: The name of the operator ID to define.
-///
#[macro_export]
macro_rules! define_firehose_operator_id {
($name:ident) => {
@@ -49,7 +50,8 @@ macro_rules! define_firehose_operator_id {
/// Macro to register a default operator factory.
///
/// Builders which do not require runtime configuration can be registered
-/// using this macro; and collected globally using `list_default_operator_builders`.
+/// using this macro; and collected globally using
+/// `list_default_operator_builders`.
///
/// You can also collect a default environment with all registered builders
/// using `new_default_operator_environment`.
@@ -71,23 +73,50 @@ macro_rules! register_firehose_operator_factory {
#[cfg(test)]
mod tests {
- use crate::core::operations::environment::{FirehoseOperatorEnvironment, MapOpEnvironment};
- use crate::core::operations::factory::SimpleConfigOperatorFactory;
- use crate::core::operations::operator::OperationRunner;
- use crate::core::operations::operator::{FirehoseOperator, OperatorSchedulingMetadata};
- use crate::core::operations::signature::{FirehoseOperatorSignature, ParameterSpec};
-
- use crate::core::FirehoseValue;
- use crate::core::rows::{
- FirehoseRowBatch, FirehoseRowReader, FirehoseRowTransaction, FirehoseRowWriter,
+ use std::{
+ collections::BTreeMap,
+ fmt::Debug,
+ sync::Arc,
};
- use crate::core::schema::{BuildPlan, ColumnSchema, DataTypeDescription, FirehoseTableSchema};
+
// use crate::define_firehose_operator_id;
use indoc::indoc;
- use serde::{Deserialize, Serialize};
- use std::collections::BTreeMap;
- use std::fmt::Debug;
- use std::sync::Arc;
+ use serde::{
+ Deserialize,
+ Serialize,
+ };
+
+ use crate::core::{
+ FirehoseValue,
+ operations::{
+ environment::{
+ FirehoseOperatorEnvironment,
+ MapOpEnvironment,
+ },
+ factory::SimpleConfigOperatorFactory,
+ operator::{
+ FirehoseOperator,
+ OperationRunner,
+ OperatorSchedulingMetadata,
+ },
+ signature::{
+ FirehoseOperatorSignature,
+ ParameterSpec,
+ },
+ },
+ rows::{
+ FirehoseRowBatch,
+ FirehoseRowReader,
+ FirehoseRowTransaction,
+ FirehoseRowWriter,
+ },
+ schema::{
+ BuildPlan,
+ ColumnSchema,
+ DataTypeDescription,
+ FirehoseTableSchema,
+ },
+ };
define_firehose_operator_id!(ADD);
diff --git a/crates/bimm-firehose/src/core/operations/operator.rs b/crates/bimm-firehose/src/core/operations/operator.rs
index d79a8730..53cb208a 100644
--- a/crates/bimm-firehose/src/core/operations/operator.rs
+++ b/crates/bimm-firehose/src/core/operations/operator.rs
@@ -1,10 +1,31 @@
-use crate::core::operations::environment::{BuildPlanContext, FirehoseOperatorEnvironment};
-use crate::core::operations::signature::FirehoseOperatorSignature;
-use crate::core::rows::{FirehoseBatchTransaction, FirehoseRowBatch, FirehoseRowTransaction};
-use crate::core::schema::{BuildPlan, FirehoseTableSchema};
-use serde::{Deserialize, Serialize};
-use std::fmt::Debug;
-use std::sync::Arc;
+use std::{
+ fmt::Debug,
+ sync::Arc,
+};
+
+use serde::{
+ Deserialize,
+ Serialize,
+};
+
+use crate::core::{
+ operations::{
+ environment::{
+ BuildPlanContext,
+ FirehoseOperatorEnvironment,
+ },
+ signature::FirehoseOperatorSignature,
+ },
+ rows::{
+ FirehoseBatchTransaction,
+ FirehoseRowBatch,
+ FirehoseRowTransaction,
+ },
+ schema::{
+ BuildPlan,
+ FirehoseTableSchema,
+ },
+};
/// Scheduling metadata for an operator.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@@ -27,7 +48,8 @@ pub trait FirehoseOperator: 'static + Send + Sync + Debug {
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if the operation fails.
+ /// An `anyhow::Result<()>` indicating success or containing an error if the
+ /// operation fails.
#[must_use]
fn apply_to_batch(
&self,
@@ -44,7 +66,8 @@ pub trait FirehoseOperator: 'static + Send + Sync + Debug {
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if the operation fails.
+ /// An `anyhow::Result<()>` indicating success or containing an error if the
+ /// operation fails.
#[must_use]
fn apply_to_row(
&self,
@@ -52,7 +75,8 @@ pub trait FirehoseOperator: 'static + Send + Sync + Debug {
) -> anyhow::Result<()>;
}
-/// Represents a schema + instantiated column operator for a particular build plan.
+/// Represents a schema + instantiated column operator for a particular build
+/// plan.
pub struct OperationRunner {
/// The table schema that this operator is bound to.
pub table_schema: Arc,
@@ -87,17 +111,21 @@ impl Debug for OperationRunner {
}
impl OperationRunner {
- /// Create a new `BoundPlanBuilder` by binding a `BuildPlan` to a `BimmTableSchema`.
+ /// Create a new `BoundPlanBuilder` by binding a `BuildPlan` to a
+ /// `BimmTableSchema`.
///
/// # Arguments
///
/// * `table_schema` - The schema of the table to which this plan is bound.
- /// * `build_plan` - The build plan that describes the operator and its inputs/outputs.
- /// * `env` - An environment that can create the operator based on the build plan.
+ /// * `build_plan` - The build plan that describes the operator and its
+ /// inputs/outputs.
+ /// * `env` - An environment that can create the operator based on the build
+ /// plan.
///
/// # Returns
///
- /// A result containing a `BoundPlanBuilder` if successful, or an error message if the binding fails.
+ /// A result containing a `BoundPlanBuilder` if successful, or an error
+ /// message if the binding fails.
#[must_use]
pub fn new_for_plan(
table_schema: Arc,
@@ -134,7 +162,8 @@ impl OperationRunner {
///
/// # Arguments
///
- /// * `rows` - A mutable slice of `BimmRow` instances that will be processed by the operator.
+ /// * `rows` - A mutable slice of `BimmRow` instances that will be processed
+ /// by the operator.
///
/// # Returns
///
diff --git a/crates/bimm-firehose/src/core/operations/planner.rs b/crates/bimm-firehose/src/core/operations/planner.rs
index 78041aaf..df6ecda5 100644
--- a/crates/bimm-firehose/src/core/operations/planner.rs
+++ b/crates/bimm-firehose/src/core/operations/planner.rs
@@ -1,9 +1,22 @@
-use crate::core::operations::environment::FirehoseOperatorEnvironment;
-use crate::core::operations::signature::FirehoseOperatorSignature;
-use crate::core::schema::{BuildPlan, ColumnSchema, FirehoseTableSchema};
-use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
+use serde::{
+ Deserialize,
+ Serialize,
+};
+
+use crate::core::{
+ operations::{
+ environment::FirehoseOperatorEnvironment,
+ signature::FirehoseOperatorSignature,
+ },
+ schema::{
+ BuildPlan,
+ ColumnSchema,
+ FirehoseTableSchema,
+ },
+};
+
/// A builder for constructing a call to an operator in a `BuildPlan`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct OperationPlan {
@@ -85,7 +98,8 @@ impl OperationPlan {
///
/// # Arguments
///
- /// * `config` - The configuration to be added, which must implement `Serialize`.
+ /// * `config` - The configuration to be added, which must implement
+ /// `Serialize`.
///
/// # Returns
///
@@ -136,12 +150,15 @@ impl OperationPlan {
///
/// # Arguments
///
- /// * `schema` - The mutable reference to the table schema to which the operation will be applied.
- /// * `env` - The environment that can create the operator based on the build plan.
+ /// * `schema` - The mutable reference to the table schema to which the
+ /// operation will be applied.
+ /// * `env` - The environment that can create the operator based on the
+ /// build plan.
///
/// # Returns
///
- /// A result containing a `BuildPlan` if successful, or an error message if the operation fails.
+ /// A result containing a `BuildPlan` if successful, or an error message if
+ /// the operation fails.
pub fn apply_to_schema(
self,
schema: &mut FirehoseTableSchema,
diff --git a/crates/bimm-firehose/src/core/operations/registration.rs b/crates/bimm-firehose/src/core/operations/registration.rs
index 9ec8abc6..1664c88d 100644
--- a/crates/bimm-firehose/src/core/operations/registration.rs
+++ b/crates/bimm-firehose/src/core/operations/registration.rs
@@ -1,9 +1,13 @@
+use std::{
+ fmt::Debug,
+ sync::Arc,
+};
+
use crate::core::operations::factory::FirehoseOperatorFactory;
-use std::fmt::Debug;
-use std::sync::Arc;
// This leverages the `inventory` crate to define a collection scheme for
-// later invocations of `inventory::submit! { }` by the registration macro.
+// later invocations of `inventory::submit! { }` by the registration
+// macro.
inventory::collect!(FirehoseOperatorFactoryRegistration);
/// Struct describing a name to constructor for an operator builder.
@@ -56,12 +60,23 @@ impl FirehoseOperatorFactoryRegistration {
#[cfg(test)]
mod tests {
+ use serde::{
+ Deserialize,
+ Serialize,
+ };
+
use super::*;
- use crate::core::operations::factory::SimpleConfigOperatorFactory;
- use crate::core::operations::operator::FirehoseOperator;
- use crate::core::operations::signature::{FirehoseOperatorSignature, ParameterSpec};
- use crate::define_firehose_operator;
- use serde::{Deserialize, Serialize};
+ use crate::{
+ core::operations::{
+ factory::SimpleConfigOperatorFactory,
+ operator::FirehoseOperator,
+ signature::{
+ FirehoseOperatorSignature,
+ ParameterSpec,
+ },
+ },
+ define_firehose_operator,
+ };
define_firehose_operator!(
EXAMPLE_OPERATOR,
diff --git a/crates/bimm-firehose/src/core/operations/signature.rs b/crates/bimm-firehose/src/core/operations/signature.rs
index ff76a326..a734555b 100644
--- a/crates/bimm-firehose/src/core/operations/signature.rs
+++ b/crates/bimm-firehose/src/core/operations/signature.rs
@@ -1,8 +1,20 @@
-use crate::core::schema::{BuildPlan, ColumnSchema, DataTypeDescription};
-use anyhow::{Context, bail};
-use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
+use anyhow::{
+ Context,
+ bail,
+};
+use serde::{
+ Deserialize,
+ Serialize,
+};
+
+use crate::core::schema::{
+ BuildPlan,
+ ColumnSchema,
+ DataTypeDescription,
+};
+
/// Defines a single parameter specification
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ParameterSpec {
@@ -26,11 +38,13 @@ impl ParameterSpec {
/// # Parameters
///
/// - `name`: The name of the parameter.
- /// - `T`: The type of the parameter, which is used to determine the data type description.
+ /// - `T`: The type of the parameter, which is used to determine the data
+ /// type description.
///
/// # Returns
///
- /// A new `ParameterSpec` instance with the specified name, data type, and required arity.
+ /// A new `ParameterSpec` instance with the specified name, data type, and
+ /// required arity.
pub fn new(name: &str) -> Self {
Self {
name: name.to_string(),
@@ -101,7 +115,8 @@ impl FirehoseOperatorSignature {
}
}
- /// Creates a new `FirehoseOperatorSignature` with the specified operator ID.
+ /// Creates a new `FirehoseOperatorSignature` with the specified operator
+ /// ID.
pub fn from_operator_id(operator_id: &str) -> Self {
Self {
operator_id: Some(operator_id.into()),
@@ -137,17 +152,21 @@ impl FirehoseOperatorSignature {
}
}
- /// Internal helper to add a parameter specification to the list of inputs or outputs.
+ /// Internal helper to add a parameter specification to the list of inputs
+ /// or outputs.
///
/// # Parameters
///
/// * `spec`: The parameter specification to add.
- /// * `ptype`: A string indicating the type of parameter ("input" or "output").
- /// * `specs`: The current list of parameter specifications (either inputs or outputs).
+ /// * `ptype`: A string indicating the type of parameter ("input" or
+ /// "output").
+ /// * `specs`: The current list of parameter specifications (either inputs
+ /// or outputs).
///
/// # Returns
///
- /// An `anyhow::Result>` containing a new vector of parameter specifications with the added parameter.
+ /// An `anyhow::Result>` containing a new vector of
+ /// parameter specifications with the added parameter.
fn with_parameter(
spec: ParameterSpec,
ptype: &str,
@@ -176,8 +195,10 @@ impl FirehoseOperatorSignature {
/// # Returns
///
/// An `Result` where:
- /// * `Ok(Self)`: A new `FirehoseOperatorSignature` with the input parameter added.
- /// * `Err(String)`: An error message if the input parameter name already exists in the signature.
+ /// * `Ok(Self)`: A new `FirehoseOperatorSignature` with the input parameter
+ /// added.
+ /// * `Err(String)`: An error message if the input parameter name already
+ /// exists in the signature.
pub fn with_input_result(
self,
spec: ParameterSpec,
@@ -222,8 +243,10 @@ impl FirehoseOperatorSignature {
/// # Returns
///
/// An `Result` where:
- /// * `Ok(Self)`: A new `FirehoseOperatorSignature` with the output parameter added.
- /// * `Err(String)`: An error message if the output parameter name already exists in the signature.
+ /// * `Ok(Self)`: A new `FirehoseOperatorSignature` with the output
+ /// parameter added.
+ /// * `Err(String)`: An error message if the output parameter name already
+ /// exists in the signature.
pub fn with_output_result(
self,
spec: ParameterSpec,
@@ -302,9 +325,12 @@ impl FirehoseOperatorSignature {
///
/// # Arguments
///
- /// * `param_type`: A string indicating the type of parameters being validated ("input" or "output").
- /// * `specs`: A slice of `ParameterSpec` that defines the expected parameters.
- /// * `provided`: A map of provided parameters, where keys are parameter names and values are their data types.
+ /// * `param_type`: A string indicating the type of parameters being
+ /// validated ("input" or "output").
+ /// * `specs`: A slice of `ParameterSpec` that defines the expected
+ /// parameters.
+ /// * `provided`: A map of provided parameters, where keys are parameter
+ /// names and values are their data types.
///
/// # Returns
///
diff --git a/crates/bimm-firehose/src/core/rows.rs b/crates/bimm-firehose/src/core/rows.rs
index 81056fdf..4b0115e7 100644
--- a/crates/bimm-firehose/src/core/rows.rs
+++ b/crates/bimm-firehose/src/core/rows.rs
@@ -1,15 +1,30 @@
-use crate::core::FirehoseValue;
-use crate::core::operations::signature::FirehoseOperatorSignature;
-use crate::core::schema::{BuildPlan, FirehoseTableSchema};
+use std::{
+ any::Any,
+ collections::HashMap,
+ fmt::Debug,
+ ops::{
+ Index,
+ IndexMut,
+ RangeBounds,
+ },
+ sync::Arc,
+ vec::Drain,
+};
+
use anyhow::Context;
-use serde::Serialize;
-use serde::de::DeserializeOwned;
-use std::any::Any;
-use std::collections::HashMap;
-use std::fmt::Debug;
-use std::ops::{Index, IndexMut, RangeBounds};
-use std::sync::Arc;
-use std::vec::Drain;
+use serde::{
+ Serialize,
+ de::DeserializeOwned,
+};
+
+use crate::core::{
+ FirehoseValue,
+ operations::signature::FirehoseOperatorSignature,
+ schema::{
+ BuildPlan,
+ FirehoseTableSchema,
+ },
+};
/// Represents a row in a Firehose table, containing values for each column.
pub struct FirehoseRow {
@@ -35,7 +50,8 @@ impl Debug for FirehoseRow {
}
impl FirehoseRow {
- /// Creates a new `ValueRow` with the given schema and initializes all slots to `None`.
+ /// Creates a new `ValueRow` with the given schema and initializes all slots
+ /// to `None`.
pub fn new(schema: Arc) -> Self {
let mut slots = Vec::with_capacity(schema.columns.len());
slots.resize_with(schema.columns.len(), || None);
@@ -93,7 +109,8 @@ pub trait FirehoseRowReader {
/// Returns the schema of the row.
fn schema(&self) -> &Arc;
- /// Returns an iterator over the column names and their corresponding values.
+ /// Returns an iterator over the column names and their corresponding
+ /// values.
fn iter(&self) -> impl Iterator)>;
/// Returns true if the row has a value for the specified column name.
@@ -108,7 +125,8 @@ pub trait FirehoseRowReader {
///
/// # Returns
///
- /// A boolean indicating whether the row has a value for the specified column.
+ /// A boolean indicating whether the row has a value for the specified
+ /// column.
fn has_column_value(
&self,
column_name: &str,
@@ -122,8 +140,9 @@ pub trait FirehoseRowReader {
///
/// # Returns
///
- /// An `Option<&ValueBox>` containing a reference to the value of the specified column,
- /// or `None` if the column does not exist or has no value.
+ /// An `Option<&ValueBox>` containing a reference to the value of the
+ /// specified column, or `None` if the column does not exist or has no
+ /// value.
fn maybe_get(
&self,
column_name: &str,
@@ -137,7 +156,8 @@ pub trait FirehoseRowReader {
///
/// # Returns
///
- /// An `anyhow::Result<&FirehoseValue>` reference to the column value; or an error.
+ /// An `anyhow::Result<&FirehoseValue>` reference to the column value; or an
+ /// error.
fn try_get(
&self,
column_name: &str,
@@ -268,7 +288,8 @@ pub trait FirehoseRowWriter {
/// # Arguments
///
/// * `column_name`: The name of the column to set the value for.
- /// * `value`: The value to set for the specified column, wrapped in a `ValueBox`.
+ /// * `value`: The value to set for the specified column, wrapped in a
+ /// `ValueBox`.
///
/// # Panics
///
@@ -328,7 +349,8 @@ pub trait FirehoseRowWriter {
}
}
- /// Take the value of the column, setting it to `None`, and returning it as an `Option`.
+ /// Take the value of the column, setting it to `None`, and returning it as
+ /// an `Option`.
fn take_column(
&mut self,
column_name: &str,
@@ -407,7 +429,8 @@ impl Debug for FirehoseRowBatch {
}
impl FirehoseRowBatch {
- /// Creates a new `ValueRowBatch` with the given schema and initializes an empty vector of rows.
+ /// Creates a new `ValueRowBatch` with the given schema and initializes an
+ /// empty vector of rows.
pub fn new(schema: Arc) -> Self {
Self::new_with_size(schema, 0)
}
@@ -548,7 +571,8 @@ impl IndexMut for FirehoseRowBatch {
}
}
-/// A map of formal parameters to their corresponding input and output columns in a build plan.
+/// A map of formal parameters to their corresponding input and output columns
+/// in a build plan.
struct ParameterMapper {
/// The build plan that describes the operator and its inputs/outputs.
build_plan: Arc,
@@ -560,7 +584,8 @@ impl ParameterMapper {
ParameterMapper { build_plan }
}
- /// Maps an input parameter name to its corresponding column name in the build plan.
+ /// Maps an input parameter name to its corresponding column name in the
+ /// build plan.
///
/// # Arguments
///
@@ -568,7 +593,8 @@ impl ParameterMapper {
///
/// # Returns
///
- /// An `Option<&str>` containing the column name if the parameter is an input parameter,
+ /// An `Option<&str>` containing the column name if the parameter is an
+ /// input parameter,
fn try_map_input_name(
&self,
parameter_name: &str,
@@ -594,7 +620,8 @@ impl ParameterMapper {
}
}
- /// Maps an output parameter name to its corresponding column name in the build plan.
+ /// Maps an output parameter name to its corresponding column name in the
+ /// build plan.
///
/// # Arguments
///
@@ -602,7 +629,8 @@ impl ParameterMapper {
///
/// # Returns
///
- /// An `Option<&str>` containing the column name if the parameter is an output parameter,
+ /// An `Option<&str>` containing the column name if the parameter is an
+ /// output parameter,
fn try_map_output_name(
&self,
parameter_name: &str,
@@ -713,7 +741,8 @@ impl<'a> FirehoseBatchTransaction<'a> {
}
}
-/// A row-transaction for a single row in a batch, allowing both reading and writing of values.
+/// A row-transaction for a single row in a batch, allowing both reading and
+/// writing of values.
///
/// This is a view-class of a backing `FirehoseBatchTransaction`.
pub struct FirehoseRowTransaction<'a> {
@@ -779,12 +808,20 @@ impl FirehoseRowWriter for FirehoseRowTransaction<'_> {
#[cfg(test)]
mod tests {
- use super::*;
- use crate::core::operations::signature::ParameterSpec;
- use crate::core::schema::{ColumnSchema, DataTypeDescription, FirehoseTableSchema};
use std::sync::Arc;
- /// Ensures that `ValueRow` is `Send`, allowing it to be safely shared across threads.
+ use super::*;
+ use crate::core::{
+ operations::signature::ParameterSpec,
+ schema::{
+ ColumnSchema,
+ DataTypeDescription,
+ FirehoseTableSchema,
+ },
+ };
+
+ /// Ensures that `ValueRow` is `Send`, allowing it to be safely shared
+ /// across threads.
const VALUE_ROW_IS_SEND: fn() = || {
fn assert_send() {}
assert_send::();
diff --git a/crates/bimm-firehose/src/core/schema.rs b/crates/bimm-firehose/src/core/schema.rs
index 9b742ae9..bc7ab31d 100644
--- a/crates/bimm-firehose/src/core/schema.rs
+++ b/crates/bimm-firehose/src/core/schema.rs
@@ -1,8 +1,24 @@
+use std::{
+ collections::{
+ BTreeMap,
+ HashSet,
+ },
+ ops::{
+ Index,
+ IndexMut,
+ },
+};
+
+use anyhow::{
+ anyhow,
+ bail,
+};
+use serde::{
+ Deserialize,
+ Serialize,
+};
+
use crate::core::identifiers;
-use anyhow::{anyhow, bail};
-use serde::{Deserialize, Serialize};
-use std::collections::{BTreeMap, HashSet};
-use std::ops::{Index, IndexMut};
/// A serializable description of a data type.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -92,7 +108,8 @@ impl BuildPlan {
///
/// # Arguments
///
- /// - `config`: The configuration to attach to the build plan, serialized as JSON.
+ /// - `config`: The configuration to attach to the build plan, serialized as
+ /// JSON.
///
/// # Returns
///
@@ -114,7 +131,8 @@ impl BuildPlan {
///
/// # Arguments
///
- /// - `assoc`: A slice of tuples where each tuple contains a parameter name and a column name.
+ /// - `assoc`: A slice of tuples where each tuple contains a parameter name
+ /// and a column name.
///
/// # Returns
///
@@ -133,7 +151,8 @@ impl BuildPlan {
///
/// # Arguments
///
- /// - `inputs`: A slice of tuples where each tuple contains a parameter name and a column name.
+ /// - `inputs`: A slice of tuples where each tuple contains a parameter name
+ /// and a column name.
///
/// # Returns
///
@@ -152,7 +171,8 @@ impl BuildPlan {
///
/// # Arguments
///
- /// - `outputs`: A slice of tuples where each tuple contains a parameter name and a column name.
+ /// - `outputs`: A slice of tuples where each tuple contains a parameter
+ /// name and a column name.
///
/// # Returns
///
@@ -194,7 +214,8 @@ impl BuildPlan {
///
/// # Returns
///
- /// An `anyhow::Result<&str>` containing the column name corresponding to the input parameter.
+ /// An `anyhow::Result<&str>` containing the column name corresponding to
+ /// the input parameter.
pub fn translate_input_name(
&self,
parameter_name: &str,
@@ -210,7 +231,8 @@ impl BuildPlan {
///
/// # Returns
///
- /// An `anyhow::Result<&str>` containing the column name corresponding to the output parameter.
+ /// An `anyhow::Result<&str>` containing the column name corresponding to
+ /// the output parameter.
pub fn translate_output_name(
&self,
parameter_name: &str,
@@ -378,12 +400,15 @@ impl FirehoseTableSchema {
///
/// # Arguments
///
- /// - `columns`: A slice of `ColumnSchema` representing the columns in the table.
- /// - `plans`: A slice of `BuildPlan` representing the build plans for the table.
+ /// - `columns`: A slice of `ColumnSchema` representing the columns in the
+ /// table.
+ /// - `plans`: A slice of `BuildPlan` representing the build plans for the
+ /// table.
///
/// # Returns
///
- /// An `anyhow::Result<(Vec, Vec)>` containing the base columns and the ordered build plans.
+ /// An `anyhow::Result<(Vec, Vec)>` containing the base
+ /// columns and the ordered build plans.
fn check_graph(
columns: &[ColumnSchema],
plans: &[BuildPlan],
@@ -453,11 +478,13 @@ impl FirehoseTableSchema {
/// Compute the build order for the table schema.
///
- /// This function checks the build plans and their dependencies to determine the order in which they should be executed.
+ /// This function checks the build plans and their dependencies to determine
+ /// the order in which they should be executed.
///
/// # Returns
///
- /// An `anyhow::Result<(Vec, Vec)>` containing the base columns and the ordered build plans.
+ /// An `anyhow::Result<(Vec, Vec)>` containing the base
+ /// columns and the ordered build plans.
pub fn build_order(&self) -> anyhow::Result<(Vec, Vec)> {
Self::check_graph(&self.columns, &self.build_plans)
}
@@ -543,11 +570,13 @@ impl FirehoseTableSchema {
/// # Arguments
///
/// - `plan`: The build plan to add.
- /// - `output_info`: A slice of tuples where each tuple contains the output column name, its data type, and a description.
+ /// - `output_info`: A slice of tuples where each tuple contains the output
+ /// column name, its data type, and a description.
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if the operation fails.
+ /// An `anyhow::Result<()>` indicating success or containing an error if the
+ /// operation fails.
pub fn add_build_plan_and_outputs(
&mut self,
plan: BuildPlan,
@@ -576,7 +605,8 @@ impl FirehoseTableSchema {
///
/// # Returns
///
- /// An `anyhow::Result<()>` indicating success or containing an error if the operation fails.
+ /// An `anyhow::Result<()>` indicating success or containing an error if the
+ /// operation fails.
pub fn extend_via_plan(
&mut self,
plan: BuildPlan,
@@ -652,7 +682,8 @@ impl FirehoseTableSchema {
///
/// # Returns
///
- /// An `Option` containing the index of the column if found, or `None` if not found.
+ /// An `Option` containing the index of the column if found, or
+ /// `None` if not found.
pub fn column_index(
&self,
name: &str,
@@ -673,7 +704,8 @@ impl FirehoseTableSchema {
///
/// # Returns
///
- /// An `anyhow::Result` containing the index of the column if it exists.
+ /// An `anyhow::Result` containing the index of the column if it
+ /// exists.
pub fn check_column_index(
&self,
name: &str,
@@ -687,9 +719,10 @@ impl FirehoseTableSchema {
#[cfg(test)]
mod tests {
- use super::*;
use indoc::indoc;
+ use super::*;
+
/// Ensures that `FirehoseTableSchema` is `Send`.
const FIREHOSE_TABLE_SCHEMA_IS_SEND: fn() = || {
fn assert_send() {}
diff --git a/crates/bimm-firehose/src/core/values.rs b/crates/bimm-firehose/src/core/values.rs
index 3c049b76..61b3e88c 100644
--- a/crates/bimm-firehose/src/core/values.rs
+++ b/crates/bimm-firehose/src/core/values.rs
@@ -1,10 +1,22 @@
-use anyhow::{Context, bail};
-use serde::Serialize;
-use serde::de::DeserializeOwned;
-use std::any::{Any, TypeId};
-use std::fmt::Debug;
-
-/// A wrapper type that can hold either a JSON value or a boxed value of any type.
+use std::{
+ any::{
+ Any,
+ TypeId,
+ },
+ fmt::Debug,
+};
+
+use anyhow::{
+ Context,
+ bail,
+};
+use serde::{
+ Serialize,
+ de::DeserializeOwned,
+};
+
+/// A wrapper type that can hold either a JSON value or a boxed value of any
+/// type.
pub enum FirehoseValue {
/// Holds a JSON value.
Value(serde_json::Value),
@@ -87,7 +99,8 @@ impl FirehoseValue {
FirehoseValue::Value(value)
}
- /// Creates a new `ValueBox::Boxed` by boxing an object that implements `Any` and `Send`.
+ /// Creates a new `ValueBox::Boxed` by boxing an object that implements
+ /// `Any` and `Send`.
pub fn boxing(obj: T) -> Self
where
T: Any + 'static + Send,
@@ -95,7 +108,8 @@ impl FirehoseValue {
Self::from_box(Box::new(obj))
}
- /// Creates a new `ValueBox::Boxed` from a boxed object that implements `Any` and `Send`.
+ /// Creates a new `ValueBox::Boxed` from a boxed object that implements
+ /// `Any` and `Send`.
pub fn from_box(boxed: Box) -> Self
where
T: Any + 'static + Send,
@@ -114,7 +128,8 @@ impl FirehoseValue {
matches!(self, FirehoseValue::Boxed(_))
}
- /// Unwraps the `ValueBox` and returns a reference to the contained JSON value.
+ /// Unwraps the `ValueBox` and returns a reference to the contained JSON
+ /// value.
pub fn unwrap_value(&self) -> &serde_json::Value {
if let FirehoseValue::Value(value) = self {
value
@@ -127,7 +142,8 @@ impl FirehoseValue {
///
/// # Type Parameters
///
- /// `T`: The type to deserialize the JSON value into. It must implement `DeserializeOwned`.
+ /// `T`: The type to deserialize the JSON value into. It must implement
+ /// `DeserializeOwned`.
///
/// # Panics
///
@@ -154,7 +170,8 @@ impl FirehoseValue {
///
/// # Type Parameters
///
- /// `T`: The type to deserialize the JSON value into. It must implement `DeserializeOwned`.
+ /// `T`: The type to deserialize the JSON value into. It must implement
+ /// `DeserializeOwned`.
///
/// # Panics
///
@@ -171,7 +188,8 @@ impl FirehoseValue {
self.parse_as::().unwrap()
}
- /// Unwraps the `ValueBox` and returns a reference to the contained boxed value.
+ /// Unwraps the `ValueBox` and returns a reference to the contained boxed
+ /// value.
///
/// # Type Parameters
///
@@ -201,7 +219,8 @@ impl FirehoseValue {
}
}
- /// Unwraps the `ValueBox` and returns a reference to the contained boxed value.
+ /// Unwraps the `ValueBox` and returns a reference to the contained boxed
+ /// value.
///
/// # Type Parameters
///
@@ -209,7 +228,8 @@ impl FirehoseValue {
///
/// # Panics
///
- /// If the `ValueBox` does not contain a boxed value or if the downcast fails.
+ /// If the `ValueBox` does not contain a boxed value or if the downcast
+ /// fails.
///
/// # Returns
///
diff --git a/crates/bimm-firehose/src/lib.rs b/crates/bimm-firehose/src/lib.rs
index 4942b8ed..69d50ae8 100644
--- a/crates/bimm-firehose/src/lib.rs
+++ b/crates/bimm-firehose/src/lib.rs
@@ -18,12 +18,13 @@ mod pipeline;
/// Define a self-referential ID.
///
-/// The id will be defined as a static string constant that refers to its own namespace path.
+/// The id will be defined as a static string constant that refers to its own
+/// namespace path.
///
/// # Arguments
///
-/// * `$name`: The final path name of the ID to define;
-/// the rest of the name will be taken from the module context.
+/// * `$name`: The final path name of the ID to define; the rest of the name
+/// will be taken from the module context.
///
/// # Example
/// ```
@@ -31,7 +32,6 @@ mod pipeline;
/// bimm_firehose::define_self_referential_id!(ID);
/// // pub static ID: &str = "foo::bar::ID";
/// ```
-///
#[macro_export]
macro_rules! define_self_referential_id {
($name:ident) => {
diff --git a/crates/bimm-firehose/src/ops/mod.rs b/crates/bimm-firehose/src/ops/mod.rs
index b3f5013e..f1f1eb08 100644
--- a/crates/bimm-firehose/src/ops/mod.rs
+++ b/crates/bimm-firehose/src/ops/mod.rs
@@ -1,5 +1,7 @@
-use crate::core::operations::environment::MapOpEnvironment;
-use crate::core::operations::registration::FirehoseOperatorFactoryRegistration;
+use crate::core::operations::{
+ environment::MapOpEnvironment,
+ registration::FirehoseOperatorFactoryRegistration,
+};
/// Build the default environment.
///
diff --git a/crates/bimm-firehose/src/pipeline/data_load_operator.rs b/crates/bimm-firehose/src/pipeline/data_load_operator.rs
index 38bc4ce5..4fd9ad9a 100644
--- a/crates/bimm-firehose/src/pipeline/data_load_operator.rs
+++ b/crates/bimm-firehose/src/pipeline/data_load_operator.rs
@@ -1,6 +1,7 @@
-use crate::pipeline::DataLoadMetaDataItem;
use std::fmt::Debug;
+use crate::pipeline::DataLoadMetaDataItem;
+
/// Support super-trait for loadable data types.
///
/// # Trait Requirements
@@ -10,7 +11,8 @@ use std::fmt::Debug;
/// - `Send` and `Sync`: the data item must be thread-safe.
pub trait DataLoadDataItem: Debug + Clone + Send + Sync {}
-/// Blanket implementation of `DataLoadDataItem` for any type that meets the requirements.
+/// Blanket implementation of `DataLoadDataItem` for any type that meets the
+/// requirements.
impl DataLoadDataItem for T where T: Debug + Clone + Send + Sync {}
/// Trait for data load operators.
@@ -23,7 +25,8 @@ where
///
/// # Arguments
///
- /// * `meta` - Metadata item that contains information needed to load the data.
+ /// * `meta` - Metadata item that contains information needed to load the
+ /// data.
///
/// # Returns
///
@@ -46,7 +49,8 @@ where
/// The function that defines how to load the data.
func: F,
- /// Phantom data to associate the operator with specific metadata and data types.
+ /// Phantom data to associate the operator with specific metadata and data
+ /// types.
phantom: std::marker::PhantomData<(M, T)>,
}
diff --git a/crates/bimm-firehose/src/pipeline/data_load_plan.rs b/crates/bimm-firehose/src/pipeline/data_load_plan.rs
index f04ff2e1..d234e39f 100644
--- a/crates/bimm-firehose/src/pipeline/data_load_plan.rs
+++ b/crates/bimm-firehose/src/pipeline/data_load_plan.rs
@@ -1,7 +1,14 @@
-use crate::pipeline::{DataLoadDataItem, DataLoadMetaDataItem, DataLoadOperator, DataLoadSchedule};
use std::sync::Arc;
-/// Represents a plan for loading data, including a schedule and an optional operator.
+use crate::pipeline::{
+ DataLoadDataItem,
+ DataLoadMetaDataItem,
+ DataLoadOperator,
+ DataLoadSchedule,
+};
+
+/// Represents a plan for loading data, including a schedule and an optional
+/// operator.
#[derive(Debug, Clone)]
pub struct DataLoadPlan
where
@@ -28,7 +35,8 @@ where
}
}
- /// Initializes a `DataLoadPlan` with a given schedule and an optional operator.
+ /// Initializes a `DataLoadPlan` with a given schedule and an optional
+ /// operator.
pub fn init(
schedule: DataLoadSchedule,
op: Option>>,
@@ -49,9 +57,10 @@ where
#[cfg(test)]
mod tests {
+ use std::sync::Arc;
+
use super::*;
use crate::pipeline::FnOperator;
- use std::sync::Arc;
#[test]
fn test_index_to_str_plan() {
diff --git a/crates/bimm-firehose/src/pipeline/data_load_schedule.rs b/crates/bimm-firehose/src/pipeline/data_load_schedule.rs
index 7136fb70..7d059c7e 100644
--- a/crates/bimm-firehose/src/pipeline/data_load_schedule.rs
+++ b/crates/bimm-firehose/src/pipeline/data_load_schedule.rs
@@ -1,21 +1,29 @@
-use serde::{Deserialize, Serialize};
-use std::fmt::Debug;
-use std::hash::Hash;
+use std::{
+ fmt::Debug,
+ hash::Hash,
+};
+
+use serde::{
+ Deserialize,
+ Serialize,
+};
/// A fixed schedule for loading data items.
///
-/// The type `M` must implement the `ScheduleItem` trait, which requires it to be
-/// Debug, Serialize, Sync, and Send safe.
+/// The type `M` must implement the `ScheduleItem` trait, which requires it to
+/// be Debug, Serialize, Sync, and Send safe.
///
/// # Motivation
///
-/// This structure is designed to hold the intermediate schedule for a data pipeline
-/// load operation; in a format which can be serialized and deserialized;
-/// and can be transformed into modified schedules without forcing a data load.
+/// This structure is designed to hold the intermediate schedule for a data
+/// pipeline load operation; in a format which can be serialized and
+/// deserialized; and can be transformed into modified schedules without forcing
+/// a data load.
///
/// As such, it is a thin wrapper around a `Vec`, where `M` carries complex
/// constraints; but the expectation is that additional metadata will be added
-/// to the schedule in the future (such as block size, or item load cost estimates).
+/// to the schedule in the future (such as block size, or item load cost
+/// estimates).
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(bound = "M: DataLoadMetaDataItem")]
pub struct DataLoadSchedule
@@ -28,9 +36,9 @@ where
/// Support super-trait for `DataLoadSchedule` items.
///
-/// This trait exists to simplify the requirements for items in a `DataLoadSchedule`;
-/// blanket implementations of `ScheduleItem` are provided for any type that meets
-/// the requirements.
+/// This trait exists to simplify the requirements for items in a
+/// `DataLoadSchedule`; blanket implementations of `ScheduleItem` are provided
+/// for any type that meets the requirements.
///
/// # Trait Requirements
///
@@ -38,13 +46,15 @@ where
/// - `Clone`: the schedule must be cloneable.
/// - `PartialEq` and `Eq`: the schedule must be comparable for equality.
/// - `Send` and `Sync`: the schedule must be thread-safe.
-/// - `Serialize` and `Deserialize`: the schedule must be serializable and deserializable.
+/// - `Serialize` and `Deserialize`: the schedule must be serializable and
+/// deserializable.
pub trait DataLoadMetaDataItem:
Debug + Clone + Hash + PartialEq + Eq + Send + Sync + Serialize + for<'de> Deserialize<'de>
{
}
-/// Blanket implementation of `ScheduleItem` for any type that meets the requirements.
+/// Blanket implementation of `ScheduleItem` for any type that meets the
+/// requirements.
impl DataLoadMetaDataItem for T where
T: Debug + Clone + Hash + PartialEq + Eq + Send + Sync + Serialize + for<'de> Deserialize<'de>
{
@@ -95,11 +105,13 @@ where
///
/// # Arguments
///
- /// - `predicate`: A closure that takes a reference to an item of type `M` and returns a boolean.
+ /// - `predicate`: A closure that takes a reference to an item of type `M`
+ /// and returns a boolean.
///
/// # Returns
///
- /// A new `DataLoadSchedule` containing only the items that match the predicate.
+ /// A new `DataLoadSchedule` containing only the items that match the
+ /// predicate.
pub fn filter
(
&self,
predicate: P,
@@ -121,15 +133,18 @@ where
/// Filters the items in the schedule based on a provided filter function,
/// and maps them to a new type `R` if the predicate returns `Some(R)`.
///
- /// This function is useful for transforming the schedule items while filtering them.
+ /// This function is useful for transforming the schedule items while
+ /// filtering them.
///
/// # Arguments
///
- /// - `predicate`: A closure that takes a reference to an item of type `M` and returns an `Option`.
+ /// - `predicate`: A closure that takes a reference to an item of type `M`
+ /// and returns an `Option`.
///
/// # Returns
///
- /// A new `DataLoadSchedule` containing the items that matched the predicate and were transformed to type `R`.
+ /// A new `DataLoadSchedule` containing the items that matched the
+ /// predicate and were transformed to type `R`.
pub fn filter_map