提交 deba9645 编写于 作者: G godchen 提交者: yefu.chen

Change name of kvBase

Signed-off-by: Ngodchen <qingxiang.chen@zilliz.com>
上级 61edc53f
......@@ -17,7 +17,7 @@ type GlobalIDAllocator struct {
allocator tso.Allocator
}
func NewGlobalIDAllocator(key string, base kv.TxnBase) *GlobalIDAllocator {
func NewGlobalIDAllocator(key string, base kv.TxnKV) *GlobalIDAllocator {
allocator := tso.NewGlobalTSOAllocator(key, base)
allocator.SetLimitMaxLogic(false)
return &GlobalIDAllocator{
......
......@@ -14,11 +14,11 @@ import (
// segment binlog meta key:
// ${prefix}/${segmentID}/${fieldID}/${idx}
type binlogMeta struct {
client kv.TxnBase // etcd kv
client kv.TxnKV // etcd kv
idAllocator allocatorInterface
}
func NewBinlogMeta(kv kv.TxnBase, idAllocator allocatorInterface) (*binlogMeta, error) {
func NewBinlogMeta(kv kv.TxnKV, idAllocator allocatorInterface) (*binlogMeta, error) {
mt := &binlogMeta{
client: kv,
idAllocator: idAllocator,
......
......@@ -31,7 +31,7 @@ type ddNode struct {
flushMap *sync.Map
inFlushCh <-chan *flushMsg
kv kv.Base
kv kv.BaseKV
replica Replica
binlogMeta *binlogMeta
}
......@@ -194,7 +194,7 @@ The keys of the binlogs are generated as below:
*/
func flushTxn(ddlData *sync.Map,
kv kv.Base,
kv kv.BaseKV,
meta *binlogMeta) {
// generate binlog
ddCodec := &storage.DataDefinitionCodec{}
......
......@@ -42,7 +42,7 @@ type insertBufferNode struct {
flushMeta *binlogMeta
flushMap sync.Map
minIOKV kv.Base
minIOKV kv.BaseKV
timeTickStream msgstream.MsgStream
segmentStatisticsStream msgstream.MsgStream
......@@ -564,7 +564,7 @@ func (ibNode *insertBufferNode) Operate(in []flowgraph.Msg) []flowgraph.Msg {
}
func flushSegmentTxn(collMeta *etcdpb.CollectionMeta, segID UniqueID, partitionID UniqueID, collID UniqueID,
insertData *sync.Map, meta *binlogMeta, kv kv.Base, finishCh chan<- bool) {
insertData *sync.Map, meta *binlogMeta, kv kv.BaseKV, finishCh chan<- bool) {
clearFn := func(isSuccess bool) {
finishCh <- isSuccess
......
......@@ -25,7 +25,7 @@ type errCollectionNotFound struct {
}
type meta struct {
sync.RWMutex
client kv.TxnBase // client of a reliable kv service, i.e. etcd client
client kv.TxnKV // client of a reliable kv service, i.e. etcd client
collections map[UniqueID]*datapb.CollectionInfo // collection id to collection info
segments map[UniqueID]*datapb.SegmentInfo // segment id to segment info
}
......@@ -46,7 +46,7 @@ func (err errCollectionNotFound) Error() string {
return fmt.Sprintf("collection %d not found", err.collectionID)
}
func newMeta(kv kv.TxnBase) (*meta, error) {
func newMeta(kv kv.TxnKV) (*meta, error) {
mt := &meta{
client: kv,
collections: make(map[UniqueID]*datapb.CollectionInfo),
......
......@@ -36,7 +36,7 @@ type IndexNode struct {
sched *TaskScheduler
kv kv.Base
kv kv.BaseKV
serviceClient types.IndexService // method factory
......
......@@ -71,7 +71,7 @@ func (bt *BaseTask) Notify(err error) {
type IndexBuildTask struct {
BaseTask
index Index
kv kv.Base
kv kv.BaseKV
savePaths []string
req *indexpb.BuildIndexRequest
serviceClient types.IndexService
......
......@@ -164,14 +164,14 @@ type TaskScheduler struct {
IndexBuildQueue TaskQueue
buildParallel int
kv kv.Base
kv kv.BaseKV
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
}
func NewTaskScheduler(ctx context.Context,
kv kv.Base) (*TaskScheduler, error) {
kv kv.BaseKV) (*TaskScheduler, error) {
ctx1, cancel := context.WithCancel(ctx)
s := &TaskScheduler{
kv: kv,
......
......@@ -44,7 +44,7 @@ type IndexService struct {
idAllocator *allocator.GlobalIDAllocator
kv kv.Base
kv kv.BaseKV
metaTable *metaTable
......
......@@ -26,13 +26,13 @@ import (
)
type metaTable struct {
client kv.TxnBase // client of a reliable kv service, i.e. etcd client
client kv.TxnKV // client of a reliable kv service, i.e. etcd client
indexBuildID2Meta map[UniqueID]indexpb.IndexMeta // index build id to index meta
lock sync.RWMutex
}
func NewMetaTable(kv kv.TxnBase) (*metaTable, error) {
func NewMetaTable(kv kv.TxnKV) (*metaTable, error) {
mt := &metaTable{
client: kv,
lock: sync.RWMutex{},
......
......@@ -65,7 +65,7 @@ type IndexAddTask struct {
indexBuildID UniqueID
idAllocator *allocator.GlobalIDAllocator
buildQueue TaskQueue
kv kv.Base
kv kv.BaseKV
builderClient types.IndexNode
nodeClients *PriorityQueue
buildClientNodeID UniqueID
......
......@@ -177,7 +177,7 @@ type TaskScheduler struct {
idAllocator *allocator.GlobalIDAllocator
metaTable *metaTable
kv kv.Base
kv kv.BaseKV
wg sync.WaitGroup
ctx context.Context
......@@ -186,7 +186,7 @@ type TaskScheduler struct {
func NewTaskScheduler(ctx context.Context,
idAllocator *allocator.GlobalIDAllocator,
kv kv.Base,
kv kv.BaseKV,
table *metaTable) (*TaskScheduler, error) {
ctx1, cancel := context.WithCancel(ctx)
s := &TaskScheduler{
......
package kv
type Base interface {
type BaseKV interface {
Load(key string) (string, error)
MultiLoad(keys []string) ([]string, error)
LoadWithPrefix(key string) ([]string, []string, error)
......@@ -13,8 +13,8 @@ type Base interface {
Close()
}
type TxnBase interface {
Base
type TxnKV interface {
BaseKV
MultiSaveAndRemove(saves map[string]string, removals []string) error
MultiRemoveWithPrefix(keys []string) error
MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error
......
......@@ -32,7 +32,7 @@ const (
)
type metaTable struct {
client kv.TxnBase // client of a reliable kv service, i.e. etcd client
client kv.TxnKV // client of a reliable kv service, i.e. etcd client
tenantID2Meta map[typeutil.UniqueID]pb.TenantMeta // tenant id to tenant meta
proxyID2Meta map[typeutil.UniqueID]pb.ProxyMeta // proxy id to proxy meta
collID2Meta map[typeutil.UniqueID]pb.CollectionInfo // collection_id -> meta
......@@ -50,7 +50,7 @@ type metaTable struct {
ddLock sync.RWMutex
}
func NewMetaTable(kv kv.TxnBase) (*metaTable, error) {
func NewMetaTable(kv kv.TxnKV) (*metaTable, error) {
mt := &metaTable{
client: kv,
tenantLock: sync.RWMutex{},
......
......@@ -19,7 +19,7 @@ import (
)
type mockTestKV struct {
kv.TxnBase
kv.TxnKV
loadWithPrefix func(key string) ([]string, []string, error)
save func(key, value string) error
......
......@@ -36,7 +36,7 @@ type indexLoader struct {
masterService types.MasterService
indexService types.IndexService
kv kv.Base // minio kv
kv kv.BaseKV // minio kv
}
func (loader *indexLoader) doLoadIndex(wg *sync.WaitGroup) {
......
......@@ -24,7 +24,7 @@ type segmentLoader struct {
dataService types.DataService
kv kv.Base // minio kv
kv kv.BaseKV // minio kv
indexLoader *indexLoader
}
......
......@@ -51,10 +51,10 @@ type GlobalTSOAllocator struct {
}
// NewGlobalTSOAllocator creates a new global TSO allocator.
func NewGlobalTSOAllocator(key string, kvBase kv.TxnBase) *GlobalTSOAllocator {
func NewGlobalTSOAllocator(key string, txnKV kv.TxnKV) *GlobalTSOAllocator {
return &GlobalTSOAllocator{
tso: &timestampOracle{
kvBase: kvBase,
txnKV: txnKV,
saveInterval: 3 * time.Second,
maxResetTSGap: func() time.Duration { return 3 * time.Second },
key: key,
......
......@@ -46,8 +46,8 @@ type atomicObject struct {
// timestampOracle is used to maintain the logic of tso.
type timestampOracle struct {
key string
kvBase kv.TxnBase
key string
txnKV kv.TxnKV
// TODO: remove saveInterval
saveInterval time.Duration
......@@ -58,7 +58,7 @@ type timestampOracle struct {
}
func (t *timestampOracle) loadTimestamp() (time.Time, error) {
strData, err := t.kvBase.Load(t.key)
strData, err := t.txnKV.Load(t.key)
var binData []byte = []byte(strData)
......@@ -75,7 +75,7 @@ func (t *timestampOracle) loadTimestamp() (time.Time, error) {
// otherwise, update it.
func (t *timestampOracle) saveTimestamp(ts time.Time) error {
data := typeutil.Uint64ToBytes(uint64(ts.UnixNano()))
err := t.kvBase.Save(t.key, string(data))
err := t.txnKV.Save(t.key, string(data))
if err != nil {
return errors.WithStack(err)
}
......
......@@ -56,7 +56,7 @@ func combKey(channelName string, id UniqueID) (string, error) {
type rocksmq struct {
store *gorocksdb.DB
kv kv.Base
kv kv.BaseKV
idAllocator allocator.GIDAllocator
channelMu map[string]*sync.Mutex
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册