MCPcopy
hub / github.com/pingcap/tidb / IsUntouchedIndexKValue

Function IsUntouchedIndexKValue

pkg/tablecodec/tablecodec.go:1165–1184  ·  view source on GitHub ↗

IsUntouchedIndexKValue uses to check whether the key is index key, and the value is untouched, since the untouched index key/value is no need to commit.

(k, v []byte)

Source from the content-addressed store, hash-verified

1163// IsUntouchedIndexKValue uses to check whether the key is index key, and the value is untouched,
1164// since the untouched index key/value is no need to commit.
1165func IsUntouchedIndexKValue(k, v []byte) bool {
1166 if !IsIndexKey(k) {
1167 return false
1168 }
1169 vLen := len(v)
1170 if IsTempIndexKey(k) {
1171 return vLen > 0 && v[vLen-1] == kv.UnCommitIndexKVFlag
1172 }
1173 if vLen <= MaxOldEncodeValueLen {
1174 return (vLen == 1 || vLen == 9) && v[vLen-1] == kv.UnCommitIndexKVFlag
1175 }
1176 // New index value format
1177 tailLen := int(v[0])
1178 if tailLen < 8 {
1179 // Non-unique index.
1180 return tailLen >= 1 && v[vLen-1] == kv.UnCommitIndexKVFlag
1181 }
1182 // Unique index
1183 return tailLen == 9
1184}
1185
1186// GenTablePrefix composes table record and index prefix: "t[tableID]".
1187func GenTablePrefix(tableID int64) kv.Key {

Callers 3

IsUnnecessaryKeyValueMethod · 0.92
KeyNeedToLockFunction · 0.92
TestUntouchedIndexKValueFunction · 0.85

Calls 2

IsIndexKeyFunction · 0.85
IsTempIndexKeyFunction · 0.85

Tested by 1

TestUntouchedIndexKValueFunction · 0.68