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

db: don't use internal types in ScanInternal #2635

Merged
merged 1 commit into from
Jun 14, 2023
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
3 changes: 2 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cockroachdb/pebble/internal/manifest"
"github.com/cockroachdb/pebble/internal/manual"
"github.com/cockroachdb/pebble/objstorage"
"github.com/cockroachdb/pebble/rangekey"
"github.com/cockroachdb/pebble/record"
"github.com/cockroachdb/pebble/sstable"
"github.com/cockroachdb/pebble/vfs"
Expand Down Expand Up @@ -1183,7 +1184,7 @@ func (d *DB) ScanInternal(
lower, upper []byte,
visitPointKey func(key *InternalKey, value LazyValue) error,
visitRangeDel func(start, end []byte, seqNum uint64) error,
visitRangeKey func(start, end []byte, keys []keyspan.Key) error,
visitRangeKey func(start, end []byte, keys []rangekey.Key) error,
visitSharedFile func(sst *SharedSSTMeta) error,
) error {
iter := d.newInternalIter(nil /* snapshot */, &scanInternalOptions{
Expand Down
7 changes: 4 additions & 3 deletions scan_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cockroachdb/pebble/internal/keyspan"
"github.com/cockroachdb/pebble/internal/manifest"
"github.com/cockroachdb/pebble/objstorage"
"github.com/cockroachdb/pebble/rangekey"
"github.com/cockroachdb/pebble/sstable"
)

Expand Down Expand Up @@ -591,10 +592,10 @@ func (p *pointCollapsingIterator) Next() (*base.InternalKey, base.LazyValue) {

// NextPrefix implements the InternalIterator interface.
func (p *pointCollapsingIterator) NextPrefix(succKey []byte) (*base.InternalKey, base.LazyValue) {
// TODO(bilal): Implement this. It'll be similar to SeekGE, except we'll call
// TODO(bilal): Implement this optimally. It'll be similar to SeekGE, except we'll call
// the child iterator's NextPrefix, and have some special logic in case pos
// is pcIterPosNext.
panic("unimplemented")
return p.SeekGE(succKey, base.SeekGEFlagsNone)
}

// Prev implements the InternalIterator interface.
Expand Down Expand Up @@ -852,7 +853,7 @@ func scanInternalImpl(
iter *scanInternalIterator,
visitPointKey func(key *InternalKey, value LazyValue) error,
visitRangeDel func(start, end []byte, seqNum uint64) error,
visitRangeKey func(start, end []byte, keys []keyspan.Key) error,
visitRangeKey func(start, end []byte, keys []rangekey.Key) error,
visitSharedFile func(sst *SharedSSTMeta) error,
) error {
if visitSharedFile != nil && (lower == nil || upper == nil) {
Expand Down
5 changes: 3 additions & 2 deletions scan_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cockroachdb/pebble/internal/keyspan"
"github.com/cockroachdb/pebble/internal/testkeys"
"github.com/cockroachdb/pebble/objstorage/shared"
"github.com/cockroachdb/pebble/rangekey"
"github.com/cockroachdb/pebble/sstable"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
Expand All @@ -31,7 +32,7 @@ func TestScanInternal(t *testing.T) {
ctx context.Context,
lower, upper []byte, visitPointKey func(key *InternalKey, value LazyValue) error,
visitRangeDel func(start, end []byte, seqNum uint64) error,
visitRangeKey func(start, end []byte, keys []keyspan.Key) error,
visitRangeKey func(start, end []byte, keys []rangekey.Key) error,
visitSharedFile func(sst *SharedSSTMeta) error) error
}
batches := map[string]*Batch{}
Expand Down Expand Up @@ -243,7 +244,7 @@ func TestScanInternal(t *testing.T) {
}, func(start, end []byte, seqNum uint64) error {
fmt.Fprintf(&b, "%s-%s#%d,RANGEDEL\n", start, end, seqNum)
return nil
}, func(start, end []byte, keys []keyspan.Key) error {
}, func(start, end []byte, keys []rangekey.Key) error {
s := keyspan.Span{Start: start, End: end, Keys: keys}
fmt.Fprintf(&b, "%s\n", s.String())
return nil
Expand Down
4 changes: 2 additions & 2 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"io"
"math"

"github.com/cockroachdb/pebble/internal/keyspan"
"github.com/cockroachdb/pebble/rangekey"
)

// Snapshot provides a read-only point-in-time view of the DB state.
Expand Down Expand Up @@ -68,7 +68,7 @@ func (s *Snapshot) ScanInternal(
lower, upper []byte,
visitPointKey func(key *InternalKey, value LazyValue) error,
visitRangeDel func(start, end []byte, seqNum uint64) error,
visitRangeKey func(start, end []byte, keys []keyspan.Key) error,
visitRangeKey func(start, end []byte, keys []rangekey.Key) error,
visitSharedFile func(sst *SharedSSTMeta) error,
) error {
if s.db == nil {
Expand Down