milvus/internal/writenode/flow_graph_insert_buffer_node.go
XuanYang-cn 881be7f3e3 Impl minimum runable writenode and writenode flowgraph
Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
2020-12-09 20:07:27 +08:00

62 lines
1.3 KiB
Go

package writenode
import (
"log"
)
type (
writeNode struct {
BaseNode
}
)
func (wNode *writeNode) Name() string {
return "wNode"
}
func (wNode *writeNode) Operate(in []*Msg) []*Msg {
log.Println("=========== WriteNode Operating")
if len(in) != 1 {
log.Println("Invalid operate message input in writetNode, input length = ", len(in))
// TODO: add error handling
}
iMsg, ok := (*in[0]).(*insertMsg)
if !ok {
log.Println("type assertion failed for insertMsg")
// TODO: add error handling
}
log.Println("=========== insertMsg length:", len(iMsg.insertMessages))
for _, task := range iMsg.insertMessages {
if len(task.RowIDs) != len(task.Timestamps) || len(task.RowIDs) != len(task.RowData) {
log.Println("Error, misaligned messages detected")
continue
}
log.Println("Timestamp: ", task.Timestamps[0])
log.Printf("t(%d) : %v ", task.Timestamps[0], task.RowData[0])
}
var res Msg = &serviceTimeMsg{
timeRange: iMsg.timeRange,
}
// TODO
return []*Msg{&res}
}
func newWriteNode() *writeNode {
maxQueueLength := Params.flowGraphMaxQueueLength()
maxParallelism := Params.flowGraphMaxParallelism()
baseNode := BaseNode{}
baseNode.SetMaxQueueLength(maxQueueLength)
baseNode.SetMaxParallelism(maxParallelism)
return &writeNode{
BaseNode: baseNode,
}
}