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

tool: use First in scan if no start key is provided #4164

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
17 changes: 14 additions & 3 deletions tool/sstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ func (s *sstableT) runScan(cmd *cobra.Command, args []string) {
}
iterCloser := base.CloseHelper(iter)
defer iterCloser.Close()
kv := iter.SeekGE(s.start, base.SeekGEFlagsNone)
var kv *base.InternalKV
if s.start == nil {
kv = iter.First()
} else {
kv = iter.SeekGE(s.start, base.SeekGEFlagsNone)
}

// We configured sstable.Reader to return raw tombstones which requires a
// bit more work here to put them in a form that can be iterated in
Expand All @@ -419,7 +424,7 @@ func (s *sstableT) runScan(cmd *cobra.Command, args []string) {
// The range tombstone lies after the scan range.
continue
}
if r.Compare(s.start, t.End) >= 0 {
if s.start != nil && r.Compare(s.start, t.End) >= 0 {
// The range tombstone lies before the scan range.
continue
}
Expand Down Expand Up @@ -512,7 +517,13 @@ func (s *sstableT) runScan(cmd *cobra.Command, args []string) {
}
if rkIter != nil {
defer rkIter.Close()
span, err := rkIter.SeekGE(s.start)
var span *keyspan.Span
var err error
if s.start == nil {
span, err = rkIter.First()
} else {
span, err = rkIter.SeekGE(s.start)
}
for ; span != nil; span, err = rkIter.Next() {
// By default, emit the key, unless there is a filter.
emit := s.filter == nil
Expand Down
Loading