MCPcopy Create free account
hub / github.com/pingcap/tidb / ReHashCode

Function ReHashCode

pkg/expression/scalar_function.go:728–758  ·  view source on GitHub ↗

ReHashCode is used after we change the argument in place.

(sf *ScalarFunction)

Source from the content-addressed store, hash-verified

726
727// ReHashCode is used after we change the argument in place.
728func 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.
761func (sf *ScalarFunction) ResolveIndices(schema *Schema) (Expression, error) {

Callers 2

substituteExpressionFunction · 0.92
HashCodeMethod · 0.85

Calls 9

EncodeCompactBytesFunction · 0.92
SliceFunction · 0.92
EncodeIntFunction · 0.92
GetArgsMethod · 0.80
EvalTypeMethod · 0.80
GetGroupingModeMethod · 0.80
GetMetaGroupingMarksMethod · 0.80
HashCodeMethod · 0.65
SortMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…