mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-03-28 21:10:23 +08:00
style(key format): consist "key" format
This commit is contained in:
parent
025ae17724
commit
a90df284ed
@ -88,10 +88,10 @@ func IsRaftStateKey(key []byte) bool {
|
||||
|
||||
func DecodeRegionMetaKey(key []byte) (uint64, byte, error) {
|
||||
if len(RegionMetaMinKey)+8+1 != len(key) {
|
||||
return 0, 0, errors.Errorf("invalid region meta key length for key %v", key)
|
||||
return 0, 0, errors.Errorf("invalid region meta key length for key %s", key)
|
||||
}
|
||||
if !bytes.HasPrefix(key, RegionMetaMinKey) {
|
||||
return 0, 0, errors.Errorf("invalid region meta key prefix for key %v", key)
|
||||
return 0, 0, errors.Errorf("invalid region meta key prefix for key %s", key)
|
||||
}
|
||||
regionID := binary.BigEndian.Uint64(key[len(RegionMetaMinKey):])
|
||||
return regionID, key[len(key)-1], nil
|
||||
@ -117,7 +117,7 @@ func RegionStateKey(regionID uint64) []byte {
|
||||
/// RaftLogIndex gets the log index from raft log key generated by `raft_log_key`.
|
||||
func RaftLogIndex(key []byte) (uint64, error) {
|
||||
if len(key) != RegionRaftLogLen {
|
||||
return 0, errors.Errorf("key %v is not a valid raft log key", key)
|
||||
return 0, errors.Errorf("key %s is not a valid raft log key", key)
|
||||
}
|
||||
return binary.BigEndian.Uint64(key[RegionRaftLogLen-8:]), nil
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -132,10 +131,10 @@ func (snapCtx *snapContext) handleApply(regionId uint64, notifier chan<- bool, s
|
||||
func (snapCtx *snapContext) cleanUpRange(regionId uint64, startKey, endKey []byte) {
|
||||
if err := engine_util.DeleteRange(snapCtx.engines.Kv, startKey, endKey); err != nil {
|
||||
log.Fatalf("failed to delete data in range, [regionId: %d, startKey: %s, endKey: %s, err: %v]", regionId,
|
||||
hex.EncodeToString(startKey), hex.EncodeToString(endKey), err)
|
||||
startKey, endKey, err)
|
||||
} else {
|
||||
log.Infof("succeed in deleting data in range. [regionId: %d, startKey: %s, endKey: %s]", regionId,
|
||||
hex.EncodeToString(startKey), hex.EncodeToString(endKey))
|
||||
startKey, endKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/Connor1996/badger"
|
||||
"github.com/pingcap-incubator/tinykv/kv/config"
|
||||
"github.com/pingcap-incubator/tinykv/kv/raftstore/message"
|
||||
@ -43,7 +41,7 @@ func (r *splitCheckHandler) Handle(t worker.Task) {
|
||||
region := spCheckTask.Region
|
||||
regionId := region.Id
|
||||
log.Debugf("executing split check worker.Task: [regionId: %d, startKey: %s, endKey: %s]", regionId,
|
||||
hex.EncodeToString(region.StartKey), hex.EncodeToString(region.EndKey))
|
||||
region.StartKey, region.EndKey)
|
||||
key := r.splitCheck(regionId, region.StartKey, region.EndKey)
|
||||
if key != nil {
|
||||
_, userKey, err := codec.DecodeBytes(key)
|
||||
|
@ -31,7 +31,7 @@ type ErrKeyNotInRegion struct {
|
||||
}
|
||||
|
||||
func (e *ErrKeyNotInRegion) Error() string {
|
||||
return fmt.Sprintf("key %v is not in region %v", e.Key, e.Region)
|
||||
return fmt.Sprintf("key %s is not in region %v", e.Key, e.Region)
|
||||
}
|
||||
|
||||
type ErrEpochNotMatch struct {
|
||||
|
@ -3,7 +3,6 @@ package test_raftstore
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
@ -274,7 +273,7 @@ func (c *Cluster) GetRegion(key []byte) *metapb.Region {
|
||||
// retry to get the region again.
|
||||
SleepMS(20)
|
||||
}
|
||||
panic(fmt.Sprintf("find no region for %s", hex.EncodeToString(key)))
|
||||
panic(fmt.Sprintf("find no region for %s", key))
|
||||
}
|
||||
|
||||
func (c *Cluster) GetRandomRegion() *metapb.Region {
|
||||
|
@ -2,7 +2,6 @@ package test_raftstore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@ -100,7 +99,7 @@ func MustGetCf(engine *engine_util.Engines, cf string, key []byte, value []byte)
|
||||
}
|
||||
SleepMS(20)
|
||||
}
|
||||
panic(fmt.Sprintf("can't get value %s for key %s", hex.EncodeToString(value), hex.EncodeToString(key)))
|
||||
panic(fmt.Sprintf("can't get value %s for key %s", value, key))
|
||||
}
|
||||
|
||||
func MustGetCfEqual(engine *engine_util.Engines, cf string, key []byte, value []byte) {
|
||||
@ -121,7 +120,7 @@ func MustGetCfNone(engine *engine_util.Engines, cf string, key []byte) {
|
||||
}
|
||||
SleepMS(20)
|
||||
}
|
||||
panic(fmt.Sprintf("get value %s for key %s", hex.EncodeToString(val), hex.EncodeToString(key)))
|
||||
panic(fmt.Sprintf("get value %s for key %s", val, key))
|
||||
}
|
||||
|
||||
func MustGetNone(engine *engine_util.Engines, key []byte) {
|
||||
|
Loading…
Reference in New Issue
Block a user