MCPcopy Create free account
hub / github.com/araddon/qlbridge / Run

Method Run

exec/join.go:54–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54func (m *JoinKey) Run() error {
55 defer m.Ctx.Recover()
56 defer close(m.msgOutCh)
57
58 outCh := m.MessageOut()
59 inCh := m.MessageIn()
60 joinNodes := m.p.Source.Stmt.JoinNodes()
61
62 for {
63
64 select {
65 case <-m.SigChan():
66 //u.Debugf("got signal quit")
67 return nil
68 case msg, ok := <-inCh:
69 if !ok {
70 //u.Debugf("NICE, got msg shutdown")
71 return nil
72 }
73
74 //u.Infof("In joinkey msg %#v", msg)
75 msgTypeSwitch:
76 switch mt := msg.(type) {
77 case *datasource.SqlDriverMessageMap:
78 vals := make([]string, len(joinNodes))
79 for i, node := range joinNodes {
80 joinVal, ok := vm.Eval(mt, node)
81 //u.Debugf("evaluating: ok?%v T:%T result=%v node '%v'", ok, joinVal, joinVal.ToString(), node.String())
82 if !ok {
83 u.Errorf("could not evaluate: %T %#v %v", joinVal, joinVal, msg)
84 break msgTypeSwitch
85 }
86 vals[i] = joinVal.ToString()
87 }
88 //u.Infof("joinkey: %v row:%v", vals, mt)
89 key := strings.Join(vals, string(byte(0)))
90 mt.SetKeyHashed(key)
91 outCh <- mt
92 default:
93 return fmt.Errorf("To use JoinKey must use SqlDriverMessageMap but got %T", msg)
94 }
95
96 }
97 }
98}
99
100// Scans 2 source tasks for rows, evaluate keys, use for join
101//

Callers

nothing calls this directly

Calls 9

EvalFunction · 0.92
RecoverMethod · 0.80
JoinNodesMethod · 0.80
ErrorfMethod · 0.80
SetKeyHashedMethod · 0.80
MessageOutMethod · 0.65
MessageInMethod · 0.65
SigChanMethod · 0.65
ToStringMethod · 0.65

Tested by

no test coverage detected