2021-04-19 13:42:47 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
|
2020-11-02 16:44:54 +08:00
|
|
|
package flowgraph
|
|
|
|
|
2021-03-25 14:41:46 +08:00
|
|
|
import (
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/msgstream"
|
2021-03-25 14:41:46 +08:00
|
|
|
)
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// Msg is an abstract class that contains a method to get the time tick of this message
|
2020-11-02 16:44:54 +08:00
|
|
|
type Msg interface {
|
|
|
|
TimeTick() Timestamp
|
|
|
|
}
|
2020-11-09 16:27:11 +08:00
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// MsgStreamMsg is a wrapper of TsMsg in flowgraph
|
2020-11-09 16:27:11 +08:00
|
|
|
type MsgStreamMsg struct {
|
2021-01-26 09:44:39 +08:00
|
|
|
tsMessages []msgstream.TsMsg
|
|
|
|
timestampMin Timestamp
|
|
|
|
timestampMax Timestamp
|
|
|
|
startPositions []*MsgPosition
|
2021-03-16 17:55:42 +08:00
|
|
|
endPositions []*MsgPosition
|
2020-11-09 16:27:11 +08:00
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// GenerateMsgStreamMsg is used to create a new MsgStreamMsg object
|
2021-03-16 17:55:42 +08:00
|
|
|
func GenerateMsgStreamMsg(tsMessages []msgstream.TsMsg, timestampMin, timestampMax Timestamp, startPos []*MsgPosition, endPos []*MsgPosition) *MsgStreamMsg {
|
2020-12-24 20:55:40 +08:00
|
|
|
return &MsgStreamMsg{
|
2021-01-26 09:44:39 +08:00
|
|
|
tsMessages: tsMessages,
|
|
|
|
timestampMin: timestampMin,
|
|
|
|
timestampMax: timestampMax,
|
2021-03-16 17:55:42 +08:00
|
|
|
startPositions: startPos,
|
|
|
|
endPositions: endPos,
|
2020-12-24 20:55:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// TimeTick returns the timetick of this message
|
2020-11-09 16:27:11 +08:00
|
|
|
func (msMsg *MsgStreamMsg) TimeTick() Timestamp {
|
|
|
|
return msMsg.timestampMax
|
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// DownStreamNodeIdx returns 0
|
2020-11-09 16:27:11 +08:00
|
|
|
func (msMsg *MsgStreamMsg) DownStreamNodeIdx() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// TsMessages returns the origin TsMsg object list
|
2020-11-17 14:10:07 +08:00
|
|
|
func (msMsg *MsgStreamMsg) TsMessages() []msgstream.TsMsg {
|
|
|
|
return msMsg.tsMessages
|
2020-11-09 16:27:11 +08:00
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// TimestampMin returns the minimal timestamp in the TsMsg list
|
2020-11-09 16:27:11 +08:00
|
|
|
func (msMsg *MsgStreamMsg) TimestampMin() Timestamp {
|
|
|
|
return msMsg.timestampMin
|
|
|
|
}
|
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// TimestampMax returns the maximal timestamp in the TsMsg list
|
2020-11-09 16:27:11 +08:00
|
|
|
func (msMsg *MsgStreamMsg) TimestampMax() Timestamp {
|
|
|
|
return msMsg.timestampMax
|
|
|
|
}
|
2021-01-26 09:44:39 +08:00
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// StartPositions returns the start position of TsMsgs
|
2021-01-26 09:44:39 +08:00
|
|
|
func (msMsg *MsgStreamMsg) StartPositions() []*MsgPosition {
|
|
|
|
return msMsg.startPositions
|
|
|
|
}
|
2021-03-16 17:55:42 +08:00
|
|
|
|
2021-10-04 22:38:02 +08:00
|
|
|
// EndPositions returns the end position of TsMsgs
|
2021-03-16 17:55:42 +08:00
|
|
|
func (msMsg *MsgStreamMsg) EndPositions() []*MsgPosition {
|
|
|
|
return msMsg.endPositions
|
|
|
|
}
|