Skip to content

Commit

Permalink
address the comment
Browse files Browse the repository at this point in the history
Signed-off-by: zyguan <[email protected]>
  • Loading branch information
zyguan committed Mar 21, 2023
1 parent 31adb08 commit b789231
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions store/driver/txn/unionstore_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

type visibilityChecker interface {
isVisible(kv.Key) bool
invisible(kv.Key) bool
}

// memBuffer wraps tikv.MemDB as kv.MemBuffer.
Expand Down Expand Up @@ -54,10 +54,10 @@ func (m *memBuffer) delInvisibleKey(k kv.Key) {
m.Unlock()
}

func (m *memBuffer) isVisible(k kv.Key) bool {
func (m *memBuffer) invisible(k kv.Key) bool {
// shall be protected by MemBuffer.RLock
_, ok := m.invisibleKeys[util.String(k)]
return !ok
return ok
}

func (m *memBuffer) Size() int {
Expand All @@ -77,7 +77,7 @@ func (m *memBuffer) DeleteWithFlags(k kv.Key, ops ...kv.FlagsOp) error {
}

func (m *memBuffer) Get(_ context.Context, key kv.Key) ([]byte, error) {
if !m.isVisible(key) {
if m.invisible(key) {
return nil, kv.ErrNotExist
}
data, err := m.MemDB.Get(key)
Expand Down Expand Up @@ -169,7 +169,7 @@ func newKVGetter(getter tikv.Getter, checker visibilityChecker) kv.Getter {
}

func (g *tikvGetter) Get(_ context.Context, k kv.Key) ([]byte, error) {
if !g.checker.isVisible(k) {
if g.checker.invisible(k) {
return nil, kv.ErrNotExist
}
data, err := g.Getter.Get(k)
Expand All @@ -185,7 +185,7 @@ type tikvIterator struct {

func newKVIterator(iterator tikv.Iterator, checker visibilityChecker) kv.Iterator {
it := &tikvIterator{iterator, checker, nil}
if it.Valid() && !it.checker.isVisible(it.Key()) {
if it.Valid() && it.checker.invisible(it.Key()) {
// skip first invisible key
it.initErr = it.Next()
}
Expand All @@ -210,7 +210,7 @@ func (it *tikvIterator) Next() error {
if !it.Valid() {
return nil
}
if it.checker.isVisible(it.Key()) {
if !it.checker.invisible(it.Key()) {
return nil
}
}
Expand Down

0 comments on commit b789231

Please sign in to comment.