A better way is to separate UU/US/SU/SS into different signatures at the planning stage instead of execution stage, i.e. func (c *arithmeticPlusFunctionClass) getFunction. A separation in getFunction can benefit both TiDB execution and TiKV execution, which can make the code simple, keep TiKV pure (no function deduction logic) and make execution slightly faster.
To finish this task, you need to:
Modify tipb to introduce 4 new signatures, like:
builtinArithmeticPlusIntUnsignedUnsigned
builtinArithmeticPlusIntUnsignedSigned
...
(for compatibility consideration, builtinArithmeticPlusInt should be kept in tipb so that TiKV can still support old TiDB)
Modify the func (c *arithmeticPlusFunctionClass) getFunction to introduce dispatch logic, dispatching to the new 4 signatures according to the operator's unsigned flag.
Implement the new 4 function signature (and their vectorized version) by copying and refining code from the original function signature.
Optionally, you may consider modifying TiKV code base as well, to support these 4 newly added signatures. This will be in a separated task in TiKV side.
Description
Currently for the PlusInt built-in function, TiDB executes different logic according to whether LHS and RHS is signed or unsigned:
func (b *builtinArithmeticPlusIntSig) plusUU
func (b *builtinArithmeticPlusIntSig) plusUS
func (b *builtinArithmeticPlusIntSig) plusSU
func (b *builtinArithmeticPlusIntSig) plusSS
The actual logic is determined in
func (b *builtinArithmeticPlusIntSig) vecEvalInt
, i.e. re-checked every 1024 rows.Meanwhile, at TiKV side, TiKV also does the same thing in the function signature mapper:
A better way is to separate UU/US/SU/SS into different signatures at the planning stage instead of execution stage, i.e.
func (c *arithmeticPlusFunctionClass) getFunction
. A separation ingetFunction
can benefit both TiDB execution and TiKV execution, which can make the code simple, keep TiKV pure (no function deduction logic) and make execution slightly faster.To finish this task, you need to:
Modify tipb to introduce 4 new signatures, like:
(for compatibility consideration,
builtinArithmeticPlusInt
should be kept in tipb so that TiKV can still support old TiDB)Modify the
func (c *arithmeticPlusFunctionClass) getFunction
to introduce dispatch logic, dispatching to the new 4 signatures according to the operator's unsigned flag.Implement the new 4 function signature (and their vectorized version) by copying and refining code from the original function signature.
Optionally, you may consider modifying TiKV code base as well, to support these 4 newly added signatures. This will be in a separated task in TiKV side.
Difficulty
Score
Mentor(s)
Recommended Skills