MCPcopy Create free account
hub / github.com/brimdata/super / replaceJoinWithHashJoin

Function replaceJoinWithHashJoin

compiler/optimizer/join.go:82–118  ·  view source on GitHub ↗
(seq dag.Seq)

Source from the content-addressed store, hash-verified

80}
81
82func replaceJoinWithHashJoin(seq dag.Seq) {
83 walkT(reflect.ValueOf(seq), func(op dag.Op) dag.Op {
84 j, ok := op.(*dag.JoinOp)
85 if !ok {
86 return op
87 }
88 var lefts, rights []dag.Expr
89 for _, e := range splitPredicate(j.Cond) {
90 left, right, ok := equiJoinKeyExprs(e, j.LeftAlias, j.RightAlias)
91 if !ok {
92 return op
93 }
94 lefts = append(lefts, left)
95 rights = append(rights, right)
96 }
97 var left, right dag.Expr
98 if len(lefts) == 1 {
99 left, right = lefts[0], rights[0]
100 } else {
101 // XXX Perhaps we should merge record expressions?
102 left = buildTuple(lefts)
103 right = buildTuple(rights)
104 }
105 style := j.Style
106 if style == "cross" {
107 style = "inner"
108 }
109 return &dag.HashJoinOp{
110 Kind: "HashJoinOp",
111 Style: style,
112 LeftAlias: j.LeftAlias,
113 RightAlias: j.RightAlias,
114 LeftKey: left,
115 RightKey: right,
116 }
117 })
118}
119
120func buildTuple(exprs []dag.Expr) dag.Expr {
121 var elems []dag.RecordElem

Callers 1

OptimizeMethod · 0.85

Calls 4

walkTFunction · 0.85
splitPredicateFunction · 0.85
equiJoinKeyExprsFunction · 0.85
buildTupleFunction · 0.85

Tested by

no test coverage detected