rewriting tree to distributed plan

moonshot/custom-path
Nils Dijk 2021-01-25 14:43:51 +01:00
parent 1aa86f6b1c
commit 089650db11
No known key found for this signature in database
GPG Key ID: CA1177EF9434F241
2 changed files with 119 additions and 37 deletions

View File

@ -739,11 +739,11 @@ typedef struct GeoJoinPathMatch
{ {
Const *stdwithinDistanceConst; Const *stdwithinDistanceConst;
AggPath *innerGrouping; // AggPath *innerGrouping;
DistributedUnionPath *innerDistUnion; DistributedUnionPath *innerDistUnion;
GeoScanPath *innerPath; GeoScanPath *innerPath;
AggPath *outerGrouping; // AggPath *outerGrouping;
DistributedUnionPath *outerDistUnion; DistributedUnionPath *outerDistUnion;
GeoScanPath *outerPath; GeoScanPath *outerPath;
} GeoJoinPathMatch; } GeoJoinPathMatch;
@ -755,6 +755,14 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
{ {
GeoJoinPathMatch match = { 0 }; GeoJoinPathMatch match = { 0 };
bool didMatch = false;
/*
* temporary nest the matcher till we figure out the final grouping, for now we need
* to be able to toggle between
*/
if (EnableGeoPartitioningGrouping)
{
IfPathMatch( IfPathMatch(
originalPath, originalPath,
MatchJoin( MatchJoin(
@ -778,7 +786,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
MatchGrouping( MatchGrouping(
&match.innerGrouping, NoCapture, /*&match.innerGrouping,*/
MatchDistributedUnion( MatchDistributedUnion(
&match.innerDistUnion, &match.innerDistUnion,
MatchGeoScan( MatchGeoScan(
@ -787,19 +795,92 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
MatchGrouping( MatchGrouping(
&match.outerGrouping, NoCapture, /*&match.outerGrouping,*/
MatchDistributedUnion(&match.outerDistUnion, MatchDistributedUnion(&match.outerDistUnion,
MatchGeoScan( MatchGeoScan(
&match.outerPath)))))) &match.outerPath))))))
{ {
/* have a match on the geo join pattern, all fields are stored in `match` */ didMatch = true;
ereport(DEBUG1, (errmsg("my custom code %p: %f", }
match.innerGrouping, }
DatumGetFloat8(match.stdwithinDistanceConst->constvalue) else
))); {
IfPathMatch(
originalPath,
MatchJoin(
NoCapture,
JOIN_INNER,
/* match on join restriction info */
MatchJoinRestrictions(
NoCapture,
MatchExprNamedOperation(
NoCapture,
geometry_overlaps,
MatchVar(NoCapture),
MatchExprNamedFunction(
NoCapture,
st_expand,
MatchVar(NoCapture),
MatchConst(
&match.stdwithinDistanceConst,
MatchFields(consttype == FLOAT8OID))))),
/* match inner path in join */
SkipReadThrough(
NoCapture,
MatchDistributedUnion(
&match.innerDistUnion,
MatchGeoScan(
&match.innerPath))),
/* match outer path in join */
SkipReadThrough(
NoCapture,
MatchDistributedUnion(&match.outerDistUnion,
MatchGeoScan(
&match.outerPath)))))
{
didMatch = true;
}
} }
(void) &match; if (didMatch)
{
/* have a match on the geo join pattern, all fields are stored in `match` */
ereport(DEBUG1, (errmsg("distance join with distance: %f",
DatumGetFloat8(match.stdwithinDistanceConst->constvalue)
)));
JoinPath *jpath = makeNode(NestPath);
*jpath = *((JoinPath *) originalPath); /* copy basic join settings */
jpath->path.type = T_NestPath;
jpath->innerjoinpath = (Path *) match.innerPath;
jpath->outerjoinpath = (Path *) match.outerPath;
// (Path *) create_append_path(
// root,
// match.outerPath->custom_path.path.parent,
// list_make1(match.outerPath), /* TODO add the result of the shuffled job */
// NIL,
// NIL,
// NULL,
// 0,
// false,
// NIL,
// match.outerPath->custom_path.path.rows + 0);
jpath->path.startup_cost -= 2000; /* remove the double dist union cost */
jpath->path.total_cost -= 2000; /* remove the double dist union cost */
/* TODO add grouping */
Path *newPath = (Path *) WrapTableAccessWithDistributedUnion(
(Path *) jpath,
match.innerDistUnion->colocationId,
match.innerDistUnion->partitionValue,
match.innerDistUnion->sampleRelid,
NIL); /* TODO is this ok? */
return list_make1(newPath);
}
return NIL; return NIL;
} }

View File

@ -163,6 +163,7 @@
\ \
PushStack(pathToMatch); \ PushStack(pathToMatch); \
pathToMatch = ((DistributedUnionPath *) pathToMatch)->worker_path; \ pathToMatch = ((DistributedUnionPath *) pathToMatch)->worker_path; \
matcher; \
PopStack(pathToMatch); \ PopStack(pathToMatch); \
DoCapture(capture, DistributedUnionPath *, pathToMatch); \ DoCapture(capture, DistributedUnionPath *, pathToMatch); \
} }