Upgrade versions of vendored libs
This commit is contained in:
142
vendor/github.com/cockroachdb/pebble/sstable/block.go
generated
vendored
142
vendor/github.com/cockroachdb/pebble/sstable/block.go
generated
vendored
@@ -534,7 +534,7 @@ func (i *blockIter) cacheEntry() {
|
||||
|
||||
// SeekGE implements internalIterator.SeekGE, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) SeekGE(key []byte, trySeekUsingNext bool) (*InternalKey, []byte) {
|
||||
func (i *blockIter) SeekGE(key []byte, flags base.SeekGEFlags) (*InternalKey, base.LazyValue) {
|
||||
i.clearCache()
|
||||
|
||||
ikey := base.MakeSearchKey(key)
|
||||
@@ -629,25 +629,25 @@ func (i *blockIter) SeekGE(key []byte, trySeekUsingNext bool) (*InternalKey, []b
|
||||
// Iterate from that restart point to somewhere >= the key sought.
|
||||
for ; i.valid(); i.Next() {
|
||||
if base.InternalCompare(i.cmp, i.ikey, ikey) >= 0 {
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
|
||||
// SeekPrefixGE implements internalIterator.SeekPrefixGE, as documented in the
|
||||
// pebble package.
|
||||
func (i *blockIter) SeekPrefixGE(
|
||||
prefix, key []byte, trySeekUsingNext bool,
|
||||
) (*base.InternalKey, []byte) {
|
||||
prefix, key []byte, flags base.SeekGEFlags,
|
||||
) (*base.InternalKey, base.LazyValue) {
|
||||
// This should never be called as prefix iteration is handled by sstable.Iterator.
|
||||
panic("pebble: SeekPrefixGE unimplemented")
|
||||
}
|
||||
|
||||
// SeekLT implements internalIterator.SeekLT, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) SeekLT(key []byte) (*InternalKey, []byte) {
|
||||
func (i *blockIter) SeekLT(key []byte, flags base.SeekLTFlags) (*InternalKey, base.LazyValue) {
|
||||
i.clearCache()
|
||||
|
||||
ikey := base.MakeSearchKey(key)
|
||||
@@ -742,7 +742,7 @@ func (i *blockIter) SeekLT(key []byte) (*InternalKey, []byte) {
|
||||
// sought.
|
||||
i.offset = -1
|
||||
i.nextOffset = 0
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
|
||||
// Iterate from that restart point to somewhere >= the key sought, then back
|
||||
@@ -761,7 +761,7 @@ func (i *blockIter) SeekLT(key []byte) (*InternalKey, []byte) {
|
||||
// loop will execute at least once with this if-block not being true, so
|
||||
// the key we are backing up to is the last one this loop cached.
|
||||
i.Prev()
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
if i.nextOffset >= targetOffset {
|
||||
@@ -777,30 +777,30 @@ func (i *blockIter) SeekLT(key []byte) (*InternalKey, []byte) {
|
||||
}
|
||||
|
||||
if !i.valid() {
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// First implements internalIterator.First, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) First() (*InternalKey, []byte) {
|
||||
func (i *blockIter) First() (*InternalKey, base.LazyValue) {
|
||||
i.offset = 0
|
||||
if !i.valid() {
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
i.clearCache()
|
||||
i.readEntry()
|
||||
i.decodeInternalKey(i.key)
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// Last implements internalIterator.Last, as documented in the pebble package.
|
||||
func (i *blockIter) Last() (*InternalKey, []byte) {
|
||||
func (i *blockIter) Last() (*InternalKey, base.LazyValue) {
|
||||
// Seek forward from the last restart point.
|
||||
i.offset = int32(binary.LittleEndian.Uint32(i.data[i.restarts+4*(i.numRestarts-1):]))
|
||||
if !i.valid() {
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
|
||||
i.readEntry()
|
||||
@@ -813,12 +813,12 @@ func (i *blockIter) Last() (*InternalKey, []byte) {
|
||||
}
|
||||
|
||||
i.decodeInternalKey(i.key)
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// Next implements internalIterator.Next, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) Next() (*InternalKey, []byte) {
|
||||
func (i *blockIter) Next() (*InternalKey, base.LazyValue) {
|
||||
if len(i.cachedBuf) > 0 {
|
||||
// We're switching from reverse iteration to forward iteration. We need to
|
||||
// populate i.fullKey with the current key we're positioned at so that
|
||||
@@ -836,7 +836,7 @@ func (i *blockIter) Next() (*InternalKey, []byte) {
|
||||
|
||||
i.offset = i.nextOffset
|
||||
if !i.valid() {
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
i.readEntry()
|
||||
// Manually inlined version of i.decodeInternalKey(i.key).
|
||||
@@ -850,12 +850,12 @@ func (i *blockIter) Next() (*InternalKey, []byte) {
|
||||
i.ikey.Trailer = uint64(InternalKeyKindInvalid)
|
||||
i.ikey.UserKey = nil
|
||||
}
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// Prev implements internalIterator.Prev, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) Prev() (*InternalKey, []byte) {
|
||||
func (i *blockIter) Prev() (*InternalKey, base.LazyValue) {
|
||||
if n := len(i.cached) - 1; n >= 0 {
|
||||
i.nextOffset = i.offset
|
||||
e := &i.cached[n]
|
||||
@@ -874,14 +874,14 @@ func (i *blockIter) Prev() (*InternalKey, []byte) {
|
||||
i.ikey.UserKey = nil
|
||||
}
|
||||
i.cached = i.cached[:n]
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
i.clearCache()
|
||||
if i.offset <= 0 {
|
||||
i.offset = -1
|
||||
i.nextOffset = 0
|
||||
return nil, nil
|
||||
return nil, base.LazyValue{}
|
||||
}
|
||||
|
||||
targetOffset := i.offset
|
||||
@@ -921,7 +921,7 @@ func (i *blockIter) Prev() (*InternalKey, []byte) {
|
||||
}
|
||||
|
||||
i.decodeInternalKey(i.key)
|
||||
return &i.ikey, i.val
|
||||
return &i.ikey, base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// Key implements internalIterator.Key, as documented in the pebble package.
|
||||
@@ -929,10 +929,8 @@ func (i *blockIter) Key() *InternalKey {
|
||||
return &i.ikey
|
||||
}
|
||||
|
||||
// Value implements internalIterator.Value, as documented in the pebble
|
||||
// package.
|
||||
func (i *blockIter) Value() []byte {
|
||||
return i.val
|
||||
func (i *blockIter) value() base.LazyValue {
|
||||
return base.MakeInPlaceValue(i.val)
|
||||
}
|
||||
|
||||
// Error implements internalIterator.Error, as documented in the pebble
|
||||
@@ -987,6 +985,10 @@ type fragmentBlockIter struct {
|
||||
closeHook func(i keyspan.FragmentIterator) error
|
||||
}
|
||||
|
||||
func (i *fragmentBlockIter) resetForReuse() fragmentBlockIter {
|
||||
return fragmentBlockIter{blockIter: i.blockIter.resetForReuse()}
|
||||
}
|
||||
|
||||
func (i *fragmentBlockIter) decodeSpanKeys(k *InternalKey, internalValue []byte) {
|
||||
// TODO(jackson): The use of i.span.Keys to accumulate keys across multiple
|
||||
// calls to Decode is too confusing and subtle. Refactor to make it
|
||||
@@ -1017,10 +1019,10 @@ func (i *fragmentBlockIter) decodeSpanKeys(k *InternalKey, internalValue []byte)
|
||||
//
|
||||
// gatherForward iterates forward, re-combining the fragmented internal keys to
|
||||
// reconstruct a keyspan.Span that holds all the keys defined over the span.
|
||||
func (i *fragmentBlockIter) gatherForward(k *InternalKey, internalValue []byte) keyspan.Span {
|
||||
func (i *fragmentBlockIter) gatherForward(k *InternalKey, lazyValue base.LazyValue) *keyspan.Span {
|
||||
i.span = keyspan.Span{}
|
||||
if k == nil || !i.blockIter.valid() {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
i.err = nil
|
||||
// Use the i.keyBuf array to back the Keys slice to prevent an allocation
|
||||
@@ -1028,20 +1030,22 @@ func (i *fragmentBlockIter) gatherForward(k *InternalKey, internalValue []byte)
|
||||
i.span.Keys = i.keyBuf[:0]
|
||||
|
||||
// Decode the span's end key and individual keys from the value.
|
||||
internalValue := lazyValue.InPlaceValue()
|
||||
i.decodeSpanKeys(k, internalValue)
|
||||
if i.err != nil {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
prevEnd := i.span.End
|
||||
|
||||
// There might exist additional internal keys with identical bounds encoded
|
||||
// within the block. Iterate forward, accumulating all the keys with
|
||||
// identical bounds to s.
|
||||
k, internalValue = i.blockIter.Next()
|
||||
k, lazyValue = i.blockIter.Next()
|
||||
internalValue = lazyValue.InPlaceValue()
|
||||
for k != nil && i.blockIter.cmp(k.UserKey, i.span.Start) == 0 {
|
||||
i.decodeSpanKeys(k, internalValue)
|
||||
if i.err != nil {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
|
||||
// Since k indicates an equal start key, the encoded end key must
|
||||
@@ -1051,12 +1055,13 @@ func (i *fragmentBlockIter) gatherForward(k *InternalKey, internalValue []byte)
|
||||
if i.blockIter.cmp(prevEnd, i.span.End) != 0 {
|
||||
i.err = base.CorruptionErrorf("pebble: corrupt keyspan fragmentation")
|
||||
i.span = keyspan.Span{}
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
k, internalValue = i.blockIter.Next()
|
||||
k, lazyValue = i.blockIter.Next()
|
||||
internalValue = lazyValue.InPlaceValue()
|
||||
}
|
||||
// i.blockIter is positioned over the first internal key for the next span.
|
||||
return i.span
|
||||
return &i.span
|
||||
}
|
||||
|
||||
// gatherBackward gathers internal keys with identical bounds. Keys defined over
|
||||
@@ -1067,10 +1072,10 @@ func (i *fragmentBlockIter) gatherForward(k *InternalKey, internalValue []byte)
|
||||
//
|
||||
// gatherBackward iterates backwards, re-combining the fragmented internal keys
|
||||
// to reconstruct a keyspan.Span that holds all the keys defined over the span.
|
||||
func (i *fragmentBlockIter) gatherBackward(k *InternalKey, internalValue []byte) keyspan.Span {
|
||||
func (i *fragmentBlockIter) gatherBackward(k *InternalKey, lazyValue base.LazyValue) *keyspan.Span {
|
||||
i.span = keyspan.Span{}
|
||||
if k == nil || !i.blockIter.valid() {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
i.err = nil
|
||||
// Use the i.keyBuf array to back the Keys slice to prevent an allocation
|
||||
@@ -1078,20 +1083,22 @@ func (i *fragmentBlockIter) gatherBackward(k *InternalKey, internalValue []byte)
|
||||
i.span.Keys = i.keyBuf[:0]
|
||||
|
||||
// Decode the span's end key and individual keys from the value.
|
||||
internalValue := lazyValue.InPlaceValue()
|
||||
i.decodeSpanKeys(k, internalValue)
|
||||
if i.err != nil {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
prevEnd := i.span.End
|
||||
|
||||
// There might exist additional internal keys with identical bounds encoded
|
||||
// within the block. Iterate backward, accumulating all the keys with
|
||||
// identical bounds to s.
|
||||
k, internalValue = i.blockIter.Prev()
|
||||
k, lazyValue = i.blockIter.Prev()
|
||||
internalValue = lazyValue.InPlaceValue()
|
||||
for k != nil && i.blockIter.cmp(k.UserKey, i.span.Start) == 0 {
|
||||
i.decodeSpanKeys(k, internalValue)
|
||||
if i.err != nil {
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
|
||||
// Since k indicates an equal start key, the encoded end key must
|
||||
@@ -1101,27 +1108,26 @@ func (i *fragmentBlockIter) gatherBackward(k *InternalKey, internalValue []byte)
|
||||
if i.blockIter.cmp(prevEnd, i.span.End) != 0 {
|
||||
i.err = base.CorruptionErrorf("pebble: corrupt keyspan fragmentation")
|
||||
i.span = keyspan.Span{}
|
||||
return i.span
|
||||
return nil
|
||||
}
|
||||
k, internalValue = i.blockIter.Prev()
|
||||
k, lazyValue = i.blockIter.Prev()
|
||||
internalValue = lazyValue.InPlaceValue()
|
||||
}
|
||||
// i.blockIter is positioned over the last internal key for the previous
|
||||
// span.
|
||||
|
||||
// Backwards iteration encounters internal keys in the wrong order.
|
||||
keyspan.SortKeys(i.span.Keys)
|
||||
keyspan.SortKeysByTrailer(&i.span.Keys)
|
||||
|
||||
return i.span
|
||||
return &i.span
|
||||
}
|
||||
|
||||
// Error implements (base.InternalIterator).Error, as documented in the
|
||||
// internal/base package.
|
||||
// Error implements (keyspan.FragmentIterator).Error.
|
||||
func (i *fragmentBlockIter) Error() error {
|
||||
return i.err
|
||||
}
|
||||
|
||||
// Close implements (base.InternalIterator).Close, as documented in the
|
||||
// internal/base package.
|
||||
// Close implements (keyspan.FragmentIterator).Close.
|
||||
func (i *fragmentBlockIter) Close() error {
|
||||
var err error
|
||||
if i.closeHook != nil {
|
||||
@@ -1131,23 +1137,20 @@ func (i *fragmentBlockIter) Close() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// First implements (base.InternalIterator).First, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) First() keyspan.Span {
|
||||
// First implements (keyspan.FragmentIterator).First
|
||||
func (i *fragmentBlockIter) First() *keyspan.Span {
|
||||
i.dir = +1
|
||||
return i.gatherForward(i.blockIter.First())
|
||||
}
|
||||
|
||||
// Last implements (base.InternalIterator).Last, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) Last() keyspan.Span {
|
||||
// Last implements (keyspan.FragmentIterator).Last.
|
||||
func (i *fragmentBlockIter) Last() *keyspan.Span {
|
||||
i.dir = -1
|
||||
return i.gatherBackward(i.blockIter.Last())
|
||||
}
|
||||
|
||||
// Next implements (base.InternalIterator).Next, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) Next() keyspan.Span {
|
||||
// Next implements (keyspan.FragmentIterator).Next.
|
||||
func (i *fragmentBlockIter) Next() *keyspan.Span {
|
||||
switch {
|
||||
case i.dir == -1 && !i.span.Valid():
|
||||
// Switching directions.
|
||||
@@ -1176,12 +1179,12 @@ func (i *fragmentBlockIter) Next() keyspan.Span {
|
||||
}
|
||||
i.dir = +1
|
||||
}
|
||||
return i.gatherForward(&i.blockIter.ikey, i.blockIter.val)
|
||||
// We know that this blockIter has in-place values.
|
||||
return i.gatherForward(&i.blockIter.ikey, base.MakeInPlaceValue(i.blockIter.val))
|
||||
}
|
||||
|
||||
// Prev implements (base.InternalIterator).Prev, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) Prev() keyspan.Span {
|
||||
// Prev implements (keyspan.FragmentIterator).Prev.
|
||||
func (i *fragmentBlockIter) Prev() *keyspan.Span {
|
||||
switch {
|
||||
case i.dir == +1 && !i.span.Valid():
|
||||
// Switching directions.
|
||||
@@ -1210,21 +1213,20 @@ func (i *fragmentBlockIter) Prev() keyspan.Span {
|
||||
}
|
||||
i.dir = -1
|
||||
}
|
||||
return i.gatherBackward(&i.blockIter.ikey, i.blockIter.val)
|
||||
// We know that this blockIter has in-place values.
|
||||
return i.gatherBackward(&i.blockIter.ikey, base.MakeInPlaceValue(i.blockIter.val))
|
||||
}
|
||||
|
||||
// SeekGE implements (base.InternalIterator).SeekGE, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) SeekGE(k []byte) keyspan.Span {
|
||||
// SeekGE implements (keyspan.FragmentIterator).SeekGE.
|
||||
func (i *fragmentBlockIter) SeekGE(k []byte) *keyspan.Span {
|
||||
i.dir = +1
|
||||
return i.gatherForward(i.blockIter.SeekGE(k, false))
|
||||
return i.gatherForward(i.blockIter.SeekGE(k, base.SeekGEFlags(0)))
|
||||
}
|
||||
|
||||
// SeekLT implements (base.InternalIterator).SeekLT, as documented in the
|
||||
// internal/base package.
|
||||
func (i *fragmentBlockIter) SeekLT(k []byte) keyspan.Span {
|
||||
// SeekLT implements (keyspan.FragmentIterator).SeekLT.
|
||||
func (i *fragmentBlockIter) SeekLT(k []byte) *keyspan.Span {
|
||||
i.dir = -1
|
||||
return i.gatherBackward(i.blockIter.SeekLT(k))
|
||||
return i.gatherBackward(i.blockIter.SeekLT(k, base.SeekLTFlagsNone))
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
|
||||
Reference in New Issue
Block a user