本文整理匯總了Golang中github.com/cockroachdb/cockroach/roachpb.Timestamp.Logical方法的典型用法代碼示例。如果您正苦於以下問題:Golang Timestamp.Logical方法的具體用法?Golang Timestamp.Logical怎麽用?Golang Timestamp.Logical使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/roachpb.Timestamp
的用法示例。
在下文中一共展示了Timestamp.Logical方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestBatchBuilderStress
func TestBatchBuilderStress(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop()
e := NewInMem(roachpb.Attributes{}, 1<<20, stopper)
rng, _ := randutil.NewPseudoRand()
for i := 0; i < 1000; i++ {
count := 1 + rng.Intn(1000)
func() {
batch := e.NewBatch().(*rocksDBBatch)
defer batch.Close()
builder := &rocksDBBatchBuilder{}
for j := 0; j < count; j++ {
var ts roachpb.Timestamp
if rng.Float32() <= 0.9 {
// Give 90% of keys timestamps.
ts.WallTime = rng.Int63()
if rng.Float32() <= 0.1 {
// Give 10% of timestamps a non-zero logical component.
ts.Logical = rng.Int31()
}
}
key := MVCCKey{
Key: []byte(fmt.Sprintf("%d", rng.Intn(10000))),
Timestamp: ts,
}
// Generate a random mixture of puts, deletes and merges.
switch rng.Intn(3) {
case 0:
if err := dbPut(batch.batch, key, []byte("value")); err != nil {
t.Fatal(err)
}
builder.Put(key, []byte("value"))
case 1:
if err := dbClear(batch.batch, key); err != nil {
t.Fatal(err)
}
builder.Clear(key)
case 2:
if err := dbMerge(batch.batch, key, appender("bar")); err != nil {
t.Fatal(err)
}
builder.Merge(key, appender("bar"))
}
}
batchRepr := batch.Repr()
builderRepr := builder.Finish()
if !bytes.Equal(batchRepr, builderRepr) {
t.Fatalf("expected [% x], but got [% x]", batchRepr, builderRepr)
}
}()
}
}