pub trait VTable:
'static
+ Sized
+ Send
+ Sync {
type Instance: 'static + Send + Sync + Debug + PartialEq + Eq + Hash;
Show 14 methods
// Required methods
fn id(&self) -> ExprId;
fn validate(&self, expr: &ExpressionView<'_, Self>) -> VortexResult<()>;
fn child_name(
&self,
_instance: &Self::Instance,
child_idx: usize,
) -> ChildName;
fn fmt_sql(
&self,
expr: &ExpressionView<'_, Self>,
f: &mut Formatter<'_>,
) -> Result;
fn return_dtype(
&self,
expr: &ExpressionView<'_, Self>,
scope: &DType,
) -> VortexResult<DType>;
fn evaluate(
&self,
expr: &ExpressionView<'_, Self>,
scope: &ArrayRef,
) -> VortexResult<ArrayRef>;
// Provided methods
fn serialize(
&self,
_instance: &Self::Instance,
) -> VortexResult<Option<Vec<u8>>> { ... }
fn deserialize(
&self,
_metadata: &[u8],
) -> VortexResult<Option<Self::Instance>> { ... }
fn fmt_data(
&self,
instance: &Self::Instance,
f: &mut Formatter<'_>,
) -> Result { ... }
fn stat_falsification(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression> { ... }
fn stat_max(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression> { ... }
fn stat_min(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression> { ... }
fn stat_nan_count(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression> { ... }
fn stat_field_path(
&self,
_expr: &ExpressionView<'_, Self>,
) -> Option<FieldPath> { ... }
}Expand description
This trait defines the interface for expression vtables, including methods for serialization, deserialization, validation, child naming, return type computation, and evaluation.
This trait is non-object safe and allows the implementer to make use of associated types for improved type safety, while allowing Vortex to enforce runtime checks on the inputs and outputs of each function.
The VTable trait should be implemented for a struct that holds global data across
all instances of the expression. In almost all cases, this struct will be an empty unit
struct, since most expressions do not require any global state.
Required Associated Types§
Required Methods§
Sourcefn validate(&self, expr: &ExpressionView<'_, Self>) -> VortexResult<()>
fn validate(&self, expr: &ExpressionView<'_, Self>) -> VortexResult<()>
Validate the metadata and children for the expression.
Sourcefn child_name(&self, _instance: &Self::Instance, child_idx: usize) -> ChildName
fn child_name(&self, _instance: &Self::Instance, child_idx: usize) -> ChildName
Returns the name of the nth child of the expr.
Sourcefn fmt_sql(
&self,
expr: &ExpressionView<'_, Self>,
f: &mut Formatter<'_>,
) -> Result
fn fmt_sql( &self, expr: &ExpressionView<'_, Self>, f: &mut Formatter<'_>, ) -> Result
Format this expression in nice human-readable SQL-style format
The implementation should recursively format child expressions by calling
expr.child(i).fmt_sql(f).
Sourcefn return_dtype(
&self,
expr: &ExpressionView<'_, Self>,
scope: &DType,
) -> VortexResult<DType>
fn return_dtype( &self, expr: &ExpressionView<'_, Self>, scope: &DType, ) -> VortexResult<DType>
Compute the return DType of the expression if evaluated in the given scope.
Sourcefn evaluate(
&self,
expr: &ExpressionView<'_, Self>,
scope: &ArrayRef,
) -> VortexResult<ArrayRef>
fn evaluate( &self, expr: &ExpressionView<'_, Self>, scope: &ArrayRef, ) -> VortexResult<ArrayRef>
Evaluate the expression in the given scope.
Provided Methods§
Sourcefn serialize(&self, _instance: &Self::Instance) -> VortexResult<Option<Vec<u8>>>
fn serialize(&self, _instance: &Self::Instance) -> VortexResult<Option<Vec<u8>>>
Serialize the metadata for the expression.
Should return Ok(None) if the expression is not serializable, and Ok(vec![]) if it is
serializable but has no metadata.
Sourcefn deserialize(&self, _metadata: &[u8]) -> VortexResult<Option<Self::Instance>>
fn deserialize(&self, _metadata: &[u8]) -> VortexResult<Option<Self::Instance>>
Deserialize an instance of this expression.
Returns Ok(None) if the expression is not serializable.
Sourcefn fmt_data(&self, instance: &Self::Instance, f: &mut Formatter<'_>) -> Result
fn fmt_data(&self, instance: &Self::Instance, f: &mut Formatter<'_>) -> Result
Format only the instance data for this expression.
Defaults to a debug representation of the instance data.
Sourcefn stat_falsification(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
fn stat_falsification( &self, _expr: &ExpressionView<'_, Self>, _catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
Sourcefn stat_max(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
fn stat_max( &self, _expr: &ExpressionView<'_, Self>, _catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
Sourcefn stat_min(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
fn stat_min( &self, _expr: &ExpressionView<'_, Self>, _catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
Sourcefn stat_nan_count(
&self,
_expr: &ExpressionView<'_, Self>,
_catalog: &mut dyn StatsCatalog,
) -> Option<Expression>
fn stat_nan_count( &self, _expr: &ExpressionView<'_, Self>, _catalog: &mut dyn StatsCatalog, ) -> Option<Expression>
Sourcefn stat_field_path(&self, _expr: &ExpressionView<'_, Self>) -> Option<FieldPath>
fn stat_field_path(&self, _expr: &ExpressionView<'_, Self>) -> Option<FieldPath>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.