Upgrade versions of vendored libs
This commit is contained in:
76
vendor/github.com/cockroachdb/pebble/internal/rangekey/coalesce.go
generated
vendored
76
vendor/github.com/cockroachdb/pebble/internal/rangekey/coalesce.go
generated
vendored
@@ -6,6 +6,7 @@ package rangekey
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
@@ -367,3 +368,78 @@ func coalesce(
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ForeignSSTTransformer implements a keyspan.Transformer for range keys in
|
||||
// foreign sstables (i.e. shared sstables not created by us). It is largely
|
||||
// similar to the Transform function implemented in UserIteratorConfig in that
|
||||
// it calls coalesce to remove range keys shadowed by other range keys, but also
|
||||
// retains the range key that does the shadowing. In addition, it elides
|
||||
// RangeKey unsets/dels in L6 as they are inapplicable when reading from a
|
||||
// different Pebble instance.
|
||||
type ForeignSSTTransformer struct {
|
||||
Comparer *base.Comparer
|
||||
Level int
|
||||
sortBuf keyspan.KeysBySuffix
|
||||
}
|
||||
|
||||
// Transform implements the Transformer interface.
|
||||
func (f *ForeignSSTTransformer) Transform(
|
||||
cmp base.Compare, s keyspan.Span, dst *keyspan.Span,
|
||||
) error {
|
||||
// Apply shadowing of keys.
|
||||
dst.Start = s.Start
|
||||
dst.End = s.End
|
||||
f.sortBuf = keyspan.KeysBySuffix{
|
||||
Cmp: cmp,
|
||||
Keys: f.sortBuf.Keys[:0],
|
||||
}
|
||||
if err := coalesce(f.Comparer.Equal, &f.sortBuf, math.MaxUint64, s.Keys); err != nil {
|
||||
return err
|
||||
}
|
||||
keys := f.sortBuf.Keys
|
||||
dst.Keys = dst.Keys[:0]
|
||||
for i := range keys {
|
||||
seqNum := keys[i].SeqNum()
|
||||
switch keys[i].Kind() {
|
||||
case base.InternalKeyKindRangeKeySet:
|
||||
if invariants.Enabled && len(dst.Keys) > 0 && cmp(dst.Keys[len(dst.Keys)-1].Suffix, keys[i].Suffix) > 0 {
|
||||
panic("pebble: keys unexpectedly not in ascending suffix order")
|
||||
}
|
||||
switch f.Level {
|
||||
case 5:
|
||||
fallthrough
|
||||
case 6:
|
||||
if seqNum != base.SeqNumForLevel(f.Level) {
|
||||
panic(fmt.Sprintf("pebble: expected range key iter to return seqnum %d, got %d", base.SeqNumForLevel(f.Level), seqNum))
|
||||
}
|
||||
}
|
||||
case base.InternalKeyKindRangeKeyUnset:
|
||||
if invariants.Enabled && len(dst.Keys) > 0 && cmp(dst.Keys[len(dst.Keys)-1].Suffix, keys[i].Suffix) > 0 {
|
||||
panic("pebble: keys unexpectedly not in ascending suffix order")
|
||||
}
|
||||
fallthrough
|
||||
case base.InternalKeyKindRangeKeyDelete:
|
||||
switch f.Level {
|
||||
case 5:
|
||||
// Emit this key.
|
||||
if seqNum != base.SeqNumForLevel(f.Level) {
|
||||
panic(fmt.Sprintf("pebble: expected range key iter to return seqnum %d, got %d", base.SeqNumForLevel(f.Level), seqNum))
|
||||
}
|
||||
case 6:
|
||||
// Skip this key, as foreign sstable in L6 do not need to emit range key
|
||||
// unsets/dels as they do not apply to any other sstables.
|
||||
continue
|
||||
}
|
||||
default:
|
||||
return base.CorruptionErrorf("pebble: unrecognized range key kind %s", keys[i].Kind())
|
||||
}
|
||||
dst.Keys = append(dst.Keys, keyspan.Key{
|
||||
Trailer: base.MakeTrailer(seqNum, keys[i].Kind()),
|
||||
Suffix: keys[i].Suffix,
|
||||
Value: keys[i].Value,
|
||||
})
|
||||
}
|
||||
// coalesce results in dst.Keys being sorted by Suffix.
|
||||
dst.KeysOrder = keyspan.BySuffixAsc
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user