Upgrade versions of vendored libs
This commit is contained in:
40
vendor/github.com/cockroachdb/pebble/internal/keyspan/seek.go
generated
vendored
40
vendor/github.com/cockroachdb/pebble/internal/keyspan/seek.go
generated
vendored
@@ -6,13 +6,9 @@ package keyspan
|
||||
|
||||
import "github.com/cockroachdb/pebble/internal/base"
|
||||
|
||||
// TODO(jackson): Move snapshot visiblity outside of SeekGE/SeekLE and into the
|
||||
// callsite. This should simplify the code some more.
|
||||
|
||||
// SeekGE seeks to the span that contains the target key or the first span past
|
||||
// the target key. The snapshot parameter controls the visibility of keys (only
|
||||
// spans older than the snapshot sequence number are visible).
|
||||
func SeekGE(cmp base.Compare, iter FragmentIterator, key []byte, snapshot uint64) Span {
|
||||
// the target key.
|
||||
func SeekGE(cmp base.Compare, iter FragmentIterator, key []byte) *Span {
|
||||
// NB: We use SeekLT in order to land on the proper span for a search
|
||||
// key that resides in the middle of a span. Consider the scenario:
|
||||
//
|
||||
@@ -29,27 +25,17 @@ func SeekGE(cmp base.Compare, iter FragmentIterator, key []byte, snapshot uint64
|
||||
|
||||
// Invariant: key > iterSpan.Start
|
||||
|
||||
if !iterSpan.Valid() || cmp(key, iterSpan.End) >= 0 {
|
||||
if iterSpan == nil || cmp(key, iterSpan.End) >= 0 {
|
||||
// The current span lies entirely before the search key, or the iterator
|
||||
// is exhausted. Advance the iterator to the next span which is
|
||||
// guaranteed to lie at or past the search key.
|
||||
iterSpan = iter.Next()
|
||||
}
|
||||
// The iterator is positioned at a valid iterSpan which is the first
|
||||
// iterator position that satisfies the requirement that it contains or is
|
||||
// past the target key. It may not be visible based on the snapshot. So now
|
||||
// we only need to move forward and return the first span with visible keys.
|
||||
iterSpan = iterSpan.Visible(snapshot)
|
||||
for iterSpan.Valid() && iterSpan.Empty() {
|
||||
iterSpan = iter.Next().Visible(snapshot)
|
||||
}
|
||||
return iterSpan
|
||||
}
|
||||
|
||||
// SeekLE seeks to the span that contains or is before the target key. The
|
||||
// snapshot parameter controls the visibility of keys (only spans older than the
|
||||
// snapshot sequence number are visible).
|
||||
func SeekLE(cmp base.Compare, iter FragmentIterator, key []byte, snapshot uint64) Span {
|
||||
// SeekLE seeks to the span that contains or is before the target key.
|
||||
func SeekLE(cmp base.Compare, iter FragmentIterator, key []byte) *Span {
|
||||
// NB: We use SeekLT in order to land on the proper span for a search
|
||||
// key that resides in the middle of a span. Consider the scenario:
|
||||
//
|
||||
@@ -64,13 +50,13 @@ func SeekLE(cmp base.Compare, iter FragmentIterator, key []byte, snapshot uint64
|
||||
// and we'll have to move forward.
|
||||
iterSpan := iter.SeekLT(key)
|
||||
|
||||
if !iterSpan.Valid() {
|
||||
if iterSpan == nil {
|
||||
// Advance the iterator once to see if the next span has a start key
|
||||
// equal to key.
|
||||
iterSpan = iter.Next()
|
||||
if !iterSpan.Valid() || cmp(key, iterSpan.Start) < 0 {
|
||||
if iterSpan == nil || cmp(key, iterSpan.Start) < 0 {
|
||||
// The iterator is exhausted or we've hit the next span.
|
||||
return Span{}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
// Invariant: key > iterSpan.Start
|
||||
@@ -79,20 +65,12 @@ func SeekLE(cmp base.Compare, iter FragmentIterator, key []byte, snapshot uint64
|
||||
// the next span contains the search key. If it doesn't, we'll backup
|
||||
// and return to our earlier candidate.
|
||||
iterSpan = iter.Next()
|
||||
if !iterSpan.Valid() || cmp(key, iterSpan.Start) < 0 {
|
||||
if iterSpan == nil || cmp(key, iterSpan.Start) < 0 {
|
||||
// The next span is past our search key or there is no next span. Go
|
||||
// back.
|
||||
iterSpan = iter.Prev()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We're positioned at a span that contains or is before the search key. It
|
||||
// may not be visible based on the snapshot. So now we only need to move
|
||||
// backward and return the first span with visible keys.
|
||||
iterSpan = iterSpan.Visible(snapshot)
|
||||
for iterSpan.Valid() && iterSpan.Empty() {
|
||||
iterSpan = iter.Prev().Visible(snapshot)
|
||||
}
|
||||
return iterSpan
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user