Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store/tikv: remove options from unionstore #24629

Merged
merged 3 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}