Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 committed May 31, 2024
1 parent b137425 commit 7cc5325
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
6 changes: 1 addition & 5 deletions pkg/executor/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,7 @@ func (e *CleanupIndexExec) getIdxColTypes() []*types.FieldType {

func (e *CleanupIndexExec) batchGetRecord(txn kv.Transaction) (map[string][]byte, error) {
e.idxValues.Range(func(h kv.Handle, _ any) bool {
if ph, ok := h.(kv.PartitionHandle); ok {
e.batchKeys = append(e.batchKeys, tablecodec.EncodeRecordKey(tablecodec.GenTableRecordPrefix(ph.PartitionID), ph.Handle))
} else {
e.batchKeys = append(e.batchKeys, tablecodec.EncodeRecordKey(e.table.RecordPrefix(), h))
}
e.batchKeys = append(e.batchKeys, tablecodec.EncodeRecordKey(e.table.RecordPrefix(), h))
return true
})
values, err := txn.BatchGet(context.Background(), e.batchKeys)
Expand Down
29 changes: 4 additions & 25 deletions pkg/tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func CutRowKeyPrefix(key kv.Key) []byte {
// EncodeRecordKey encodes the recordPrefix, row handle into a kv.Key.
func EncodeRecordKey(recordPrefix kv.Key, h kv.Handle) kv.Key {
buf := make([]byte, 0, len(recordPrefix)+h.Len())
if ph, ok := h.(kv.PartitionHandle); ok {
recordPrefix = GenTableRecordPrefix(ph.PartitionID)
}
buf = append(buf, recordPrefix...)
buf = append(buf, h.Encoded()...)
return buf
Expand Down Expand Up @@ -1678,31 +1681,7 @@ func encodeCommonHandle(idxVal []byte, h kv.Handle) []byte {

// DecodeHandleInUniqueIndexValue decodes handle in data.
func DecodeHandleInUniqueIndexValue(data []byte, isCommonHandle bool) (kv.Handle, error) {
if !isCommonHandle {
dLen := len(data)
if dLen <= MaxOldEncodeValueLen {
return kv.IntHandle(int64(binary.BigEndian.Uint64(data))), nil
}
return kv.IntHandle(int64(binary.BigEndian.Uint64(data[dLen-int(data[0]):]))), nil
}
if getIndexVersion(data) == 1 {
seg := splitIndexValueForClusteredIndexVersion1(data)
h, err := kv.NewCommonHandle(seg.CommonHandle)
if err != nil {
return nil, err
}
return h, nil
}

tailLen := int(data[0])
data = data[:len(data)-tailLen]
handleLen := uint16(data[2])<<8 + uint16(data[3])
handleEndOff := 4 + handleLen
h, err := kv.NewCommonHandle(data[4:handleEndOff])
if err != nil {
return nil, err
}
return h, nil
return decodeHandleInIndexValue(data)
}

func encodePartitionID(idxVal []byte, partitionID int64) []byte {
Expand Down

0 comments on commit 7cc5325

Please sign in to comment.