2021-01-15 17:09:41 +08:00
|
|
|
package dataservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
|
|
|
|
2021-03-05 20:41:34 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/kv"
|
2021-03-02 15:52:42 +08:00
|
|
|
|
2021-02-03 18:55:00 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
2021-01-15 17:09:41 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
|
2021-03-12 14:22:09 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
2021-04-09 09:55:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
metaPrefix = "dataservice-meta"
|
|
|
|
segmentPrefix = metaPrefix + "/s"
|
2021-01-15 17:09:41 +08:00
|
|
|
)
|
|
|
|
|
2021-03-05 20:41:34 +08:00
|
|
|
type errSegmentNotFound struct {
|
|
|
|
segmentID UniqueID
|
|
|
|
}
|
|
|
|
type errCollectionNotFound struct {
|
|
|
|
collectionID UniqueID
|
|
|
|
}
|
|
|
|
type meta struct {
|
2021-04-09 09:55:04 +08:00
|
|
|
sync.RWMutex
|
|
|
|
client kv.TxnBase // 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
|
2021-03-05 20:41:34 +08:00
|
|
|
}
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-01-22 11:07:07 +08:00
|
|
|
func newErrSegmentNotFound(segmentID UniqueID) errSegmentNotFound {
|
|
|
|
return errSegmentNotFound{segmentID: segmentID}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err errSegmentNotFound) Error() string {
|
|
|
|
return fmt.Sprintf("segment %d not found", err.segmentID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newErrCollectionNotFound(collectionID UniqueID) errCollectionNotFound {
|
|
|
|
return errCollectionNotFound{collectionID: collectionID}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err errCollectionNotFound) Error() string {
|
|
|
|
return fmt.Sprintf("collection %d not found", err.collectionID)
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:17:17 +08:00
|
|
|
func newMeta(kv kv.TxnBase) (*meta, error) {
|
2021-01-15 17:09:41 +08:00
|
|
|
mt := &meta{
|
|
|
|
client: kv,
|
2021-04-09 09:55:04 +08:00
|
|
|
collections: make(map[UniqueID]*datapb.CollectionInfo),
|
|
|
|
segments: make(map[UniqueID]*datapb.SegmentInfo),
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
err := mt.reloadFromKV()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return mt, nil
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:10:49 +08:00
|
|
|
func (meta *meta) reloadFromKV() error {
|
2021-04-09 09:55:04 +08:00
|
|
|
_, values, err := meta.client.LoadWithPrefix(segmentPrefix)
|
2021-01-15 17:09:41 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, value := range values {
|
|
|
|
segmentInfo := &datapb.SegmentInfo{}
|
|
|
|
err = proto.UnmarshalText(value, segmentInfo)
|
|
|
|
if err != nil {
|
2021-03-30 20:19:30 +08:00
|
|
|
return fmt.Errorf("DataService reloadFromKV UnMarshalText datapb.SegmentInfo err:%w", err)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.segments[segmentInfo.ID] = segmentInfo
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) AddCollection(collection *datapb.CollectionInfo) error {
|
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
|
|
|
if _, ok := meta.collections[collection.ID]; ok {
|
|
|
|
return fmt.Errorf("collection %s with id %d already exist", collection.Schema.Name, collection.ID)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.collections[collection.ID] = collection
|
2021-01-15 17:09:41 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:10:49 +08:00
|
|
|
func (meta *meta) DropCollection(collID UniqueID) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
if _, ok := meta.collections[collID]; !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return newErrCollectionNotFound(collID)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
key := fmt.Sprintf("%s/%d/", segmentPrefix, collID)
|
|
|
|
if err := meta.client.RemoveWithPrefix(key); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
delete(meta.collections, collID)
|
|
|
|
|
|
|
|
for i, info := range meta.segments {
|
2021-02-02 14:25:58 +08:00
|
|
|
if info.CollectionID == collID {
|
2021-04-09 09:55:04 +08:00
|
|
|
delete(meta.segments, i)
|
2021-02-02 14:25:58 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-15 17:09:41 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:10:49 +08:00
|
|
|
func (meta *meta) HasCollection(collID UniqueID) bool {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
|
|
|
_, ok := meta.collections[collID]
|
2021-01-15 17:09:41 +08:00
|
|
|
return ok
|
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) GetCollection(collectionID UniqueID) (*datapb.CollectionInfo, error) {
|
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-01-19 15:35:40 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
collection, ok := meta.collections[collectionID]
|
2021-01-19 15:35:40 +08:00
|
|
|
if !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return nil, newErrCollectionNotFound(collectionID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
return proto.Clone(collection).(*datapb.CollectionInfo), nil
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-02-02 14:25:58 +08:00
|
|
|
func (meta *meta) GetNumRowsOfCollection(collectionID UniqueID) (int64, error) {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-02-02 14:25:58 +08:00
|
|
|
var ret int64 = 0
|
2021-04-09 09:55:04 +08:00
|
|
|
for _, info := range meta.segments {
|
2021-02-02 14:25:58 +08:00
|
|
|
if info.CollectionID == collectionID {
|
|
|
|
ret += info.NumRows
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (meta *meta) GetMemSizeOfCollection(collectionID UniqueID) (int64, error) {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-02-02 14:25:58 +08:00
|
|
|
var ret int64 = 0
|
2021-04-09 09:55:04 +08:00
|
|
|
for _, info := range meta.segments {
|
2021-02-02 14:25:58 +08:00
|
|
|
if info.CollectionID == collectionID {
|
|
|
|
ret += info.MemSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) AddSegment(segment *datapb.SegmentInfo) error {
|
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
|
|
|
if _, ok := meta.segments[segment.ID]; ok {
|
|
|
|
return fmt.Errorf("segment %d already exist", segment.ID)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.segments[segment.ID] = segment
|
|
|
|
if err := meta.saveSegmentInfo(segment); err != nil {
|
2021-01-15 17:09:41 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) UpdateSegment(segment *datapb.SegmentInfo) error {
|
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
|
|
|
seg, ok := meta.segments[segment.ID]
|
|
|
|
if !ok {
|
|
|
|
return newErrSegmentNotFound(segment.ID)
|
|
|
|
}
|
|
|
|
seg.OpenTime = segment.OpenTime
|
|
|
|
seg.SealedTime = segment.SealedTime
|
|
|
|
seg.NumRows = segment.NumRows
|
|
|
|
seg.MemSize = segment.MemSize
|
|
|
|
seg.StartPosition = proto.Clone(segment.StartPosition).(*internalpb.MsgPosition)
|
|
|
|
seg.EndPosition = proto.Clone(segment.EndPosition).(*internalpb.MsgPosition)
|
|
|
|
|
|
|
|
if err := meta.saveSegmentInfo(segment); err != nil {
|
2021-01-15 17:09:41 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-19 15:35:40 +08:00
|
|
|
func (meta *meta) DropSegment(segmentID UniqueID) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-19 15:35:40 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segment, ok := meta.segments[segmentID]
|
|
|
|
if !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return newErrSegmentNotFound(segmentID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
if err := meta.removeSegmentInfo(segment); err != nil {
|
2021-02-02 14:25:58 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
delete(meta.segments, segmentID)
|
2021-01-19 15:35:40 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:10:49 +08:00
|
|
|
func (meta *meta) GetSegment(segID UniqueID) (*datapb.SegmentInfo, error) {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segment, ok := meta.segments[segID]
|
2021-01-15 17:09:41 +08:00
|
|
|
if !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return nil, newErrSegmentNotFound(segID)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-04-09 09:55:04 +08:00
|
|
|
return proto.Clone(segment).(*datapb.SegmentInfo), nil
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-01-25 15:17:17 +08:00
|
|
|
func (meta *meta) OpenSegment(segmentID UniqueID, timetick Timestamp) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segInfo, ok := meta.segments[segmentID]
|
2021-01-15 17:09:41 +08:00
|
|
|
if !ok {
|
2021-01-25 15:17:17 +08:00
|
|
|
return newErrSegmentNotFound(segmentID)
|
2021-01-22 11:07:07 +08:00
|
|
|
}
|
|
|
|
|
2021-01-25 15:17:17 +08:00
|
|
|
segInfo.OpenTime = timetick
|
2021-04-09 09:55:04 +08:00
|
|
|
if err := meta.saveSegmentInfo(segInfo); err != nil {
|
2021-01-22 11:07:07 +08:00
|
|
|
return err
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-01-25 15:17:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (meta *meta) SealSegment(segID UniqueID, timetick Timestamp) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-25 15:17:17 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segInfo, ok := meta.segments[segID]
|
2021-01-25 15:17:17 +08:00
|
|
|
if !ok {
|
|
|
|
return newErrSegmentNotFound(segID)
|
|
|
|
}
|
|
|
|
|
|
|
|
segInfo.SealedTime = timetick
|
2021-04-09 09:55:04 +08:00
|
|
|
if err := meta.saveSegmentInfo(segInfo); err != nil {
|
2021-01-22 11:07:07 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:17:17 +08:00
|
|
|
func (meta *meta) FlushSegment(segID UniqueID, timetick Timestamp) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-22 11:07:07 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segInfo, ok := meta.segments[segID]
|
2021-01-22 11:07:07 +08:00
|
|
|
if !ok {
|
|
|
|
return newErrSegmentNotFound(segID)
|
|
|
|
}
|
2021-01-25 15:17:17 +08:00
|
|
|
segInfo.FlushedTime = timetick
|
2021-03-22 16:36:10 +08:00
|
|
|
segInfo.State = commonpb.SegmentState_Flushed
|
2021-04-09 09:55:04 +08:00
|
|
|
if err := meta.saveSegmentInfo(segInfo); err != nil {
|
2021-01-22 11:07:07 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-01-25 15:17:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-03 18:55:00 +08:00
|
|
|
func (meta *meta) SetSegmentState(segmentID UniqueID, state commonpb.SegmentState) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
segInfo, ok := meta.segments[segmentID]
|
2021-01-25 15:17:17 +08:00
|
|
|
if !ok {
|
|
|
|
return newErrSegmentNotFound(segmentID)
|
|
|
|
}
|
|
|
|
segInfo.State = state
|
2021-04-09 09:55:04 +08:00
|
|
|
if err := meta.saveSegmentInfo(segInfo); err != nil {
|
2021-01-15 17:09:41 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-02 14:25:58 +08:00
|
|
|
func (meta *meta) GetSegmentsOfCollection(collectionID UniqueID) []UniqueID {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-01-19 15:35:40 +08:00
|
|
|
ret := make([]UniqueID, 0)
|
2021-04-09 09:55:04 +08:00
|
|
|
for _, info := range meta.segments {
|
2021-01-19 15:35:40 +08:00
|
|
|
if info.CollectionID == collectionID {
|
2021-04-09 09:55:04 +08:00
|
|
|
ret = append(ret, info.ID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2021-02-02 14:25:58 +08:00
|
|
|
func (meta *meta) GetSegmentsOfPartition(collectionID, partitionID UniqueID) []UniqueID {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-01-19 15:35:40 +08:00
|
|
|
|
|
|
|
ret := make([]UniqueID, 0)
|
2021-04-09 09:55:04 +08:00
|
|
|
for _, info := range meta.segments {
|
2021-01-22 11:07:07 +08:00
|
|
|
if info.CollectionID == collectionID && info.PartitionID == partitionID {
|
2021-04-09 09:55:04 +08:00
|
|
|
ret = append(ret, info.ID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (meta *meta) AddPartition(collectionID UniqueID, partitionID UniqueID) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
|
|
|
coll, ok := meta.collections[collectionID]
|
2021-01-15 17:09:41 +08:00
|
|
|
if !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return newErrCollectionNotFound(collectionID)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
2021-01-19 15:35:40 +08:00
|
|
|
|
2021-01-23 14:41:29 +08:00
|
|
|
for _, t := range coll.Partitions {
|
2021-01-19 15:35:40 +08:00
|
|
|
if t == partitionID {
|
2021-03-05 10:15:27 +08:00
|
|
|
return fmt.Errorf("partition %d already exists", partitionID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-23 14:41:29 +08:00
|
|
|
coll.Partitions = append(coll.Partitions, partitionID)
|
2021-01-19 15:35:40 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (meta *meta) DropPartition(collID UniqueID, partitionID UniqueID) error {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.Lock()
|
|
|
|
defer meta.Unlock()
|
2021-01-19 15:35:40 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
collection, ok := meta.collections[collID]
|
2021-01-19 15:35:40 +08:00
|
|
|
if !ok {
|
2021-01-22 11:07:07 +08:00
|
|
|
return newErrCollectionNotFound(collID)
|
2021-01-19 15:35:40 +08:00
|
|
|
}
|
|
|
|
idx := -1
|
2021-01-23 14:41:29 +08:00
|
|
|
for i, id := range collection.Partitions {
|
2021-01-19 15:35:40 +08:00
|
|
|
if partitionID == id {
|
|
|
|
idx = i
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if idx == -1 {
|
|
|
|
return fmt.Errorf("cannot find partition id %d", partitionID)
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
prefix := fmt.Sprintf("%s/%d/%d/", segmentPrefix, collID, partitionID)
|
|
|
|
if err := meta.client.RemoveWithPrefix(prefix); err != nil {
|
2021-02-02 14:25:58 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-01-23 14:41:29 +08:00
|
|
|
collection.Partitions = append(collection.Partitions[:idx], collection.Partitions[idx+1:]...)
|
2021-04-09 09:55:04 +08:00
|
|
|
|
|
|
|
for i, info := range meta.segments {
|
|
|
|
if info.PartitionID == partitionID {
|
|
|
|
delete(meta.segments, i)
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 15:35:40 +08:00
|
|
|
return nil
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-02-02 14:25:58 +08:00
|
|
|
func (meta *meta) GetNumRowsOfPartition(collectionID UniqueID, partitionID UniqueID) (int64, error) {
|
2021-04-09 09:55:04 +08:00
|
|
|
meta.RLock()
|
|
|
|
defer meta.RUnlock()
|
2021-02-02 14:25:58 +08:00
|
|
|
var ret int64 = 0
|
2021-04-09 09:55:04 +08:00
|
|
|
for _, info := range meta.segments {
|
2021-02-02 14:25:58 +08:00
|
|
|
if info.CollectionID == collectionID && info.PartitionID == partitionID {
|
|
|
|
ret += info.NumRows
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) saveSegmentInfo(segment *datapb.SegmentInfo) error {
|
|
|
|
segBytes := proto.MarshalTextString(segment)
|
2021-01-15 17:09:41 +08:00
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
key := fmt.Sprintf("%s/%d/%d/%d", segmentPrefix, segment.CollectionID, segment.PartitionID, segment.ID)
|
|
|
|
return meta.client.Save(key, segBytes)
|
2021-01-15 17:09:41 +08:00
|
|
|
}
|
|
|
|
|
2021-04-09 09:55:04 +08:00
|
|
|
func (meta *meta) removeSegmentInfo(segment *datapb.SegmentInfo) error {
|
|
|
|
key := fmt.Sprintf("%s/%d/%d/%d", segmentPrefix, segment.CollectionID, segment.PartitionID, segment.ID)
|
|
|
|
return meta.client.Remove(key)
|
2021-02-02 14:25:58 +08:00
|
|
|
}
|
|
|
|
|
2021-02-02 18:53:10 +08:00
|
|
|
func BuildSegment(collectionID UniqueID, partitionID UniqueID, segmentID UniqueID, channelName string) (*datapb.SegmentInfo, error) {
|
2021-01-25 15:17:17 +08:00
|
|
|
return &datapb.SegmentInfo{
|
2021-04-09 09:55:04 +08:00
|
|
|
ID: segmentID,
|
2021-02-02 18:53:10 +08:00
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionID: partitionID,
|
|
|
|
InsertChannel: channelName,
|
|
|
|
OpenTime: 0,
|
|
|
|
SealedTime: 0,
|
|
|
|
NumRows: 0,
|
|
|
|
MemSize: 0,
|
2021-03-11 14:14:29 +08:00
|
|
|
State: commonpb.SegmentState_Growing,
|
2021-03-12 14:22:09 +08:00
|
|
|
StartPosition: &internalpb.MsgPosition{
|
2021-03-02 15:52:42 +08:00
|
|
|
ChannelName: channelName,
|
2021-03-27 09:46:54 +08:00
|
|
|
MsgID: make([]byte, 0),
|
2021-03-02 15:52:42 +08:00
|
|
|
Timestamp: 0,
|
|
|
|
},
|
2021-03-12 14:22:09 +08:00
|
|
|
EndPosition: &internalpb.MsgPosition{
|
2021-03-02 15:52:42 +08:00
|
|
|
ChannelName: channelName,
|
2021-03-27 09:46:54 +08:00
|
|
|
MsgID: make([]byte, 0),
|
2021-03-02 15:52:42 +08:00
|
|
|
Timestamp: 0,
|
|
|
|
},
|
2021-01-25 15:17:17 +08:00
|
|
|
}, nil
|
|
|
|
}
|