Skip to content

Commit

Permalink
use y.CompareKeysWithVer instead of bytes.Compare in Iterator. (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored Jul 25, 2019
1 parent fcec660 commit 290d112
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 290d112

Please sign in to comment.