Skip to content

Commit

Permalink
fix: Refactor VLE Logic. (#598)
Browse files Browse the repository at this point in the history
Previously, AgensGraph(NestLoopVLEJoin) was strongly combined with other
executors. This makes it difficult to identify PG's own code and AgensGraph
code, and it has a form that cannot be combined with other storage.

Due to this work, it will be easier to simplify merging upstream postgresql
source. also, help implement graph storage in the future.
  • Loading branch information
emotionbug authored Dec 15, 2022
1 parent 990416a commit daf2dd4
Show file tree
Hide file tree
Showing 57 changed files with 1,350 additions and 2,873 deletions.
50 changes: 22 additions & 28 deletions src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
pname = sname = "BitmapOr";
break;
case T_NestLoop:
case T_NestLoopVLE:
pname = sname = "Nested Loop";
break;
case T_MergeJoin:
Expand Down Expand Up @@ -1432,6 +1431,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
case T_Dijkstra:
pname = sname = "Dijkstra";
break;
case T_GraphVLE:
pname = sname = "Graph VLE";
break;
default:
pname = sname = "???";
break;
Expand Down Expand Up @@ -1557,7 +1559,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
}
break;
case T_NestLoop:
case T_NestLoopVLE:
case T_MergeJoin:
case T_HashJoin:
{
Expand Down Expand Up @@ -1589,9 +1590,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
case JOIN_CYPHER_DELETE:
jointype = "CypherDelete";
break;
case JOIN_VLE:
jointype = "VLE";
break;
default:
jointype = "???";
break;
Expand All @@ -1602,18 +1600,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
* For historical reasons, the join type is interpolated
* into the node type name...
*/
if (((Join *) plan)->jointype == JOIN_VLE)
{
NestLoopVLE *nlvPlan = (NestLoopVLE *) plan;

appendStringInfo(es->str, " %s [%d..",
jointype, nlvPlan->minHops);
if (nlvPlan->maxHops != -1)
appendStringInfo(es->str, "%d]", nlvPlan->maxHops);
else
appendStringInfo(es->str, "]");
}
else if (((Join *) plan)->jointype != JOIN_INNER)
if (((Join *) plan)->jointype != JOIN_INNER)
{
appendStringInfo(es->str, " %s Join", jointype);
}
Expand Down Expand Up @@ -1654,6 +1641,21 @@ ExplainNode(PlanState *planstate, List *ancestors,
ExplainPropertyText("Command", setopcmd, es);
}
break;
case T_GraphVLE:
{
GraphVLE *graph_vle = (GraphVLE *) plan;
CypherRel *cypher_rel = (CypherRel *) graph_vle->vle_rel;
A_Indices *rel_indices = (A_Indices *) cypher_rel->varlen;

appendStringInfo(es->str, " [%d..",
((A_Const *) rel_indices->lidx)->val.val.ival);
if (rel_indices->uidx != NULL)
appendStringInfo(es->str, "%d]",
((A_Const *) rel_indices->uidx)->val.val.ival);
else
appendStringInfo(es->str, "]");
}
break;
default:
break;
}
Expand Down Expand Up @@ -2033,17 +2035,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
show_instrumentation_count("Rows Removed by Filter", 2,
planstate, es);
break;
case T_NestLoopVLE:
show_upper_qual(((NestLoopVLE *) plan)->nl.join.joinqual,
"Join Filter", planstate, ancestors, es);
if (((NestLoopVLE *) plan)->nl.join.joinqual)
show_instrumentation_count("Rows Removed by Join Filter", 1,
planstate, es);
show_upper_qual(plan->qual, "Filter", planstate, ancestors, es);
if (plan->qual)
show_instrumentation_count("Rows Removed by Filter", 2,
planstate, es);
break;
case T_MergeJoin:
show_upper_qual(((MergeJoin *) plan)->mergeclauses,
"Merge Cond", planstate, ancestors, es);
Expand Down Expand Up @@ -2284,6 +2275,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
ExplainNode(((ModifyGraphState *) planstate)->subplan, ancestors,
"Subquery", NULL, es);
break;
case T_GraphVLE:
ExplainNode(((GraphVLEState *) planstate)->subplan, ancestors,
"Subquery", NULL, es);
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/executor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ OBJS = \
execCypherSet.o \
execCypherMerge.o \
nodeModifyGraph.o \
nodeNestloopVle.o \
nodeHash2Side.o \
nodeShortestpath.o \
nodeDijkstra.o
nodeDijkstra.o \
execGraphVle.o

include $(top_srcdir)/src/backend/common.mk
68 changes: 5 additions & 63 deletions src/backend/executor/execAmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "executor/nodeNamedtuplestorescan.h"
#include "executor/nodeNestloop.h"
#include "executor/nodeProjectSet.h"
#include "executor/nodeNestloopVle.h"
#include "executor/nodeRecursiveunion.h"
#include "executor/nodeResult.h"
#include "executor/nodeResultCache.h"
Expand All @@ -67,6 +66,7 @@
#include "nodes/pathnodes.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "executor/execGraphVle.h"

static bool IndexSupportsBackwardScan(Oid indexid);

Expand Down Expand Up @@ -247,10 +247,6 @@ ExecReScan(PlanState *node)
ExecReScanNestLoop((NestLoopState *) node);
break;

case T_NestLoopVLEState:
ExecReScanNestLoopVLE((NestLoopVLEState *) node);
break;

case T_MergeJoinState:
ExecReScanMergeJoin((MergeJoinState *) node);
break;
Expand Down Expand Up @@ -319,6 +315,10 @@ ExecReScan(PlanState *node)
ExecReScanDijkstra((DijkstraState *) node);
break;

case T_GraphVLEState:
ExecReScanGraphVLE((GraphVLEState *) node);
break;

default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
break;
Expand All @@ -331,64 +331,6 @@ ExecReScan(PlanState *node)
}
}

void
ExecNextContext(PlanState *node)
{
switch (nodeTag(node))
{
case T_SeqScanState:
ExecNextSeqScanContext((SeqScanState *) node);
break;
case T_IndexScanState:
ExecNextIndexScanContext((IndexScanState *) node);
break;
case T_IndexOnlyScanState:
ExecNextIndexOnlyScanContext((IndexOnlyScanState *) node);
break;
case T_AppendState:
ExecNextAppendContext((AppendState *) node);
break;
case T_ResultState:
ExecNextResultContext((ResultState *) node);
break;
case T_NestLoopState:
ExecNextNestLoopContext((NestLoopState *) node);
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
break;
}
}

void
ExecPrevContext(PlanState *node)
{
switch (nodeTag(node))
{
case T_SeqScanState:
ExecPrevSeqScanContext((SeqScanState *) node);
break;
case T_IndexScanState:
ExecPrevIndexScanContext((IndexScanState *) node);
break;
case T_IndexOnlyScanState:
ExecPrevIndexOnlyScanContext((IndexOnlyScanState *) node);
break;
case T_AppendState:
ExecPrevAppendContext((AppendState *) node);
break;
case T_ResultState:
ExecPrevResultContext((ResultState *) node);
break;
case T_NestLoopState:
ExecPrevNestLoopContext((NestLoopState *) node);
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
break;
}
}

/*
* ExecMarkPos
*
Expand Down
Loading

0 comments on commit daf2dd4

Please sign in to comment.