提交 1323bdb8 编写于 作者: B bigsheeper 提交者: yefu.chen

Update segment close time

Signed-off-by: Nbigsheeper <yihao.dai@zilliz.com>
上级 bb03b9bf
......@@ -3,6 +3,7 @@ package reader
import (
"context"
"fmt"
"log"
"path"
"reflect"
"strconv"
......@@ -48,6 +49,15 @@ func isSegmentObj(key string) bool {
return index == 0
}
func isSegmentChannelRangeInQueryNodeChannelRange(segment *mock.Segment) bool {
if segment.ChannelStart > segment.ChannelEnd {
log.Printf("Illegal segment channel range")
return false
}
// TODO: add query node channel range check
return true
}
func printCollectionStruct(obj *mock.Collection) {
v := reflect.ValueOf(obj)
v = reflect.Indirect(v)
......@@ -93,6 +103,11 @@ func (node *QueryNode) processSegmentCreate(id string, value string) {
println(err.Error())
}
printSegmentStruct(segment)
if !isSegmentChannelRangeInQueryNodeChannelRange(segment) {
return
}
collection := node.GetCollectionByID(segment.CollectionID)
if collection != nil {
partition := collection.GetPartitionByName(segment.PartitionTag)
......@@ -101,6 +116,7 @@ func (node *QueryNode) processSegmentCreate(id string, value string) {
// start new segment and add it into partition.OpenedSegments
newSegment := partition.NewSegment(newSegmentID)
newSegment.SegmentStatus = SegmentOpened
newSegment.SegmentCloseTime = -1
partition.OpenedSegments = append(partition.OpenedSegments, newSegment)
node.SegmentsMap[newSegmentID] = newSegment
}
......@@ -130,6 +146,11 @@ func (node *QueryNode) processSegmentModify(id string, value string) {
println(err.Error())
}
printSegmentStruct(segment)
if !isSegmentChannelRangeInQueryNodeChannelRange(segment) {
return
}
seg, err := node.GetSegmentBySegmentID(int64(segment.SegmentID)) // todo change to uint64
if seg != nil {
seg.SegmentCloseTime = segment.CloseTimeStamp
......
......@@ -19,7 +19,7 @@ func (node *QueryNode) SegmentsManagement() {
for _, partition := range collection.Partitions {
for _, oldSegment := range partition.OpenedSegments {
// TODO: check segment status
if timeNow >= oldSegment.SegmentCloseTime {
if oldSegment.SegmentCloseTime != -1 && timeNow >= oldSegment.SegmentCloseTime {
// close old segment and move it into partition.ClosedSegments
if oldSegment.SegmentStatus != SegmentOpened {
log.Println("Never reach here, Opened segment cannot be closed")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册