Upgrade versions of vendored libs
This commit is contained in:
83
vendor/github.com/cockroachdb/pebble/internal/keyspan/interleaving_iter.go
generated
vendored
83
vendor/github.com/cockroachdb/pebble/internal/keyspan/interleaving_iter.go
generated
vendored
@@ -29,9 +29,9 @@ type SpanMask interface {
|
||||
SpanChanged(*Span)
|
||||
// SkipPoint is invoked by the interleaving iterator whenever the iterator
|
||||
// encounters a point key covered by a Span. If SkipPoint returns true, the
|
||||
// interleaving iterator skips the point key without returning it. This is
|
||||
// used during range key iteration to skip over point keys 'masked' by range
|
||||
// keys.
|
||||
// interleaving iterator skips the point key and all larger keys with the
|
||||
// same prefix. This is used during range key iteration to skip over point
|
||||
// keys 'masked' by range keys.
|
||||
SkipPoint(userKey []byte) bool
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ type SpanMask interface {
|
||||
// SeekGE or SeekPrefixGE search key. Consider, for example SetBounds('c', 'e'),
|
||||
// with an iterator containing the Span [a,z):
|
||||
//
|
||||
// First() = `c#72057594037927935,21` Span() = [c,e)
|
||||
// SeekGE('d') = `d#72057594037927935,21` Span() = [c,e)
|
||||
// First() = `c#72057594037927935,21` Span() = [c,e)
|
||||
// SeekGE('d') = `d#72057594037927935,21` Span() = [c,e)
|
||||
//
|
||||
// InterleavedIter does not interleave synthetic markers for spans that do not
|
||||
// contain any keys.
|
||||
//
|
||||
// SpanMask
|
||||
// # SpanMask
|
||||
//
|
||||
// InterelavingIter takes a SpanMask parameter that may be used to configure the
|
||||
// behavior of the iterator. See the documentation on the SpanMask type.
|
||||
@@ -479,6 +479,30 @@ func (i *InterleavingIter) Next() (*base.InternalKey, base.LazyValue) {
|
||||
return i.interleaveForward(i.lower, nil /* prefix */)
|
||||
}
|
||||
|
||||
// NextPrefix implements (base.InternalIterator).NextPrefix.
|
||||
func (i *InterleavingIter) NextPrefix(succKey []byte) (*base.InternalKey, base.LazyValue) {
|
||||
if i.dir == -1 {
|
||||
panic("pebble: cannot switch directions with NextPrefix")
|
||||
}
|
||||
|
||||
// Refresh the point key if the current point key has already been
|
||||
// interleaved, OR if the next uninterleaved point key has the old suffix
|
||||
// (it's less than succKey).
|
||||
if i.pointKeyInterleaved || (i.pointKey != nil && i.cmp(i.pointKey.UserKey, succKey) < 0) {
|
||||
i.pointKey, i.pointVal = i.pointIter.NextPrefix(succKey)
|
||||
i.pointKeyInterleaved = false
|
||||
}
|
||||
// If we already interleaved the current span start key, and the point key
|
||||
// is ≥ the span's end key, move to the next span.
|
||||
if i.keyspanInterleaved && i.pointKey != nil && i.span != nil &&
|
||||
i.cmp(i.pointKey.UserKey, i.span.End) >= 0 {
|
||||
i.span = i.keyspanIter.Next()
|
||||
i.checkForwardBound(nil)
|
||||
i.savedKeyspan()
|
||||
}
|
||||
return i.interleaveForward(i.lower, nil)
|
||||
}
|
||||
|
||||
// Prev implements (base.InternalIterator).Prev.
|
||||
func (i *InterleavingIter) Prev() (*base.InternalKey, base.LazyValue) {
|
||||
if i.dir == +1 {
|
||||
@@ -677,9 +701,29 @@ func (i *InterleavingIter) interleaveForward(
|
||||
// if we have stepped outside of the span last saved as a mask,
|
||||
// so that the decision to skip is made with the correct
|
||||
// knowledge of the covering span.
|
||||
i.maybeUpdateMask(true /*covered */)
|
||||
i.maybeUpdateMask(true /* covered */)
|
||||
|
||||
if i.mask != nil && i.mask.SkipPoint(i.pointKey.UserKey) {
|
||||
if i.prefix {
|
||||
// During prefix-iteration node, once a point is masked,
|
||||
// all subsequent keys with the same prefix must also be
|
||||
// masked according to the key ordering. We can stop and
|
||||
// return nil.
|
||||
//
|
||||
// NB: The above is not just an optimization. During
|
||||
// prefix-iteration mode, the internal iterator contract
|
||||
// prohibits us from Next-ing beyond the first key
|
||||
// beyond the iteration prefix. If we didn't already
|
||||
// stop early, we would need to check if this masked
|
||||
// point is already beyond the prefix.
|
||||
return i.yieldNil()
|
||||
}
|
||||
// TODO(jackson): If we thread a base.Comparer through to
|
||||
// InterleavingIter so that we have access to
|
||||
// ImmediateSuccessor, we could use NextPrefix. We'd need to
|
||||
// tweak the SpanMask interface slightly, but it's probably
|
||||
// worthwhile.
|
||||
|
||||
i.pointKey, i.pointVal = i.pointIter.Next()
|
||||
// We may have just invalidated the invariant that
|
||||
// ensures the span's End is > the point key, so
|
||||
@@ -780,27 +824,16 @@ func (i *InterleavingIter) interleaveBackward() (*base.InternalKey, base.LazyVal
|
||||
}
|
||||
}
|
||||
|
||||
// keyspanSeekGE seeks the keyspan iterator to the first span covering k ≥ key.
|
||||
// Note that this differs from the FragmentIterator.SeekGE semantics, which
|
||||
// seek to the first span with a start key ≥ key.
|
||||
func (i *InterleavingIter) keyspanSeekGE(key []byte, prefix []byte) {
|
||||
// Seek using SeekLT to look for a span that starts before key, with an end
|
||||
// boundary extending beyond key.
|
||||
i.span = i.keyspanIter.SeekLT(key)
|
||||
if i.span == nil || i.cmp(i.span.End, key) <= 0 {
|
||||
// The iterator is exhausted in the reverse direction, or the span we
|
||||
// found ends before key. Next to the first key with a start ≥ key.
|
||||
i.span = i.keyspanIter.Next()
|
||||
}
|
||||
// keyspanSeekGE seeks the keyspan iterator to the first span covering a key ≥ k.
|
||||
func (i *InterleavingIter) keyspanSeekGE(k []byte, prefix []byte) {
|
||||
i.span = i.keyspanIter.SeekGE(k)
|
||||
i.checkForwardBound(prefix)
|
||||
i.savedKeyspan()
|
||||
}
|
||||
|
||||
// keyspanSeekLT seeks the keyspan iterator to the last span covering k < key.
|
||||
// Note that this differs from the FragmentIterator.SeekLT semantics, which
|
||||
// seek to the last span with a start key < key.
|
||||
func (i *InterleavingIter) keyspanSeekLT(key []byte) {
|
||||
i.span = i.keyspanIter.SeekLT(key)
|
||||
// keyspanSeekLT seeks the keyspan iterator to the last span covering a key < k.
|
||||
func (i *InterleavingIter) keyspanSeekLT(k []byte) {
|
||||
i.span = i.keyspanIter.SeekLT(k)
|
||||
i.checkBackwardBound()
|
||||
// The current span's start key is not guaranteed to be less than key,
|
||||
// because of the bounds enforcement. Consider the following example:
|
||||
@@ -813,7 +846,7 @@ func (i *InterleavingIter) keyspanSeekLT(key []byte) {
|
||||
//
|
||||
// This problem is a consequence of the SeekLT's exclusive search key and
|
||||
// the fact that we don't perform bounds truncation at every leaf iterator.
|
||||
if i.span != nil && i.truncated && i.cmp(i.truncatedSpan.Start, key) >= 0 {
|
||||
if i.span != nil && i.truncated && i.cmp(i.truncatedSpan.Start, k) >= 0 {
|
||||
i.span = nil
|
||||
}
|
||||
i.savedKeyspan()
|
||||
|
||||
Reference in New Issue
Block a user