From 00c19853ec1da47bbe181372c04b2800609697e5 Mon Sep 17 00:00:00 2001 From: disksing Date: Wed, 28 Apr 2021 06:18:30 +0800 Subject: [PATCH] store/tikv: remove KeyOnly option Signed-off-by: disksing --- store/tikv/snapshot.go | 7 +++++-- store/tikv/tests/lock_test.go | 3 +-- store/tikv/tests/scan_test.go | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/store/tikv/snapshot.go b/store/tikv/snapshot.go index 0eee303a5a912..7441bde8246fb 100644 --- a/store/tikv/snapshot.go +++ b/store/tikv/snapshot.go @@ -544,8 +544,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) { s.notFillCache = val.(bool) case kv.SyncLog: s.syncLog = val.(bool) - case kv.KeyOnly: - s.keyOnly = val.(bool) case kv.SnapshotTS: s.setSnapshotTS(val.(uint64)) case kv.ReplicaRead: @@ -589,6 +587,11 @@ func (s *KVSnapshot) DelOption(opt int) { } } +// SetKeyOnly updates option to scan only keys. +func (s *KVSnapshot) SetKeyOnly(b bool) { + s.keyOnly = b +} + // SnapCacheHitCount gets the snapshot cache hit count. Only for test. func (s *KVSnapshot) SnapCacheHitCount() int { return int(atomic.LoadInt64(&s.mu.hitCnt)) diff --git a/store/tikv/tests/lock_test.go b/store/tikv/tests/lock_test.go index f55265a8a98a6..6c84ea488add8 100644 --- a/store/tikv/tests/lock_test.go +++ b/store/tikv/tests/lock_test.go @@ -26,7 +26,6 @@ import ( "github.com/pingcap/kvproto/pkg/kvrpcpb" tidbkv "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/tikv" - "github.com/pingcap/tidb/store/tikv/kv" "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/store/tikv/tikvrpc" ) @@ -142,7 +141,7 @@ func (s *testLockSuite) TestScanLockResolveWithSeekKeyOnly(c *C) { txn, err := s.store.Begin() c.Assert(err, IsNil) - txn.SetOption(kv.KeyOnly, true) + txn.GetSnapshot().SetKeyOnly(true) iter, err := txn.Iter([]byte("a"), nil) c.Assert(err, IsNil) for ch := byte('a'); ch <= byte('z'); ch++ { diff --git a/store/tikv/tests/scan_test.go b/store/tikv/tests/scan_test.go index 91e15747d3894..c64c6c3c52500 100644 --- a/store/tikv/tests/scan_test.go +++ b/store/tikv/tests/scan_test.go @@ -146,7 +146,7 @@ func (s *testScanSuite) TestScan(c *C) { check(c, scan, upperBound, false) txn3 := s.beginTxn(c) - txn3.SetOption(kv.KeyOnly, true) + txn3.GetSnapshot().SetKeyOnly(true) // Test scan without upper bound scan, err = txn3.Iter(s.recordPrefix, nil) c.Assert(err, IsNil) @@ -157,7 +157,7 @@ func (s *testScanSuite) TestScan(c *C) { check(c, scan, upperBound, true) // Restore KeyOnly to false - txn3.SetOption(kv.KeyOnly, false) + txn3.GetSnapshot().SetKeyOnly(false) scan, err = txn3.Iter(s.recordPrefix, nil) c.Assert(err, IsNil) check(c, scan, rowNum, true)