-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: Make use of the upperBound of ticlient's kv_scan interface to ensure no overbound scan will happen #8081
Changes from 7 commits
8f24d6f
aa23f25
3995026
5c12af2
3d118e3
4a20ceb
6f92d47
e64e7c9
d6ee090
a059b8f
9c20c8c
972ff01
63fdd1c
f8426e5
6e893fc
aae45bc
cf6c377
b8326f3
d9ed06f
11f4b36
fc5bea3
02ee433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,14 +50,10 @@ func NewMemDbBuffer(cap int) MemBuffer { | |
} | ||
} | ||
|
||
// Seek creates an Iterator. | ||
func (m *memDbBuffer) Seek(k Key) (Iterator, error) { | ||
var i Iterator | ||
if k == nil { | ||
i = &memDbIter{iter: m.db.NewIterator(&util.Range{}), reverse: false} | ||
} else { | ||
i = &memDbIter{iter: m.db.NewIterator(&util.Range{Start: []byte(k)}), reverse: false} | ||
} | ||
// Iter creates an Iterator. | ||
func (m *memDbBuffer) Iter(k Key, upperBound Key) (Iterator, error) { | ||
i := &memDbIter{iter: m.db.NewIterator(&util.Range{Start: []byte(k), Limit: []byte(upperBound)}), reverse: false} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about k or upperBound is nil? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok. If |
||
|
||
err := i.Next() | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
|
@@ -69,7 +65,7 @@ func (m *memDbBuffer) SetCap(cap int) { | |
|
||
} | ||
|
||
func (m *memDbBuffer) SeekReverse(k Key) (Iterator, error) { | ||
func (m *memDbBuffer) IterReverse(k Key) (Iterator, error) { | ||
var i *memDbIter | ||
if k == nil { | ||
i = &memDbIter{iter: m.db.NewIterator(&util.Range{}), reverse: true} | ||
|
@@ -161,7 +157,7 @@ func (i *memDbIter) Close() { | |
|
||
// WalkMemBuffer iterates all buffered kv pairs in memBuf | ||
func WalkMemBuffer(memBuf MemBuffer, f func(k Key, v []byte) error) error { | ||
iter, err := memBuf.Seek(nil) | ||
iter, err := memBuf.Iter(nil, nil) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.EndKey
?