Documentation ¶
Overview ¶
Package testkeys provides facilities for generating and comparing human-readable test keys for use in tests and benchmarks. This package provides a single Comparer implementation that compares all keys generated by this package.
Keys generated by this package may optionally have a 'suffix' encoding an MVCC timestamp. This suffix is of the form "@<integer>". Comparisons on the suffix are performed using integer value, not the byte representation.
Index ¶
- Variables
- func Key(k Keyspace, i int) []byte
- func KeyAt(k Keyspace, i int, t int) []byte
- func ParseSuffix(s []byte) (int, error)
- func Suffix(t int) []byte
- func SuffixLen(t int) int
- func WriteKey(dst []byte, k Keyspace, i int) int
- func WriteKeyAt(dst []byte, k Keyspace, i int, t int) int
- func WriteSuffix(dst []byte, t int) int
- type Keyspace
Constants ¶
This section is empty.
Variables ¶
var Comparer *base.Comparer = &base.Comparer{ Compare: compare, Equal: func(a, b []byte) bool { return compare(a, b) == 0 }, AbbreviatedKey: func(k []byte) uint64 { return base.DefaultComparer.AbbreviatedKey(k[:split(k)]) }, FormatKey: base.DefaultFormatter, Separator: func(dst, a, b []byte) []byte { ai := split(a) if ai == len(a) { return append(dst, a...) } bi := split(b) if bi == len(b) { return append(dst, a...) } if bytes.Equal(a[:ai], b[:bi]) { return append(dst, a...) } n := len(dst) dst = base.DefaultComparer.Separator(dst, a[:ai], b[:bi]) buf := dst[n:] if bytes.Equal(a[:ai], buf) { return append(dst[:n], a...) } return append(dst, 0) }, Successor: func(dst, a []byte) []byte { ai := split(a) if ai == len(a) { return append(dst, a...) } n := len(dst) dst = base.DefaultComparer.Successor(dst, a[:ai]) buf := dst[n:] if bytes.Equal(a[:ai], buf) { return append(dst[:n], a...) } return append(dst, 0) }, Split: split, Name: "pebble.internal.testkeys", }
Comparer is the comparer for test keys generated by this package.
MaxSuffixLen is the maximum length of a suffix generated by this package.
Functions ¶
func ParseSuffix ¶
ParseSuffix returns the integer representation of the encoded suffix.
func WriteKey ¶
WriteKey writes the i-th unsuffixed key within the keyspace to the buffer dst. It returns the number of bytes written.
func WriteKeyAt ¶
WriteKeyAt writes the i-th key within the keyspace to the buffer dst, with a suffix encoding the timestamp t suffix. It returns the number of bytes written.
func WriteSuffix ¶
WriteSuffix writes the test keys suffix representation of timestamp t to dst, returning the number of bytes written.
Types ¶
type Keyspace ¶
type Keyspace interface { // Count returns the number of keys that exist within this keyspace. Count() int // MaxLen returns the maximum length, in bytes, of a key within this // keyspace. This is only guaranteed to return an upper bound. MaxLen() int // Slice returns the sub-keyspace from index i, inclusive, to index j, // exclusive. The receiver is unmodified. Slice(i, j int) Keyspace // EveryN returns a key space that includes 1 key for every N keys in the // original keyspace. The receiver is unmodified. EveryN(n int) Keyspace // contains filtered or unexported methods }
Keyspace describes a finite keyspace of unsuffixed test keys.