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

Function DecodeIndexKey

pkg/tablecodec/tablecodec.go:180–198  ·  view source on GitHub ↗

DecodeIndexKey decodes the key and gets the tableID, indexID, indexValues.

(key kv.Key)

Source from the content-addressed store, hash-verified

178
179// DecodeIndexKey decodes the key and gets the tableID, indexID, indexValues.
180func DecodeIndexKey(key kv.Key) (tableID int64, indexID int64, indexValues []string, err error) {
181 k := key
182
183 tableID, indexID, isRecord, err := DecodeKeyHead(key)
184 if err != nil {
185 return 0, 0, nil, errors.Trace(err)
186 }
187 if isRecord {
188 err = errInvalidIndexKey.GenWithStack("invalid index key - %q", k)
189 return 0, 0, nil, err
190 }
191 indexKey := key[prefixLen+idLen:]
192 indexValues, err = DecodeValuesBytesToStrings(indexKey)
193 if err != nil {
194 err = errInvalidIndexKey.GenWithStack("invalid index key - %q %v", k, err)
195 return 0, 0, nil, err
196 }
197 return tableID, indexID, indexValues, nil
198}
199
200// DecodeValuesBytesToStrings decode the raw bytes to strings for each columns.
201// FIXME: Without the schema information, we can only decode the raw kind of

Callers 11

decodeIndexKeyMethod · 0.92
prettyWriteKeyFunction · 0.92
DecodeKeyFunction · 0.92
decodeIndexIDFunction · 0.92
TestDecodeIndexKeyFunction · 0.85

Calls 2

DecodeKeyHeadFunction · 0.85

Tested by 2

TestDecodeIndexKeyFunction · 0.68