提交 1bd7938d 编写于 作者: N neza2017 提交者: yefu.chen

Modify logic of time tick

Signed-off-by: Nneza2017 <yefu.chen@zilliz.com>
上级 9a9bc4ec
...@@ -36,9 +36,9 @@ fmt: ...@@ -36,9 +36,9 @@ fmt:
lint: lint:
@echo "Running $@ check" @echo "Running $@ check"
@GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean @GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./internal/ || true @GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./internal/... || true
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./cmd/ || true @GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./cmd/... || true
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./test/ || true @GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=1m --config ./.golangci.yml ./test/... || true
ruleguard: ruleguard:
@echo "Running $@ check" @echo "Running $@ check"
......
...@@ -33,8 +33,8 @@ func GetMarshaler(MsgType MsgType) *TsMsgMarshaler { ...@@ -33,8 +33,8 @@ func GetMarshaler(MsgType MsgType) *TsMsgMarshaler {
searchResultMarshler := &SearchResultMarshaler{} searchResultMarshler := &SearchResultMarshaler{}
var tsMsgMarshaller TsMsgMarshaler = searchResultMarshler var tsMsgMarshaller TsMsgMarshaler = searchResultMarshler
return &tsMsgMarshaller return &tsMsgMarshaller
case KTimeSync: case KTimeTick:
timeSyncMarshaler := &TimeSyncMarshaler{} timeSyncMarshaler := &TimeTickMarshaler{}
var tsMsgMarshaller TsMsgMarshaler = timeSyncMarshaler var tsMsgMarshaller TsMsgMarshaler = timeSyncMarshaler
return &tsMsgMarshaller return &tsMsgMarshaller
default: default:
...@@ -145,10 +145,10 @@ func (srm *SearchResultMarshaler) Unmarshal(input []byte) (*TsMsg, commonPb.Stat ...@@ -145,10 +145,10 @@ func (srm *SearchResultMarshaler) Unmarshal(input []byte) (*TsMsg, commonPb.Stat
/////////////////////////////////////TimeSync/////////////////////////////////////////////// /////////////////////////////////////TimeSync///////////////////////////////////////////////
type TimeSyncMarshaler struct{} type TimeTickMarshaler struct{}
func (tm *TimeSyncMarshaler) Marshal(input *TsMsg) ([]byte, commonPb.Status) { func (tm *TimeTickMarshaler) Marshal(input *TsMsg) ([]byte, commonPb.Status) {
timeSyncTask := (*input).(TimeSyncTask) timeSyncTask := (*input).(TimeTickMsg)
timeSyncMsg := &timeSyncTask.TimeTickMsg timeSyncMsg := &timeSyncTask.TimeTickMsg
mb, err := proto.Marshal(timeSyncMsg) mb, err := proto.Marshal(timeSyncMsg)
if err != nil { if err != nil {
...@@ -157,10 +157,10 @@ func (tm *TimeSyncMarshaler) Marshal(input *TsMsg) ([]byte, commonPb.Status) { ...@@ -157,10 +157,10 @@ func (tm *TimeSyncMarshaler) Marshal(input *TsMsg) ([]byte, commonPb.Status) {
return mb, commonPb.Status{ErrorCode: commonPb.ErrorCode_SUCCESS} return mb, commonPb.Status{ErrorCode: commonPb.ErrorCode_SUCCESS}
} }
func (tm *TimeSyncMarshaler) Unmarshal(input []byte) (*TsMsg, commonPb.Status) { func (tm *TimeTickMarshaler) Unmarshal(input []byte) (*TsMsg, commonPb.Status) {
timeSyncMsg := internalPb.TimeTickMsg{} timeSyncMsg := internalPb.TimeTickMsg{}
err := proto.Unmarshal(input, &timeSyncMsg) err := proto.Unmarshal(input, &timeSyncMsg)
timeSyncTask := TimeSyncTask{TimeTickMsg: timeSyncMsg} timeSyncTask := TimeTickMsg{TimeTickMsg: timeSyncMsg}
if err != nil { if err != nil {
return nil, commonPb.Status{ErrorCode: commonPb.ErrorCode_UNEXPECTED_ERROR} return nil, commonPb.Status{ErrorCode: commonPb.ErrorCode_UNEXPECTED_ERROR}
} }
......
...@@ -85,17 +85,17 @@ func getTsMsg(msgType MsgType, reqId int64, hashValue int32) *TsMsg { ...@@ -85,17 +85,17 @@ func getTsMsg(msgType MsgType, reqId int64, hashValue int32) *TsMsg {
SearchResult: searchResult, SearchResult: searchResult,
} }
tsMsg = searchResultMsg tsMsg = searchResultMsg
case kTimeSync: case KTimeSync:
timeSyncResult := internalPb.TimeTickMsg{ timeSyncResult := internalPb.TimeTickMsg{
PeerId: reqId, PeerId: reqId,
Timestamp: 1, Timestamp: 1,
} }
timeSyncMsg := TimeSyncTask{ timeSyncMsg := TimeTickMsg{
HashValues: []int32{hashValue}, HashValues: []int32{hashValue},
TimeTickMsg: timeSyncResult, TimeTickMsg: timeSyncResult,
} }
tsMsg = timeSyncMsg tsMsg = timeSyncMsg
case kTimeTick: case KTimeTick:
insertRequest := internalPb.InsertRequest{ insertRequest := internalPb.InsertRequest{
ReqType: internalPb.ReqType_kTimeTick, ReqType: internalPb.ReqType_kTimeTick,
ReqId: reqId, ReqId: reqId,
...@@ -236,9 +236,9 @@ func TestStream_BroadCast(t *testing.T) { ...@@ -236,9 +236,9 @@ func TestStream_BroadCast(t *testing.T) {
consumerSubName := "subInsert" consumerSubName := "subInsert"
msgPack := MsgPack{} msgPack := MsgPack{}
msgPack.Msgs = append(msgPack.Msgs, getTsMsg(kTimeTick, 0, 0)) msgPack.Msgs = append(msgPack.Msgs, getTsMsg(KTimeTick, 0, 0))
msgPack.Msgs = append(msgPack.Msgs, getTsMsg(kTimeTick, 3, 3)) msgPack.Msgs = append(msgPack.Msgs, getTsMsg(KTimeTick, 3, 3))
//run stream //run stream
initStream(pulsarAddress, producerChannels, consumerChannels, consumerSubName, &msgPack, kInsert, kInsert) initStream(pulsarAddress, producerChannels, consumerChannels, consumerSubName, &msgPack, KInsert, KInsert)
} }
...@@ -184,28 +184,28 @@ func (srt SearchResultTask) HashKeys() []int32 { ...@@ -184,28 +184,28 @@ func (srt SearchResultTask) HashKeys() []int32 {
} }
/////////////////////////////////////////TimeSync////////////////////////////////////////// /////////////////////////////////////////TimeSync//////////////////////////////////////////
type TimeSyncTask struct { type TimeTickMsg struct {
HashValues []int32 HashValues []int32
internalPb.TimeTickMsg internalPb.TimeTickMsg
} }
func (tst TimeSyncTask) SetTs(ts Timestamp) { func (tst TimeTickMsg) SetTs(ts Timestamp) {
tst.Timestamp = uint64(ts) tst.Timestamp = uint64(ts)
} }
func (tst TimeSyncTask) BeginTs() Timestamp { func (tst TimeTickMsg) BeginTs() Timestamp {
return Timestamp(tst.Timestamp) return Timestamp(tst.Timestamp)
} }
func (tst TimeSyncTask) EndTs() Timestamp { func (tst TimeTickMsg) EndTs() Timestamp {
return Timestamp(tst.Timestamp) return Timestamp(tst.Timestamp)
} }
func (tst TimeSyncTask) Type() MsgType { func (tst TimeTickMsg) Type() MsgType {
return KTimeSync return KTimeSync
} }
func (tst TimeSyncTask) HashKeys() []int32 { func (tst TimeTickMsg) HashKeys() []int32 {
return tst.HashValues return tst.HashValues
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册