Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: add UnsafeLazyValue to EngineIterator interface #110281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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