Skip to content

Commit

Permalink
Add the reason of not implementing ConcreteAggFunctionState
Browse files Browse the repository at this point in the history
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
  • Loading branch information
sticnarf committed May 27, 2019
1 parent b08c791 commit 2920306
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions src/coprocessor/dag/aggr_fn/impl_first.rs
Expand Up @@ -102,39 +102,8 @@ where
}
}

// default impl all `Evaluable` for all `AggrFnStateFirst` to make `AggrFnStateFirst`
// satisfy trait `AggrFunctionState`
impl<T1, T2> super::AggrFunctionStateUpdatePartial<T1> for AggrFnStateFirst<T2>
where
T1: Evaluable,
T2: Evaluable,
VectorValue: VectorValueExt<T2>,
{
#[inline]
default fn update(&mut self, _ctx: &mut EvalContext, _value: &Option<T1>) -> Result<()> {
panic!("Unmatched parameter type")
}

#[inline]
default fn update_repeat(
&mut self,
_ctx: &mut EvalContext,
_value: &Option<T1>,
_repeat_times: usize,
) -> Result<()> {
panic!("Unmatched parameter type")
}

#[inline]
default fn update_vector(
&mut self,
_ctx: &mut EvalContext,
_values: &[Option<T1>],
) -> Result<()> {
panic!("Unmatched parameter type")
}
}

// Here we manually implement `AggrFunctionStateUpdatePartial` instead of implementing
// `ConcreteAggrFunctionState` so that `update_repeat` and `update_vector` can be faster.
impl<T> super::AggrFunctionStateUpdatePartial<T> for AggrFnStateFirst<T>
where
T: Evaluable,
Expand Down Expand Up @@ -169,6 +138,39 @@ where
}
}

// In order to make `AggrFnStateFirst` satisfy the `AggrFunctionState` trait, we default impl all
// `AggrFunctionStateUpdatePartial` of `Evaluable` for all `AggrFnStateFirst`.
impl<T1, T2> super::AggrFunctionStateUpdatePartial<T1> for AggrFnStateFirst<T2>
where
T1: Evaluable,
T2: Evaluable,
VectorValue: VectorValueExt<T2>,
{
#[inline]
default fn update(&mut self, _ctx: &mut EvalContext, _value: &Option<T1>) -> Result<()> {
panic!("Unmatched parameter type")
}

#[inline]
default fn update_repeat(
&mut self,
_ctx: &mut EvalContext,
_value: &Option<T1>,
_repeat_times: usize,
) -> Result<()> {
panic!("Unmatched parameter type")
}

#[inline]
default fn update_vector(
&mut self,
_ctx: &mut EvalContext,
_values: &[Option<T1>],
) -> Result<()> {
panic!("Unmatched parameter type")
}
}

impl<T> super::AggrFunctionState for AggrFnStateFirst<T>
where
T: Evaluable,
Expand Down

0 comments on commit 2920306

Please sign in to comment.