tikv/txn: add the method BatchGet (#108)#109
Conversation
Signed-off-by: Xu Qiaolun <jamesxql@gmail.com>
|
Hi @gotoxu , would you like to add some test? |
Signed-off-by: Xu Qiaolun <jamesxql@gmail.com>
|
Hi @disksing , I have added a test case for BufferBatchGetter! |
|
Another question, do you have plan to update TiDB code to use the new method? |
tikv/batch_getter_test.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (s *mockBatchGetterStore) Iter(k []byte, upperBound []byte) (unionstore.Iterator, error) { |
There was a problem hiding this comment.
Could we remove this function?
There was a problem hiding this comment.
This method is implemented because the parameters of the NewUnionStore method need to implement the uSnapshot interface:
// uSnapshot defines the interface for the snapshot fetched from KV store.
type uSnapshot interface {
// Get gets the value for key k from kv store.
// If corresponding kv pair does not exist, it returns nil and ErrNotExist.
Get(ctx context.Context, k []byte) ([]byte, error)
// Iter creates an Iterator positioned on the first entry that k <= entry's key.
// If such entry is not found, it returns an invalid Iterator with no error.
// It yields only keys that < upperBound. If upperBound is nil, it means the upperBound is unbounded.
// The Iterator must be Closed after use.
Iter(k []byte, upperBound []byte) (Iterator, error)
// IterReverse creates a reversed Iterator positioned on the first entry which key is less than k.
// The returned iterator will iterate from greater key to smaller key.
// If k is nil, the returned iterator will be positioned at the last key.
// TODO: Add lower bound limit
IterReverse(k []byte) (Iterator, error)
}In fact, I just need to create a MemDB object. Can we consider exposing the newMemDB method?
There was a problem hiding this comment.
How about using mockBatchGetterStore as the first argument for the function NewBufferBatchGetter since the mockBatchGetterStore already implement the interface BatchBufferGetter, and also this would make the test easier to understand(the reviewer needn't understand what is UnionStore which could not be related to this test).
Signed-off-by: Xu Qiaolun <jamesxql@gmail.com>
We do not use TiDB, we just use TiKV as the storage layer of our entire system, so we need a separate Go client project. |
Got it. We will create a linked issue at TiDB side and handle it later. |
|
LGTM. Please help to take another look. /cc @AndreMouche |
…fferBatchGetter Signed-off-by: Xu Qiaolun <jamesxql@gmail.com>
Signed-off-by: Xu Qiaolun <jamesxql@gmail.com>
|
Thanks @gotoxu , I'll update your branch before merging. |
Signed-off-by: Xu Qiaolun jamesxql@gmail.com
fix issue: #108