ReHashCode is used after we change the argument in place.
(sf *ScalarFunction)
| 726 | |
| 727 | // ReHashCode is used after we change the argument in place. |
| 728 | func ReHashCode(sf *ScalarFunction) { |
| 729 | sf.hashcode = sf.hashcode[:0] |
| 730 | sf.hashcode = append(sf.hashcode, scalarFunctionFlag) |
| 731 | sf.hashcode = codec.EncodeCompactBytes(sf.hashcode, hack.Slice(sf.FuncName.L)) |
| 732 | for _, arg := range sf.GetArgs() { |
| 733 | sf.hashcode = append(sf.hashcode, arg.HashCode()...) |
| 734 | } |
| 735 | // Cast is a special case. The RetType should also be considered as an argument. |
| 736 | // Please see `newFunctionImpl()` for detail. |
| 737 | if sf.FuncName.L == ast.Cast { |
| 738 | evalTp := sf.RetType.EvalType() |
| 739 | sf.hashcode = append(sf.hashcode, byte(evalTp)) |
| 740 | } |
| 741 | if sf.FuncName.L == ast.Grouping { |
| 742 | sf.hashcode = codec.EncodeInt(sf.hashcode, int64(sf.Function.(*BuiltinGroupingImplSig).GetGroupingMode())) |
| 743 | marks := sf.Function.(*BuiltinGroupingImplSig).GetMetaGroupingMarks() |
| 744 | sf.hashcode = codec.EncodeInt(sf.hashcode, int64(len(marks))) |
| 745 | for _, mark := range marks { |
| 746 | sf.hashcode = codec.EncodeInt(sf.hashcode, int64(len(mark))) |
| 747 | // we need to sort map keys to ensure the hashcode is deterministic. |
| 748 | keys := make([]uint64, 0, len(mark)) |
| 749 | for k := range mark { |
| 750 | keys = append(keys, k) |
| 751 | } |
| 752 | slices.Sort(keys) |
| 753 | for _, k := range keys { |
| 754 | sf.hashcode = codec.EncodeInt(sf.hashcode, int64(k)) |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | // ResolveIndices implements Expression interface. |
| 761 | func (sf *ScalarFunction) ResolveIndices(schema *Schema) (Expression, error) { |
no test coverage detected
searching dependent graphs…