16
16
import io .trino .operator .join .JoinBridgeManager ;
17
17
import io .trino .operator .join .JoinProbe .JoinProbeFactory ;
18
18
import io .trino .operator .join .LookupJoinOperatorFactory ;
19
- import io .trino .operator .join .LookupJoinOperatorFactory .JoinType ;
20
19
import io .trino .operator .join .LookupSourceFactory ;
20
+ import io .trino .operator .join .unspilled .PartitionedLookupSourceFactory ;
21
21
import io .trino .spi .type .Type ;
22
22
import io .trino .spiller .PartitioningSpillerFactory ;
23
23
import io .trino .sql .planner .plan .PlanNodeId ;
29
29
import java .util .stream .IntStream ;
30
30
31
31
import static com .google .common .collect .ImmutableList .toImmutableList ;
32
- import static io .trino .operator .join .LookupJoinOperatorFactory .JoinType .FULL_OUTER ;
33
- import static io .trino .operator .join .LookupJoinOperatorFactory .JoinType .INNER ;
34
- import static io .trino .operator .join .LookupJoinOperatorFactory .JoinType .LOOKUP_OUTER ;
35
- import static io .trino .operator .join .LookupJoinOperatorFactory .JoinType .PROBE_OUTER ;
36
32
37
33
public class TrinoOperatorFactories
38
34
implements OperatorFactories
39
35
{
40
36
@ Override
41
- public OperatorFactory innerJoin (
37
+ public OperatorFactory join (
38
+ JoinOperatorType joinType ,
42
39
int operatorId ,
43
40
PlanNodeId planNodeId ,
44
- JoinBridgeManager <?> lookupSourceFactory ,
45
- boolean outputSingleMatch ,
46
- boolean waitForBuild ,
41
+ JoinBridgeManager <? extends PartitionedLookupSourceFactory > lookupSourceFactory ,
47
42
boolean hasFilter ,
48
- boolean spillingEnabled ,
49
43
List <Type > probeTypes ,
50
44
List <Integer > probeJoinChannel ,
51
45
OptionalInt probeHashChannel ,
52
- Optional <List <Integer >> probeOutputChannels ,
53
- OptionalInt totalOperatorsCount ,
54
- PartitioningSpillerFactory partitioningSpillerFactory ,
46
+ Optional <List <Integer >> probeOutputChannelsOptional ,
55
47
BlockTypeOperators blockTypeOperators )
56
48
{
57
- return createJoinOperatorFactory (
58
- operatorId ,
59
- planNodeId ,
60
- lookupSourceFactory ,
61
- probeTypes ,
62
- probeJoinChannel ,
63
- probeHashChannel ,
64
- probeOutputChannels .orElse (rangeList (probeTypes .size ())),
65
- INNER ,
66
- outputSingleMatch ,
67
- waitForBuild ,
68
- spillingEnabled ,
69
- totalOperatorsCount ,
70
- partitioningSpillerFactory ,
71
- blockTypeOperators );
72
- }
49
+ List <Integer > probeOutputChannels = probeOutputChannelsOptional .orElse (rangeList (probeTypes .size ()));
50
+ List <Type > probeOutputChannelTypes = probeOutputChannels .stream ()
51
+ .map (probeTypes ::get )
52
+ .collect (toImmutableList ());
73
53
74
- @ Override
75
- public OperatorFactory probeOuterJoin (
76
- int operatorId ,
77
- PlanNodeId planNodeId ,
78
- JoinBridgeManager <?> lookupSourceFactory ,
79
- boolean outputSingleMatch ,
80
- boolean hasFilter ,
81
- boolean spillingEnabled ,
82
- List <Type > probeTypes ,
83
- List <Integer > probeJoinChannel ,
84
- OptionalInt probeHashChannel ,
85
- Optional <List <Integer >> probeOutputChannels ,
86
- OptionalInt totalOperatorsCount ,
87
- PartitioningSpillerFactory partitioningSpillerFactory ,
88
- BlockTypeOperators blockTypeOperators )
89
- {
90
- return createJoinOperatorFactory (
54
+ return new io .trino .operator .join .unspilled .LookupJoinOperatorFactory (
91
55
operatorId ,
92
56
planNodeId ,
93
57
lookupSourceFactory ,
94
58
probeTypes ,
59
+ probeOutputChannelTypes ,
60
+ lookupSourceFactory .getBuildOutputTypes (),
61
+ joinType ,
62
+ new JoinProbeFactory (probeOutputChannels .stream ().mapToInt (i -> i ).toArray (), probeJoinChannel , probeHashChannel ),
63
+ blockTypeOperators ,
95
64
probeJoinChannel ,
96
- probeHashChannel ,
97
- probeOutputChannels .orElse (rangeList (probeTypes .size ())),
98
- PROBE_OUTER ,
99
- outputSingleMatch ,
100
- false ,
101
- spillingEnabled ,
102
- totalOperatorsCount ,
103
- partitioningSpillerFactory ,
104
- blockTypeOperators );
65
+ probeHashChannel );
105
66
}
106
67
107
68
@ Override
108
- public OperatorFactory lookupOuterJoin (
69
+ public OperatorFactory spillingJoin (
70
+ JoinOperatorType joinType ,
109
71
int operatorId ,
110
72
PlanNodeId planNodeId ,
111
- JoinBridgeManager <?> lookupSourceFactory ,
112
- boolean waitForBuild ,
73
+ JoinBridgeManager <? extends LookupSourceFactory > lookupSourceFactory ,
113
74
boolean hasFilter ,
114
- boolean spillingEnabled ,
115
75
List <Type > probeTypes ,
116
76
List <Integer > probeJoinChannel ,
117
77
OptionalInt probeHashChannel ,
118
- Optional <List <Integer >> probeOutputChannels ,
78
+ Optional <List <Integer >> probeOutputChannelsOptional ,
119
79
OptionalInt totalOperatorsCount ,
120
80
PartitioningSpillerFactory partitioningSpillerFactory ,
121
81
BlockTypeOperators blockTypeOperators )
122
82
{
123
- return createJoinOperatorFactory (
124
- operatorId ,
125
- planNodeId ,
126
- lookupSourceFactory ,
127
- probeTypes ,
128
- probeJoinChannel ,
129
- probeHashChannel ,
130
- probeOutputChannels .orElse (rangeList (probeTypes .size ())),
131
- LOOKUP_OUTER ,
132
- false ,
133
- waitForBuild ,
134
- spillingEnabled ,
135
- totalOperatorsCount ,
136
- partitioningSpillerFactory ,
137
- blockTypeOperators );
138
- }
83
+ List <Integer > probeOutputChannels = probeOutputChannelsOptional .orElse (rangeList (probeTypes .size ()));
84
+ List <Type > probeOutputChannelTypes = probeOutputChannels .stream ()
85
+ .map (probeTypes ::get )
86
+ .collect (toImmutableList ());
139
87
140
- @ Override
141
- public OperatorFactory fullOuterJoin (
142
- int operatorId ,
143
- PlanNodeId planNodeId ,
144
- JoinBridgeManager <?> lookupSourceFactory ,
145
- boolean hasFilter ,
146
- boolean spillingEnabled ,
147
- List <Type > probeTypes ,
148
- List <Integer > probeJoinChannel ,
149
- OptionalInt probeHashChannel ,
150
- Optional <List <Integer >> probeOutputChannels ,
151
- OptionalInt totalOperatorsCount ,
152
- PartitioningSpillerFactory partitioningSpillerFactory ,
153
- BlockTypeOperators blockTypeOperators )
154
- {
155
- return createJoinOperatorFactory (
88
+ return new LookupJoinOperatorFactory (
156
89
operatorId ,
157
90
planNodeId ,
158
91
lookupSourceFactory ,
159
92
probeTypes ,
93
+ probeOutputChannelTypes ,
94
+ lookupSourceFactory .getBuildOutputTypes (),
95
+ joinType ,
96
+ new JoinProbeFactory (probeOutputChannels .stream ().mapToInt (i -> i ).toArray (), probeJoinChannel , probeHashChannel ),
97
+ blockTypeOperators ,
98
+ totalOperatorsCount ,
160
99
probeJoinChannel ,
161
100
probeHashChannel ,
162
- probeOutputChannels .orElse (rangeList (probeTypes .size ())),
163
- FULL_OUTER ,
164
- false ,
165
- false ,
166
- spillingEnabled ,
167
- totalOperatorsCount ,
168
- partitioningSpillerFactory ,
169
- blockTypeOperators );
101
+ partitioningSpillerFactory );
170
102
}
171
103
172
104
private static List <Integer > rangeList (int endExclusive )
@@ -175,59 +107,4 @@ private static List<Integer> rangeList(int endExclusive)
175
107
.boxed ()
176
108
.collect (toImmutableList ());
177
109
}
178
-
179
- private OperatorFactory createJoinOperatorFactory (
180
- int operatorId ,
181
- PlanNodeId planNodeId ,
182
- JoinBridgeManager <?> lookupSourceFactoryManager ,
183
- List <Type > probeTypes ,
184
- List <Integer > probeJoinChannel ,
185
- OptionalInt probeHashChannel ,
186
- List <Integer > probeOutputChannels ,
187
- JoinType joinType ,
188
- boolean outputSingleMatch ,
189
- boolean waitForBuild ,
190
- boolean spillingEnabled ,
191
- OptionalInt totalOperatorsCount ,
192
- PartitioningSpillerFactory partitioningSpillerFactory ,
193
- BlockTypeOperators blockTypeOperators )
194
- {
195
- List <Type > probeOutputChannelTypes = probeOutputChannels .stream ()
196
- .map (probeTypes ::get )
197
- .collect (toImmutableList ());
198
-
199
- if (spillingEnabled ) {
200
- return new LookupJoinOperatorFactory (
201
- operatorId ,
202
- planNodeId ,
203
- (JoinBridgeManager <? extends LookupSourceFactory >) lookupSourceFactoryManager ,
204
- probeTypes ,
205
- probeOutputChannelTypes ,
206
- lookupSourceFactoryManager .getBuildOutputTypes (),
207
- joinType ,
208
- outputSingleMatch ,
209
- waitForBuild ,
210
- new JoinProbeFactory (probeOutputChannels .stream ().mapToInt (i -> i ).toArray (), probeJoinChannel , probeHashChannel ),
211
- blockTypeOperators ,
212
- totalOperatorsCount ,
213
- probeJoinChannel ,
214
- probeHashChannel ,
215
- partitioningSpillerFactory );
216
- }
217
-
218
- return new io .trino .operator .join .unspilled .LookupJoinOperatorFactory (
219
- operatorId ,
220
- planNodeId ,
221
- (JoinBridgeManager <? extends io .trino .operator .join .unspilled .PartitionedLookupSourceFactory >) lookupSourceFactoryManager ,
222
- probeTypes ,
223
- probeOutputChannelTypes ,
224
- lookupSourceFactoryManager .getBuildOutputTypes (),
225
- joinType ,
226
- outputSingleMatch ,
227
- waitForBuild ,
228
- new JoinProbeFactory (probeOutputChannels .stream ().mapToInt (i -> i ).toArray (), probeJoinChannel , probeHashChannel ),
229
- blockTypeOperators ,
230
- probeJoinChannel ,
231
- probeHashChannel );
232
- }
233
110
}
0 commit comments