Skip to content

Commit

Permalink
Merge #110281
Browse files Browse the repository at this point in the history
110281: storage: add UnsafeLazyValue to EngineIterator interface r=nvanbenschoten a=nvanbenschoten

All implementations of the interface except `spanset.EngineIterator` already implement the method.

Epic: None
Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Sep 8, 2023
2 parents 918445f + 51c96d4 commit 52f0a7e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
21 changes: 13 additions & 8 deletions pkg/kv/kvserver/spanset/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,24 @@ func (i *EngineIterator) UnsafeEngineKey() (storage.EngineKey, error) {
return i.i.UnsafeEngineKey()
}

// EngineKey is part of the storage.EngineIterator interface.
func (i *EngineIterator) EngineKey() (storage.EngineKey, error) {
return i.i.EngineKey()
}

// UnsafeRawEngineKey is part of the storage.EngineIterator interface.
func (i *EngineIterator) UnsafeRawEngineKey() []byte {
return i.i.UnsafeRawEngineKey()
}

// UnsafeValue is part of the storage.EngineIterator interface.
func (i *EngineIterator) UnsafeValue() ([]byte, error) {
return i.i.UnsafeValue()
}

// EngineKey is part of the storage.EngineIterator interface.
func (i *EngineIterator) EngineKey() (storage.EngineKey, error) {
return i.i.EngineKey()
// UnsafeLazyValue is part of the storage.EngineIterator interface.
func (i *EngineIterator) UnsafeLazyValue() pebble.LazyValue {
return i.i.UnsafeLazyValue()
}

// Value is part of the storage.EngineIterator interface.
Expand All @@ -421,11 +431,6 @@ func (i *EngineIterator) ValueLen() int {
return i.i.ValueLen()
}

// UnsafeRawEngineKey is part of the storage.EngineIterator interface.
func (i *EngineIterator) UnsafeRawEngineKey() []byte {
return i.i.UnsafeRawEngineKey()
}

// CloneContext is part of the storage.EngineIterator interface.
func (i *EngineIterator) CloneContext() storage.CloneContext {
return i.i.CloneContext()
Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ type EngineIterator interface {
// invalidated on the next call to {Next,NextKey,Prev,SeekGE,SeekLT,Close}.
// REQUIRES: latest positioning function returned valid=true.
UnsafeValue() ([]byte, error)
// UnsafeLazyValue is only for use inside the storage package. It exposes
// the LazyValue at the current iterator position, and hence delays fetching
// the actual value.
// REQUIRES: latest positioning function returned valid=true.
UnsafeLazyValue() pebble.LazyValue
// Value returns the current value as a byte slice.
// REQUIRES: latest positioning function returned valid=true.
Value() ([]byte, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/pebble_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (p *pebbleIterator) UnsafeValue() ([]byte, error) {
return p.iter.ValueAndErr()
}

// UnsafeLazyValue implements the MVCCIterator interface.
// UnsafeLazyValue implements the MVCCIterator and EngineIterator interfaces.
func (p *pebbleIterator) UnsafeLazyValue() pebble.LazyValue {
if ok := p.iter.Valid(); !ok {
panic(errors.AssertionFailedf("UnsafeLazyValue called on !Valid iterator"))
Expand Down

0 comments on commit 52f0a7e

Please sign in to comment.