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