From 612a1d1b5f2b579d1eca8fdbd4c60f77b03f1bfe Mon Sep 17 00:00:00 2001 From: disksing Date: Thu, 13 May 2021 04:33:55 +0800 Subject: [PATCH] remove options from unionstore Signed-off-by: disksing --- kv/union_store.go | 8 -------- store/driver/txn/txn_driver.go | 6 +----- store/tikv/txn.go | 16 ---------------- store/tikv/unionstore/union_store.go | 24 ------------------------ 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/kv/union_store.go b/kv/union_store.go index 0e9a6768c5ebc..41e0686e74fdb 100644 --- a/kv/union_store.go +++ b/kv/union_store.go @@ -23,13 +23,5 @@ type UnionStore interface { // UnmarkPresumeKeyNotExists deletes the key presume key not exists error flag for the lazy check. UnmarkPresumeKeyNotExists(k Key) - // SetOption sets an option with a value, when val is nil, uses the default - // value of this option. - SetOption(opt int, val interface{}) - // DelOption deletes an option. - DelOption(opt int) - // GetOption gets an option. - GetOption(opt int) interface{} - // GetMemBuffer return the MemBuffer binding to this unionStore. GetMemBuffer() MemBuffer } diff --git a/store/driver/txn/txn_driver.go b/store/driver/txn/txn_driver.go index 4d5ce77034312..3d0bc552fe9a1 100644 --- a/store/driver/txn/txn_driver.go +++ b/store/driver/txn/txn_driver.go @@ -172,8 +172,6 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) { txn.KVTxn.GetSnapshot().SetIsStatenessReadOnly(val.(bool)) case kv.MatchStoreLabels: txn.KVTxn.GetSnapshot().SetMatchStoreLabels(val.([]*metapb.StoreLabel)) - default: - txn.KVTxn.SetOption(opt, val) } } @@ -184,7 +182,7 @@ func (txn *tikvTxn) GetOption(opt int) interface{} { case kv.TxnScope: return txn.KVTxn.GetScope() default: - return txn.KVTxn.GetOption(opt) + return nil } } @@ -192,8 +190,6 @@ func (txn *tikvTxn) DelOption(opt int) { switch opt { case kv.CollectRuntimeStats: txn.KVTxn.GetSnapshot().SetRuntimeStats(nil) - default: - txn.KVTxn.DelOption(opt) } } diff --git a/store/tikv/txn.go b/store/tikv/txn.go index cba091cbdc8da..85334601ab23a 100644 --- a/store/tikv/txn.go +++ b/store/tikv/txn.go @@ -221,22 +221,6 @@ func (txn *KVTxn) Delete(k []byte) error { return txn.us.GetMemBuffer().Delete(k) } -// SetOption sets an option with a value, when val is nil, uses the default -// value of this option. -func (txn *KVTxn) SetOption(opt int, val interface{}) { - txn.us.SetOption(opt, val) -} - -// GetOption returns the option -func (txn *KVTxn) GetOption(opt int) interface{} { - return txn.us.GetOption(opt) -} - -// DelOption deletes an option. -func (txn *KVTxn) DelOption(opt int) { - txn.us.DelOption(opt) -} - // SetSchemaLeaseChecker sets a hook to check schema version. func (txn *KVTxn) SetSchemaLeaseChecker(checker SchemaLeaseChecker) { txn.schemaLeaseChecker = checker diff --git a/store/tikv/unionstore/union_store.go b/store/tikv/unionstore/union_store.go index f9a077d1c1352..08354975e38c5 100644 --- a/store/tikv/unionstore/union_store.go +++ b/store/tikv/unionstore/union_store.go @@ -59,7 +59,6 @@ type uSnapshot interface { type KVUnionStore struct { memBuffer *MemDB snapshot uSnapshot - opts options } // NewUnionStore builds a new unionStore. @@ -67,7 +66,6 @@ func NewUnionStore(snapshot uSnapshot) *KVUnionStore { return &KVUnionStore{ snapshot: snapshot, memBuffer: newMemDB(), - opts: make(map[int]interface{}), } } @@ -131,30 +129,8 @@ func (us *KVUnionStore) UnmarkPresumeKeyNotExists(k []byte) { us.memBuffer.UpdateFlags(k, kv.DelPresumeKeyNotExists) } -// SetOption implements the unionStore SetOption interface. -func (us *KVUnionStore) SetOption(opt int, val interface{}) { - us.opts[opt] = val -} - -// DelOption implements the unionStore DelOption interface. -func (us *KVUnionStore) DelOption(opt int) { - delete(us.opts, opt) -} - -// GetOption implements the unionStore GetOption interface. -func (us *KVUnionStore) GetOption(opt int) interface{} { - return us.opts[opt] -} - // SetEntrySizeLimit sets the size limit for each entry and total buffer. func (us *KVUnionStore) SetEntrySizeLimit(entryLimit, bufferLimit uint64) { us.memBuffer.entrySizeLimit = entryLimit us.memBuffer.bufferSizeLimit = bufferLimit } - -type options map[int]interface{} - -func (opts options) Get(opt int) (interface{}, bool) { - v, ok := opts[opt] - return v, ok -}