MCPcopy Create free account
hub / github.com/apache/cloudberry / cdbpathlocus_parallel_join

Function cdbpathlocus_parallel_join

src/backend/cdb/cdbpathlocus.c:1226–1476  ·  view source on GitHub ↗

* cdbpathlocus_parallel_join * This is parallel version of cdbpathlocus_join. * We only handle parallel join here(either path's parallel_works > 1, or both). */

Source from the content-addressed store, hash-verified

1224 * We only handle parallel join here(either path's parallel_works > 1, or both).
1225 */
1226CdbPathLocus
1227cdbpathlocus_parallel_join(JoinType jointype, CdbPathLocus a, CdbPathLocus b, bool parallel_aware)
1228{
1229 ListCell *acell;
1230 ListCell *bcell;
1231 CdbPathLocus resultlocus = {0};
1232 int numsegments;
1233 int outerParallel PG_USED_FOR_ASSERTS_ONLY = CdbPathLocus_NumParallelWorkers(a);
1234 int innerParallel PG_USED_FOR_ASSERTS_ONLY = CdbPathLocus_NumParallelWorkers(b);
1235
1236 Assert(cdbpathlocus_is_valid(a));
1237 Assert(cdbpathlocus_is_valid(b));
1238
1239 /* Do both input rels have same locus? */
1240 if (cdbpathlocus_equal(a, b))
1241 return a;
1242
1243 /*
1244 * SingleQE may have different segment counts.
1245 */
1246 if (CdbPathLocus_IsSingleQE(a) &&
1247 CdbPathLocus_IsSingleQE(b))
1248 {
1249 CdbPathLocus_MakeSingleQE(&resultlocus,
1250 CdbPathLocus_CommonSegments(a, b));
1251 return resultlocus;
1252 }
1253
1254 if (CdbPathLocus_IsGeneral(a))
1255 return b;
1256
1257 if (CdbPathLocus_IsGeneral(b))
1258 return a;
1259
1260 /*
1261 * If one rel is replicated, result stays with the other rel,
1262 * but need to ensure the result is on the common segments.
1263 */
1264 if (CdbPathLocus_IsReplicated(a))
1265 {
1266 b.numsegments = CdbPathLocus_CommonSegments(a, b);
1267 return b;
1268 }
1269 if (CdbPathLocus_IsReplicatedWorkers(a))
1270 {
1271 b.numsegments = CdbPathLocus_CommonSegments(a, b);
1272 if (CdbPathLocus_IsHashed(b))
1273 {
1274 b.locustype = CdbLocusType_HashedWorkers;
1275 }
1276 return b;
1277 }
1278 if (CdbPathLocus_IsReplicated(b) || CdbPathLocus_IsReplicatedWorkers(b))
1279 {
1280 a.numsegments = CdbPathLocus_CommonSegments(a, b);
1281 return a;
1282 }
1283

Callers 1

Calls 6

cdbpathlocus_is_validFunction · 0.85
cdbpathlocus_equalFunction · 0.85
list_lengthFunction · 0.85
forbothFunction · 0.85
list_union_ptrFunction · 0.85
lappendFunction · 0.85

Tested by

no test coverage detected