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

use y.CompareKeysWithVer instead of bytes.Compare in Iterator. #102

Merged
merged 1 commit into from
Jul 25, 2019
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
16 changes: 8 additions & 8 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ func (opts *IteratorOptions) OverlapPending(it *pendingWritesIterator) bool {
if !opts.hasRange() {
return true
}
if bytes.Compare(opts.endKeyWithTS, it.entries[0].Key) <= 0 {
if y.CompareKeysWithVer(opts.endKeyWithTS, it.entries[0].Key) <= 0 {
return false
}
if bytes.Compare(opts.startKeyWithTS, it.entries[len(it.entries)-1].Key) > 0 {
if y.CompareKeysWithVer(opts.startKeyWithTS, it.entries[len(it.entries)-1].Key) > 0 {
return false
}
return true
Expand All @@ -298,7 +298,7 @@ func (opts *IteratorOptions) OverlapMemTable(t *table.MemTable) bool {
if !iter.Valid() {
return false
}
if bytes.Compare(iter.Key(), opts.endKeyWithTS) >= 0 {
if y.CompareKeysWithVer(iter.Key(), opts.endKeyWithTS) >= 0 {
return false
}
return true
Expand All @@ -308,10 +308,10 @@ func (opts *IteratorOptions) OverlapTable(t *table.Table) bool {
if !opts.hasRange() {
return true
}
if bytes.Compare(opts.endKeyWithTS, t.Smallest()) <= 0 {
if y.CompareKeysWithVer(opts.endKeyWithTS, t.Smallest()) <= 0 {
return false
}
if bytes.Compare(opts.startKeyWithTS, t.Biggest()) > 0 {
if y.CompareKeysWithVer(opts.startKeyWithTS, t.Biggest()) > 0 {
return false
}
iter := t.NewIterator(false)
Expand All @@ -320,7 +320,7 @@ func (opts *IteratorOptions) OverlapTable(t *table.Table) bool {
if !iter.Valid() {
return false
}
if bytes.Compare(iter.Key(), opts.endKeyWithTS) >= 0 {
if y.CompareKeysWithVer(iter.Key(), opts.endKeyWithTS) >= 0 {
return false
}
return true
Expand All @@ -335,15 +335,15 @@ func (opts *IteratorOptions) OverlapTables(tables []*table.Table) []*table.Table
}
startIdx := sort.Search(len(tables), func(i int) bool {
t := tables[i]
return bytes.Compare(opts.startKeyWithTS, t.Biggest()) <= 0
return y.CompareKeysWithVer(opts.startKeyWithTS, t.Biggest()) <= 0
})
if startIdx == len(tables) {
return nil
}
tables = tables[startIdx:]
endIdx := sort.Search(len(tables), func(i int) bool {
t := tables[i]
return bytes.Compare(t.Smallest(), opts.endKeyWithTS) >= 0
return y.CompareKeysWithVer(t.Smallest(), opts.endKeyWithTS) >= 0
})
tables = tables[:endIdx]
overlapTables := make([]*table.Table, 0, 8)
Expand Down