本文整理汇总了Golang中github.com/cockroachdb/cockroach/pkg/roachpb.RKey函数的典型用法代码示例。如果您正苦于以下问题:Golang RKey函数的具体用法?Golang RKey怎么用?Golang RKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RKey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestRangeIterForward
func TestRangeIterForward(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
cfg := DistSenderConfig{
RangeDescriptorDB: alphaRangeDescriptorDB,
}
ctx := context.Background()
g := makeGossip(t, stopper)
ds := NewDistSender(cfg, g)
ri := NewRangeIterator(ds, false /*reverse*/)
i := 0
for ri.Seek(ctx, roachpb.RKey(roachpb.KeyMin)); ri.Valid(); ri.Next(ctx) {
if !reflect.DeepEqual(alphaRangeDescriptors[i], ri.Desc()) {
t.Fatalf("%d: expected %v; got %v", i, alphaRangeDescriptors[i], ri.Desc())
}
i++
if !ri.NeedAnother(roachpb.RSpan{
EndKey: roachpb.RKey([]byte("z")),
}) {
break
}
}
}
开发者ID:knz,项目名称:cockroach,代码行数:27,代码来源:range_iter_test.go
示例2: TestRangeIterReverse
func TestRangeIterReverse(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
g, clock := makeGossip(t, stopper)
ds := NewDistSender(DistSenderConfig{
Clock: clock,
RangeDescriptorDB: alphaRangeDescriptorDB,
}, g)
ctx := context.Background()
ri := NewRangeIterator(ds, true /*reverse*/)
i := len(alphaRangeDescriptors) - 1
for ri.Seek(ctx, roachpb.RKey([]byte{'z'})); ri.Valid(); ri.Next(ctx) {
if !reflect.DeepEqual(alphaRangeDescriptors[i], ri.Desc()) {
t.Fatalf("%d: expected %v; got %v", i, alphaRangeDescriptors[i], ri.Desc())
}
i--
if !ri.NeedAnother(roachpb.RSpan{
Key: roachpb.RKey(roachpb.KeyMin),
}) {
break
}
}
}
开发者ID:bdarnell,项目名称:cockroach,代码行数:27,代码来源:range_iter_test.go
示例3: Addr
// Addr returns the address for the key, used to lookup the range containing
// the key. In the normal case, this is simply the key's value. However, for
// local keys, such as transaction records, range-spanning binary tree node
// pointers, the address is the inner encoded key, with the local key prefix
// and the suffix and optional detail removed. This address unwrapping is
// performed repeatedly in the case of doubly-local keys. In this way, local
// keys address to the same range as non-local keys, but are stored separately
// so that they don't collide with user-space or global system keys.
//
// However, not all local keys are addressable in the global map. Only range
// local keys incorporating a range key (start key or transaction key) are
// addressable (e.g. range metadata and txn records). Range local keys
// incorporating the Range ID are not (e.g. abort cache entries, and range
// stats).
func Addr(k roachpb.Key) (roachpb.RKey, error) {
if !IsLocal(k) {
return roachpb.RKey(k), nil
}
for {
if bytes.HasPrefix(k, localStorePrefix) {
return nil, errors.Errorf("store-local key %q is not addressable", k)
}
if bytes.HasPrefix(k, LocalRangeIDPrefix) {
return nil, errors.Errorf("local range ID key %q is not addressable", k)
}
if !bytes.HasPrefix(k, LocalRangePrefix) {
return nil, errors.Errorf("local key %q malformed; should contain prefix %q",
k, LocalRangePrefix)
}
k = k[len(LocalRangePrefix):]
var err error
// Decode the encoded key, throw away the suffix and detail.
if _, k, err = encoding.DecodeBytesAscending(k, nil); err != nil {
return nil, err
}
if !bytes.HasPrefix(k, localPrefix) {
break
}
}
return roachpb.RKey(k), nil
}
开发者ID:knz,项目名称:cockroach,代码行数:42,代码来源:keys.go
示例4: TestRangeIterForward
func TestRangeIterForward(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
g, clock := makeGossip(t, stopper)
ds := NewDistSender(DistSenderConfig{
Clock: clock,
RangeDescriptorDB: alphaRangeDescriptorDB,
}, g)
ctx := context.Background()
ri := NewRangeIterator(ds)
i := 0
span := roachpb.RSpan{
Key: roachpb.RKey(roachpb.KeyMin),
EndKey: roachpb.RKey([]byte("z")),
}
for ri.Seek(ctx, span.Key, Ascending); ri.Valid(); ri.Next(ctx) {
if !reflect.DeepEqual(alphaRangeDescriptors[i], ri.Desc()) {
t.Fatalf("%d: expected %v; got %v", i, alphaRangeDescriptors[i], ri.Desc())
}
i++
if !ri.NeedAnother(span) {
break
}
}
}
开发者ID:veteranlu,项目名称:cockroach,代码行数:29,代码来源:range_iter_test.go
示例5: TestRangeIterSeekReverse
func TestRangeIterSeekReverse(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
g, clock := makeGossip(t, stopper)
ds := NewDistSender(DistSenderConfig{
Clock: clock,
RangeDescriptorDB: alphaRangeDescriptorDB,
}, g)
ctx := context.Background()
ri := NewRangeIterator(ds)
i := len(alphaRangeDescriptors) - 1
for ri.Seek(ctx, roachpb.RKey([]byte{'z'}), Descending); ri.Valid(); {
if !reflect.DeepEqual(alphaRangeDescriptors[i], ri.Desc()) {
t.Fatalf("%d: expected %v; got %v", i, alphaRangeDescriptors[i], ri.Desc())
}
i -= 2
// Skip every other range.
nextByte := ri.Desc().StartKey[0] - 1
if nextByte <= byte('a') {
break
}
seekKey := roachpb.RKey([]byte{nextByte})
ri.Seek(ctx, seekKey, Descending)
if !ri.Key().Equal(seekKey) {
t.Errorf("expected iterator key %s; got %s", seekKey, ri.Key())
}
}
}
开发者ID:veteranlu,项目名称:cockroach,代码行数:32,代码来源:range_iter_test.go
示例6: TestRangeIterSeekForward
func TestRangeIterSeekForward(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
g, clock := makeGossip(t, stopper)
ds := NewDistSender(DistSenderConfig{
Clock: clock,
RangeDescriptorDB: alphaRangeDescriptorDB,
}, g)
ctx := context.Background()
ri := NewRangeIterator(ds, false /*reverse*/)
i := 0
for ri.Seek(ctx, roachpb.RKey(roachpb.KeyMin)); ri.Valid(); {
if !reflect.DeepEqual(alphaRangeDescriptors[i], ri.Desc()) {
t.Fatalf("%d: expected %v; got %v", i, alphaRangeDescriptors[i], ri.Desc())
}
i += 2
// Skip even ranges.
nextByte := ri.Desc().EndKey[0] + 1
if nextByte >= byte('z') {
break
}
seekKey := roachpb.RKey([]byte{nextByte})
ri.Seek(ctx, seekKey)
if !ri.Key().Equal(seekKey) {
t.Errorf("expected iterator key %s; got %s", seekKey, ri.Key())
}
}
}
开发者ID:bdarnell,项目名称:cockroach,代码行数:32,代码来源:range_iter_test.go
示例7: TestComputeStatsForKeySpan
func TestComputeStatsForKeySpan(t *testing.T) {
defer leaktest.AfterTest(t)()
mtc := &multiTestContext{}
defer mtc.Stop()
mtc.Start(t, 3)
// Create a number of ranges using splits.
splitKeys := []string{"a", "c", "e", "g", "i"}
for _, k := range splitKeys {
key := []byte(k)
repl := mtc.stores[0].LookupReplica(key, roachpb.RKeyMin)
args := adminSplitArgs(key, key)
header := roachpb.Header{
RangeID: repl.RangeID,
}
if _, err := client.SendWrappedWith(context.Background(), mtc.stores[0], header, args); err != nil {
t.Fatal(err)
}
}
// Wait for splits to finish.
testutils.SucceedsSoon(t, func() error {
repl := mtc.stores[0].LookupReplica(roachpb.RKey("z"), nil)
if actualRSpan := repl.Desc().RSpan(); !actualRSpan.Key.Equal(roachpb.RKey("i")) {
return errors.Errorf("expected range %s to begin at key 'i'", repl)
}
return nil
})
// Create some keys across the ranges.
incKeys := []string{"b", "bb", "bbb", "d", "dd", "h"}
for _, k := range incKeys {
if _, err := mtc.dbs[0].Inc(context.TODO(), []byte(k), 5); err != nil {
t.Fatal(err)
}
}
// Verify stats across different spans.
for _, tcase := range []struct {
startKey string
endKey string
expectedRanges int
expectedKeys int64
}{
{"a", "i", 4, 6},
{"a", "c", 1, 3},
{"b", "e", 2, 5},
{"e", "i", 2, 1},
} {
start, end := tcase.startKey, tcase.endKey
stats, count := mtc.stores[0].ComputeStatsForKeySpan(
roachpb.RKey(start), roachpb.RKey(end))
if a, e := count, tcase.expectedRanges; a != e {
t.Errorf("Expected %d ranges in span [%s - %s], found %d", e, start, end, a)
}
if a, e := stats.LiveCount, tcase.expectedKeys; a != e {
t.Errorf("Expected %d keys in span [%s - %s], found %d", e, start, end, a)
}
}
}
开发者ID:BramGruneir,项目名称:cockroach,代码行数:60,代码来源:client_status_test.go
示例8: newTestRangeSet
// newTestRangeSet creates a new range set that has the count number of ranges.
func newTestRangeSet(count int, t *testing.T) *testRangeSet {
rs := &testRangeSet{replicasByKey: btree.New(64 /* degree */)}
for i := 0; i < count; i++ {
desc := &roachpb.RangeDescriptor{
RangeID: roachpb.RangeID(i),
StartKey: roachpb.RKey(fmt.Sprintf("%03d", i)),
EndKey: roachpb.RKey(fmt.Sprintf("%03d", i+1)),
}
// Initialize the range stat so the scanner can use it.
repl := &Replica{
RangeID: desc.RangeID,
}
repl.mu.TimedMutex = syncutil.MakeTimedMutex(defaultMuLogger)
repl.cmdQMu.TimedMutex = syncutil.MakeTimedMutex(defaultMuLogger)
repl.mu.state.Stats = enginepb.MVCCStats{
KeyBytes: 1,
ValBytes: 2,
KeyCount: 1,
LiveCount: 1,
}
if err := repl.setDesc(desc); err != nil {
t.Fatal(err)
}
if exRngItem := rs.replicasByKey.ReplaceOrInsert(repl); exRngItem != nil {
t.Fatalf("failed to insert range %s", repl)
}
}
return rs
}
开发者ID:BramGruneir,项目名称:cockroach,代码行数:31,代码来源:scanner_test.go
示例9: TestUpdateRangeAddressingSplitMeta1
// TestUpdateRangeAddressingSplitMeta1 verifies that it's an error to
// attempt to update range addressing records that would allow a split
// of meta1 records.
func TestUpdateRangeAddressingSplitMeta1(t *testing.T) {
defer leaktest.AfterTest(t)()
left := &roachpb.RangeDescriptor{StartKey: roachpb.RKeyMin, EndKey: meta1Key(roachpb.RKey("a"))}
right := &roachpb.RangeDescriptor{StartKey: meta1Key(roachpb.RKey("a")), EndKey: roachpb.RKeyMax}
if err := splitRangeAddressing(&client.Batch{}, left, right); err == nil {
t.Error("expected failure trying to update addressing records for meta1 split")
}
}
开发者ID:knz,项目名称:cockroach,代码行数:11,代码来源:addressing_test.go
示例10: TestBatchPrevNext
// TestBatchPrevNext tests batch.{Prev,Next}.
func TestBatchPrevNext(t *testing.T) {
defer leaktest.AfterTest(t)()
loc := func(s string) string {
return string(keys.RangeDescriptorKey(roachpb.RKey(s)))
}
span := func(strs ...string) []roachpb.Span {
var r []roachpb.Span
for i, str := range strs {
if i%2 == 0 {
r = append(r, roachpb.Span{Key: roachpb.Key(str)})
} else {
r[len(r)-1].EndKey = roachpb.Key(str)
}
}
return r
}
max, min := string(roachpb.RKeyMax), string(roachpb.RKeyMin)
abc := span("a", "", "b", "", "c", "")
testCases := []struct {
spans []roachpb.Span
key, expFW, expBW string
}{
{spans: span("a", "c", "b", ""), key: "b", expFW: "b", expBW: "b"},
{spans: span("a", "c", "b", ""), key: "a", expFW: "a", expBW: "a"},
{spans: span("a", "c", "d", ""), key: "c", expFW: "d", expBW: "c"},
{spans: span("a", "c\x00", "d", ""), key: "c", expFW: "c", expBW: "c"},
{spans: abc, key: "b", expFW: "b", expBW: "b"},
{spans: abc, key: "b\x00", expFW: "c", expBW: "b\x00"},
{spans: abc, key: "bb", expFW: "c", expBW: "b"},
{spans: span(), key: "whatevs", expFW: max, expBW: min},
{spans: span(loc("a"), loc("c")), key: "c", expFW: "c", expBW: "c"},
{spans: span(loc("a"), loc("c")), key: "c\x00", expFW: max, expBW: "c\x00"},
}
for i, test := range testCases {
var ba roachpb.BatchRequest
for _, span := range test.spans {
args := &roachpb.ScanRequest{}
args.Key, args.EndKey = span.Key, span.EndKey
ba.Add(args)
}
if next, err := next(ba, roachpb.RKey(test.key)); err != nil {
t.Errorf("%d: %v", i, err)
} else if !bytes.Equal(next, roachpb.Key(test.expFW)) {
t.Errorf("%d: next: expected %q, got %q", i, test.expFW, next)
}
if prev, err := prev(ba, roachpb.RKey(test.key)); err != nil {
t.Errorf("%d: %v", i, err)
} else if !bytes.Equal(prev, roachpb.Key(test.expBW)) {
t.Errorf("%d: prev: expected %q, got %q", i, test.expBW, prev)
}
}
}
开发者ID:knz,项目名称:cockroach,代码行数:54,代码来源:batch_test.go
示例11: TestGCQueueLastProcessedTimestamps
func TestGCQueueLastProcessedTimestamps(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
stopper := stop.NewStopper()
defer stopper.Stop()
tc.Start(t, stopper)
// Create two last processed times both at the range start key and
// also at some mid-point key in order to simulate a merge.
// Two transactions.
lastProcessedVals := []struct {
key roachpb.Key
expGC bool
}{
{keys.QueueLastProcessedKey(roachpb.RKeyMin, "timeSeriesMaintenance"), false},
{keys.QueueLastProcessedKey(roachpb.RKeyMin, "replica consistency checker"), false},
{keys.QueueLastProcessedKey(roachpb.RKey("a"), "timeSeriesMaintenance"), true},
{keys.QueueLastProcessedKey(roachpb.RKey("b"), "replica consistency checker"), true},
}
ts := tc.Clock().Now()
for _, lpv := range lastProcessedVals {
if err := engine.MVCCPutProto(context.Background(), tc.engine, nil, lpv.key, hlc.ZeroTimestamp, nil, &ts); err != nil {
t.Fatal(err)
}
}
cfg, ok := tc.gossip.GetSystemConfig()
if !ok {
t.Fatal("config not set")
}
// Process through a scan queue.
gcQ := newGCQueue(tc.store, tc.gossip)
if err := gcQ.process(context.Background(), tc.repl, cfg); err != nil {
t.Fatal(err)
}
// Verify GC.
testutils.SucceedsSoon(t, func() error {
for _, lpv := range lastProcessedVals {
ok, err := engine.MVCCGetProto(context.Background(), tc.engine, lpv.key, hlc.ZeroTimestamp, true, nil, &ts)
if err != nil {
return err
}
if ok == lpv.expGC {
return errors.Errorf("expected GC of %s: %t; got %t", lpv.key, lpv.expGC, ok)
}
}
return nil
})
}
开发者ID:BramGruneir,项目名称:cockroach,代码行数:52,代码来源:gc_queue_test.go
示例12: TransactionKey
// TransactionKey returns a transaction key based on the provided
// transaction key and ID. The base key is encoded in order to
// guarantee that all transaction records for a range sort together.
func TransactionKey(key roachpb.Key, txnID *uuid.UUID) roachpb.Key {
rk, err := Addr(key)
if err != nil {
panic(err)
}
return MakeRangeKey(rk, localTransactionSuffix, roachpb.RKey(txnID.GetBytes()))
}
开发者ID:knz,项目名称:cockroach,代码行数:10,代码来源:keys.go
示例13: TestBatchPrevNextWithNoop
func TestBatchPrevNextWithNoop(t *testing.T) {
defer leaktest.AfterTest(t)()
leftKey := roachpb.Key("a")
middleKey := roachpb.RKey("b")
rightKey := roachpb.Key("c")
var ba roachpb.BatchRequest
ba.Add(&roachpb.GetRequest{Span: roachpb.Span{Key: leftKey}})
ba.Add(&roachpb.NoopRequest{})
ba.Add(&roachpb.GetRequest{Span: roachpb.Span{Key: rightKey}})
t.Run("prev", func(t *testing.T) {
rk, err := prev(ba, middleKey)
if err != nil {
t.Fatal(err)
}
if !rk.Equal(leftKey) {
t.Errorf("got %s, expected %s", rk, leftKey)
}
})
t.Run("next", func(t *testing.T) {
rk, err := next(ba, middleKey)
if err != nil {
t.Fatal(err)
}
if !rk.Equal(rightKey) {
t.Errorf("got %s, expected %s", rk, rightKey)
}
})
}
开发者ID:BramGruneir,项目名称:cockroach,代码行数:30,代码来源:batch_test.go
示例14: TestObjectIDForKey
func TestObjectIDForKey(t *testing.T) {
defer leaktest.AfterTest(t)()
testCases := []struct {
key roachpb.RKey
success bool
id uint32
}{
// Before the structured span.
{roachpb.RKeyMin, false, 0},
// Boundaries of structured span.
{roachpb.RKeyMax, false, 0},
// Valid, even if there are things after the ID.
{testutils.MakeKey(keys.MakeTablePrefix(42), roachpb.RKey("\xff")), true, 42},
{keys.MakeTablePrefix(0), true, 0},
{keys.MakeTablePrefix(999), true, 999},
}
for tcNum, tc := range testCases {
id, success := config.ObjectIDForKey(tc.key)
if success != tc.success {
t.Errorf("#%d: expected success=%t", tcNum, tc.success)
continue
}
if id != tc.id {
t.Errorf("#%d: expected id=%d, got %d", tcNum, tc.id, id)
}
}
}
开发者ID:nvanbenschoten,项目名称:cockroach,代码行数:31,代码来源:config_test.go
示例15: localRangeIDKeyParse
func localRangeIDKeyParse(input string) (remainder string, key roachpb.Key) {
var rangeID int64
var err error
input = mustShiftSlash(input)
if endPos := strings.Index(input, "/"); endPos > 0 {
rangeID, err = strconv.ParseInt(input[:endPos], 10, 64)
if err != nil {
panic(err)
}
input = input[endPos:]
} else {
panic(errors.Errorf("illegal RangeID: %q", input))
}
input = mustShiftSlash(input)
var infix string
infix, input = mustShift(input)
var replicated bool
switch {
case bytes.Equal(localRangeIDUnreplicatedInfix, []byte(infix)):
case bytes.Equal(localRangeIDReplicatedInfix, []byte(infix)):
replicated = true
default:
panic(errors.Errorf("invalid infix: %q", infix))
}
input = mustShiftSlash(input)
// Get the suffix.
var suffix roachpb.RKey
for _, s := range rangeIDSuffixDict {
if strings.HasPrefix(input, s.name) {
input = input[len(s.name):]
if s.psFunc != nil {
remainder, key = s.psFunc(roachpb.RangeID(rangeID), input)
return
}
suffix = roachpb.RKey(s.suffix)
break
}
}
maker := MakeRangeIDUnreplicatedKey
if replicated {
maker = MakeRangeIDReplicatedKey
}
if suffix != nil {
if input != "" {
panic(&errUglifyUnsupported{errors.New("nontrivial detail")})
}
var detail roachpb.RKey
// TODO(tschottdorf): can't do this, init cycle:
// detail, err := UglyPrint(input)
// if err != nil {
// return "", nil, err
// }
remainder = ""
key = maker(roachpb.RangeID(rangeID), suffix, detail)
return
}
panic(&errUglifyUnsupported{errors.New("unhandled general range key")})
}
开发者ID:knz,项目名称:cockroach,代码行数:59,代码来源:printer.go
示例16: TestUserKey
func TestUserKey(t *testing.T) {
testCases := []struct {
key, expKey roachpb.RKey
}{
{
key: roachpb.RKeyMin,
expKey: roachpb.RKey(Meta1Prefix),
},
{
key: roachpb.RKey("\x02\x04zonefoo"),
expKey: roachpb.RKey("\x03\x04zonefoo"),
},
{
key: roachpb.RKey("\x03foo"),
expKey: roachpb.RKey("foo"),
},
{
key: roachpb.RKey("foo"),
expKey: roachpb.RKey("foo"),
},
}
for i, test := range testCases {
result := UserKey(test.key)
if !bytes.Equal(result, test.expKey) {
t.Errorf("%d: expected range meta for key %q doesn't match %q (%q)",
i, test.key, test.expKey, result)
}
}
}
开发者ID:hvaara,项目名称:cockroach,代码行数:29,代码来源:keys_test.go
示例17: init
func init() {
lastKey := roachpb.RKey(keys.MinKey)
for i, b := 0, byte('a'); b <= byte('z'); i, b = i+1, b+1 {
key := roachpb.RKey([]byte{b})
alphaRangeDescriptors = append(alphaRangeDescriptors, &roachpb.RangeDescriptor{
RangeID: roachpb.RangeID(i + 2),
StartKey: lastKey,
EndKey: key,
Replicas: []roachpb.ReplicaDescriptor{
{
NodeID: 1,
StoreID: 1,
},
},
})
lastKey = key
}
}
开发者ID:veteranlu,项目名称:cockroach,代码行数:18,代码来源:range_iter_test.go
示例18: TestKeyAddress
func TestKeyAddress(t *testing.T) {
testCases := []struct {
key roachpb.Key
expAddress roachpb.RKey
}{
{roachpb.Key{}, roachpb.RKeyMin},
{roachpb.Key("123"), roachpb.RKey("123")},
{RangeDescriptorKey(roachpb.RKey("foo")), roachpb.RKey("foo")},
{TransactionKey(roachpb.Key("baz"), uuid.MakeV4()), roachpb.RKey("baz")},
{TransactionKey(roachpb.KeyMax, uuid.MakeV4()), roachpb.RKeyMax},
{RangeDescriptorKey(roachpb.RKey(TransactionKey(roachpb.Key("doubleBaz"), uuid.MakeV4()))), roachpb.RKey("doubleBaz")},
{nil, nil},
}
for i, test := range testCases {
if keyAddr, err := Addr(test.key); err != nil {
t.Errorf("%d: %v", i, err)
} else if !keyAddr.Equal(test.expAddress) {
t.Errorf("%d: expected address for key %q doesn't match %q", i, test.key, test.expAddress)
}
}
}
开发者ID:hvaara,项目名称:cockroach,代码行数:21,代码来源:keys_test.go
示例19: TestRangeSplitMeta
// TestRangeSplitMeta executes various splits (including at meta addressing)
// and checks that all created intents are resolved. This includes both intents
// which are resolved synchronously with EndTransaction and via RPC.
func TestRangeSplitMeta(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := createTestDB(t)
defer s.Stop()
splitKeys := []roachpb.RKey{roachpb.RKey("G"), mustMeta(roachpb.RKey("F")),
mustMeta(roachpb.RKey("K")), mustMeta(roachpb.RKey("H"))}
// Execute the consecutive splits.
for _, splitKey := range splitKeys {
log.Infof(context.Background(), "starting split at key %q...", splitKey)
if err := s.DB.AdminSplit(context.TODO(), roachpb.Key(splitKey)); err != nil {
t.Fatal(err)
}
log.Infof(context.Background(), "split at key %q complete", splitKey)
}
testutils.SucceedsSoon(t, func() error {
if _, _, _, err := engine.MVCCScan(context.Background(), s.Eng, keys.LocalMax, roachpb.KeyMax, math.MaxInt64, hlc.MaxTimestamp, true, nil); err != nil {
return errors.Errorf("failed to verify no dangling intents: %s", err)
}
return nil
})
}
开发者ID:BramGruneir,项目名称:cockroach,代码行数:27,代码来源:split_test.go
示例20: UserKey
// UserKey returns an ordinary key for the given range metadata (meta1, meta2)
// indexing key.
//
// - For RKeyMin, Meta1Prefix is returned.
// - For a meta1 key, a meta2 key is returned.
// - For a meta2 key, an ordinary key is returned.
// - For an ordinary key, the input key is returned.
func UserKey(key roachpb.RKey) roachpb.RKey {
if len(key) == 0 { // key.Equal(roachpb.RKeyMin)
return roachpb.RKey(Meta1Prefix)
}
var prefix roachpb.Key
switch key[0] {
case meta1PrefixByte:
prefix = Meta2Prefix
key = key[len(Meta1Prefix):]
case meta2PrefixByte:
key = key[len(Meta2Prefix):]
}
buf := make(roachpb.RKey, 0, len(prefix)+len(key))
buf = append(buf, prefix...)
buf = append(buf, key...)
return buf
}
开发者ID:knz,项目名称:cockroach,代码行数:25,代码来源:keys.go
注:本文中的github.com/cockroachdb/cockroach/pkg/roachpb.RKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论