Skip to content

Commit

Permalink
store/tikv: remove options from unionstore (#24629)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored May 14, 2021
1 parent 4d7fcbb commit 42b12f7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 45 deletions.
6 changes: 1 addition & 5 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,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)
}
}

Expand All @@ -180,16 +178,14 @@ func (txn *tikvTxn) GetOption(opt int) interface{} {
case kv.TxnScope:
return txn.KVTxn.GetScope()
default:
return txn.KVTxn.GetOption(opt)
return nil
}
}

func (txn *tikvTxn) DelOption(opt int) {
switch opt {
case kv.CollectRuntimeStats:
txn.KVTxn.GetSnapshot().SetRuntimeStats(nil)
default:
txn.KVTxn.DelOption(opt)
}
}

Expand Down
16 changes: 0 additions & 16 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 0 additions & 24 deletions store/tikv/unionstore/union_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ type uSnapshot interface {
type KVUnionStore struct {
memBuffer *MemDB
snapshot uSnapshot
opts options
}

// NewUnionStore builds a new unionStore.
func NewUnionStore(snapshot uSnapshot) *KVUnionStore {
return &KVUnionStore{
snapshot: snapshot,
memBuffer: newMemDB(),
opts: make(map[int]interface{}),
}
}

Expand Down Expand Up @@ -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
}

0 comments on commit 42b12f7

Please sign in to comment.