milvus/internal/dataservice/stats_handler.go
XuanYang-cn 1aafe86ffe Change MsgPosition Logic
Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
2021-02-04 11:19:48 +08:00

33 lines
718 B
Go

package dataservice
import (
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
)
type statsHandler struct {
meta *meta
}
func newStatsHandler(meta *meta) *statsHandler {
return &statsHandler{
meta: meta,
}
}
func (handler *statsHandler) HandleSegmentStat(segStats *internalpb2.SegmentStatisticsUpdates) error {
segMeta, err := handler.meta.GetSegment(segStats.SegmentID)
if err != nil {
return err
}
if segStats.IsNewSegment {
segMeta.OpenTime = segStats.CreateTime
segMeta.StartPosition = segStats.StartPosition
}
segMeta.SealedTime = segStats.EndTime
segMeta.NumRows = segStats.NumRows
segMeta.MemSize = segStats.MemorySize
return handler.meta.UpdateSegment(segMeta)
}