From 29203062108463d32fdc5e3ab36c6b3aad490c2a Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Mon, 27 May 2019 16:12:41 +0800 Subject: [PATCH] Add the reason of not implementing ConcreteAggFunctionState Signed-off-by: Yilin Chen --- src/coprocessor/dag/aggr_fn/impl_first.rs | 68 ++++++++++++----------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/coprocessor/dag/aggr_fn/impl_first.rs b/src/coprocessor/dag/aggr_fn/impl_first.rs index 63fc465ff5b..bc197855dea 100644 --- a/src/coprocessor/dag/aggr_fn/impl_first.rs +++ b/src/coprocessor/dag/aggr_fn/impl_first.rs @@ -102,39 +102,8 @@ where } } -// default impl all `Evaluable` for all `AggrFnStateFirst` to make `AggrFnStateFirst` -// satisfy trait `AggrFunctionState` -impl super::AggrFunctionStateUpdatePartial for AggrFnStateFirst -where - T1: Evaluable, - T2: Evaluable, - VectorValue: VectorValueExt, -{ - #[inline] - default fn update(&mut self, _ctx: &mut EvalContext, _value: &Option) -> Result<()> { - panic!("Unmatched parameter type") - } - - #[inline] - default fn update_repeat( - &mut self, - _ctx: &mut EvalContext, - _value: &Option, - _repeat_times: usize, - ) -> Result<()> { - panic!("Unmatched parameter type") - } - - #[inline] - default fn update_vector( - &mut self, - _ctx: &mut EvalContext, - _values: &[Option], - ) -> 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 super::AggrFunctionStateUpdatePartial for AggrFnStateFirst where T: Evaluable, @@ -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 super::AggrFunctionStateUpdatePartial for AggrFnStateFirst +where + T1: Evaluable, + T2: Evaluable, + VectorValue: VectorValueExt, +{ + #[inline] + default fn update(&mut self, _ctx: &mut EvalContext, _value: &Option) -> Result<()> { + panic!("Unmatched parameter type") + } + + #[inline] + default fn update_repeat( + &mut self, + _ctx: &mut EvalContext, + _value: &Option, + _repeat_times: usize, + ) -> Result<()> { + panic!("Unmatched parameter type") + } + + #[inline] + default fn update_vector( + &mut self, + _ctx: &mut EvalContext, + _values: &[Option], + ) -> Result<()> { + panic!("Unmatched parameter type") + } +} + impl super::AggrFunctionState for AggrFnStateFirst where T: Evaluable,