Update segment struct and change collection to collection id

Signed-off-by: rain <boyan.wang@zilliz.com>
pull/4973/head^2
rain 2020-09-16 10:40:04 +08:00 committed by yefu.chen
parent 9ccf5c1c7d
commit 455b3ace2f
4 changed files with 23 additions and 18 deletions

View File

@ -11,3 +11,14 @@ go run cmd/master.go
```
## Start with docker
## What rules does master use to write data to kv storage?
1.find the root path variable ```ETCD_ROOT_PATH ```which defined in common/config.go
2.add prefix path ```segment``` if the resource is a segement
3.add prefix path ```collection``` if the resource is a collection
4.add resource uuid
### example
if master create a collection with uuid ```46e468ee-b34a-419d-85ed-80c56bfa4e90```
the corresponding key in etcd is /$(ETCD_ROOT_PATH)/collection/46e468ee-b34a-419d-85ed-80c56bfa4e90

View File

@ -35,19 +35,19 @@ func SegmentUnMarshal(data []byte) (SegmentStats, error) {
}
type Segment struct {
SegmentID uint64 `json:"segment_id"`
Collection Collection `json:"collection"`
PartitionTag string `json:"partition_tag"`
ChannelStart int `json:"channel_start"`
ChannelEnd int `json:"channel_end"`
OpenTimeStamp uint64 `json:"open_timestamp"`
CloseTimeStamp uint64 `json:"close_timestamp"`
SegmentID uint64 `json:"segment_id"`
CollectionID uint64 `json:"collection_id"`
PartitionTag string `json:"partition_tag"`
ChannelStart int `json:"channel_start"`
ChannelEnd int `json:"channel_end"`
OpenTimeStamp uint64 `json:"open_timestamp"`
CloseTimeStamp uint64 `json:"close_timestamp"`
}
func NewSegment(id uuid.UUID, collection Collection, ptag string, chStart int, chEnd int, openTime time.Time, closeTime time.Time) Segment {
func NewSegment(id uuid.UUID, collectioID uuid.UUID, ptag string, chStart int, chEnd int, openTime time.Time, closeTime time.Time) Segment {
return Segment{
SegmentID: uint64(id.ID()),
Collection: collection,
CollectionID: uint64(id.ID()),
PartitionTag: ptag,
ChannelStart: chStart,
ChannelEnd: chEnd,

View File

@ -30,14 +30,8 @@ func TestSegmentMarshal(t *testing.T) {
}
var Ts = Segment{
SegmentID: uint64(101111),
Collection: Collection{
ID: uint64(11111),
Name: "test-collection",
CreateTime: uint64(time.Now().Unix()),
SegmentIDs: []uint64{uint64(10111)},
PartitionTags: []string{"default"},
},
SegmentID: uint64(101111),
CollectionID: uint64(12010101),
PartitionTag: "default",
ChannelStart: 1,
ChannelEnd: 100,

View File

@ -129,7 +129,7 @@ func CollectionController(ch chan *messagepb.Mapping) {
time.Now(), fieldMetas, []uuid.UUID{sID},
[]string{"default"})
cm := mock.GrpcMarshal(&c)
s := mock.NewSegment(sID, c, "default", 0, 100, time.Now(), time.Unix(1<<36-1, 0))
s := mock.NewSegment(sID, cID, "default", 0, 100, time.Now(), time.Unix(1<<36-1, 0))
collectionData, _ := mock.Collection2JSON(*cm)
segmentData, err := mock.Segment2JSON(s)
if err != nil {