Documentation
¶
Overview ¶
Package crdbtest provides facilities for representing keys, workloads, etc representative of CockroachDB's use of Pebble.
Index ¶
- Constants
- Variables
- func AppendTimestamp(key []byte, walltime uint64, logical uint32) []byte
- func Compare(a, b []byte) int
- func ComparePointSuffixes(a, b []byte) int
- func CompareRangeSuffixes(a, b []byte) int
- func DecodeEngineKey(b []byte) (roachKey, version []byte, ok bool)
- func EncodeMVCCKey(dst []byte, key []byte, walltime uint64, logical uint32) []byte
- func EncodeTimestamp(key []byte, walltime uint64, logical uint32) []byte
- func Equal(a, b []byte) bool
- func Split(key []byte) int
Constants ¶
const MaxSuffixLen = 1 + max(
engineKeyVersionLockTableLen,
engineKeyVersionWallLogicalAndSyntheticTimeLen,
engineKeyVersionWallAndLogicalTimeLen,
engineKeyVersionWallTimeLen,
)
MaxSuffixLen is the maximum length of the CockroachDB key suffix.
Variables ¶
var Comparer = base.Comparer{ Split: Split, ComparePointSuffixes: ComparePointSuffixes, CompareRangeSuffixes: CompareRangeSuffixes, Compare: Compare, Equal: Equal, AbbreviatedKey: func(k []byte) uint64 { key, ok := getKeyPartFromEngineKey(k) if !ok { return 0 } return base.DefaultComparer.AbbreviatedKey(key) }, FormatKey: base.DefaultFormatter, Separator: func(dst, a, b []byte) []byte { aKey, ok := getKeyPartFromEngineKey(a) if !ok { return append(dst, a...) } bKey, ok := getKeyPartFromEngineKey(b) if !ok { return append(dst, a...) } if bytes.Equal(aKey, bKey) { return append(dst, a...) } n := len(dst) dst = base.DefaultComparer.Separator(dst, aKey, bKey) buf := dst[n:] if bytes.Equal(aKey, buf) { return append(dst[:n], a...) } return append(dst, 0) }, Successor: func(dst, a []byte) []byte { aKey, ok := getKeyPartFromEngineKey(a) if !ok { return append(dst, a...) } n := len(dst) dst = base.DefaultComparer.Successor(dst, aKey) buf := dst[n:] if bytes.Equal(aKey, buf) { return append(dst[:n], a...) } return append(dst, 0) }, ImmediateSuccessor: func(dst, a []byte) []byte { return append(append(dst, a...), 0) }, Name: "cockroach_comparator", }
Comparer is a base.Comparer for CockroachDB keys.
var KeySchema = colblk.KeySchema{ Name: "crdb1", HeaderSize: 1, ColumnTypes: []colblk.DataType{ // contains filtered or unexported fields }, NewKeyWriter: func() colblk.KeyWriter { return makeCockroachKeyWriter() }, InitKeySeekerMetadata: func(meta *colblk.KeySeekerMetadata, d *colblk.DataBlockDecoder) { ks := (*cockroachKeySeeker)(unsafe.Pointer(meta)) ks.init(d) }, KeySeeker: func(meta *colblk.KeySeekerMetadata) colblk.KeySeeker { return (*cockroachKeySeeker)(unsafe.Pointer(meta)) }, }
Functions ¶
func AppendTimestamp ¶
AppendTimestamp appends an encoded MVCC timestamp onto key, returning the new key. The provided key should already have the 0x00 sentinel byte (i.e., key should be a proper prefix from the perspective of Pebble).
func Compare ¶
Compare compares cockroach keys, including the version (which could be MVCC timestamps).
func ComparePointSuffixes ¶
ComparePointSuffixes compares point key suffixes (normally timestamps).
func CompareRangeSuffixes ¶
CompareRangeSuffixes compares range key suffixes (normally timestamps).
func DecodeEngineKey ¶
DecodeEngineKey decodes the given bytes as an EngineKey.
func EncodeMVCCKey ¶
EncodeMVCCKey encodes a MVCC key into dst, growing dst as necessary.
func EncodeTimestamp ¶
EncodeTimestamp encodes a MVCC timestamp into a key, returning the new key. The key's capacity must be sufficiently large to hold the encoded timestamp.
Types ¶
This section is empty.