DecodeRowKey decodes the key and gets the handle.
(key kv.Key)
| 328 | |
| 329 | // DecodeRowKey decodes the key and gets the handle. |
| 330 | func DecodeRowKey(key kv.Key) (kv.Handle, error) { |
| 331 | if len(key) < RecordRowKeyLen || !hasTablePrefix(key) || !hasRecordPrefixSep(key[prefixLen-2:]) { |
| 332 | return kv.IntHandle(0), errInvalidKey.GenWithStack("invalid key - %q", key) |
| 333 | } |
| 334 | if len(key) == RecordRowKeyLen { |
| 335 | u := binary.BigEndian.Uint64(key[prefixLen:]) |
| 336 | return kv.IntHandle(codec.DecodeCmpUintToInt(u)), nil |
| 337 | } |
| 338 | return kv.NewCommonHandle(key[prefixLen:]) |
| 339 | } |
| 340 | |
| 341 | // EncodeValue encodes a go value to bytes. |
| 342 | // This function may return both a valid encoded bytes and an error (actually `"pingcap/errors".ErrorGroup`). If the caller |