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

Function ExecInitMemoize

src/backend/executor/nodeMemoize.c:909–1032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907}
908
909MemoizeState *
910ExecInitMemoize(Memoize *node, EState *estate, int eflags)
911{
912 MemoizeState *mstate = makeNode(MemoizeState);
913 Plan *outerNode;
914 int i;
915 int nkeys;
916 Oid *eqfuncoids;
917
918 /* check for unsupported flags */
919 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
920
921 mstate->ss.ps.plan = (Plan *) node;
922 mstate->ss.ps.state = estate;
923 mstate->ss.ps.ExecProcNode = ExecMemoize;
924
925 /*
926 * Miscellaneous initialization
927 *
928 * create expression context for node
929 */
930 ExecAssignExprContext(estate, &mstate->ss.ps);
931
932 outerNode = outerPlan(node);
933 outerPlanState(mstate) = ExecInitNode(outerNode, estate, eflags);
934
935 /*
936 * Initialize return slot and type. No need to initialize projection info
937 * because this node doesn't do projections.
938 */
939 ExecInitResultTupleSlotTL(&mstate->ss.ps, &TTSOpsMinimalTuple);
940 mstate->ss.ps.ps_ProjInfo = NULL;
941
942 /*
943 * Initialize scan slot and type.
944 */
945 ExecCreateScanSlotFromOuterPlan(estate, &mstate->ss, &TTSOpsMinimalTuple);
946
947 /*
948 * Set the state machine to lookup the cache. We won't find anything
949 * until we cache something, but this saves a special case to create the
950 * first entry.
951 */
952 mstate->mstatus = MEMO_CACHE_LOOKUP;
953
954 mstate->nkeys = nkeys = node->numKeys;
955 mstate->hashkeydesc = ExecTypeFromExprList(node->param_exprs);
956 mstate->tableslot = MakeSingleTupleTableSlot(mstate->hashkeydesc,
957 &TTSOpsMinimalTuple);
958 mstate->probeslot = MakeSingleTupleTableSlot(mstate->hashkeydesc,
959 &TTSOpsVirtual);
960
961 mstate->param_exprs = (ExprState **) palloc(nkeys * sizeof(ExprState *));
962 mstate->collations = node->collations; /* Just point directly to the plan
963 * data */
964 mstate->hashfunctions = (FmgrInfo *) palloc(nkeys * sizeof(FmgrInfo));
965
966 eqfuncoids = palloc(nkeys * sizeof(Oid));

Callers 1

ExecInitNodeFunction · 0.85

Calls 15

ExecAssignExprContextFunction · 0.85
ExecInitNodeFunction · 0.85
ExecTypeFromExprListFunction · 0.85
MakeSingleTupleTableSlotFunction · 0.85
list_nthFunction · 0.85
get_op_hash_functionsFunction · 0.85
fmgr_infoFunction · 0.85
ExecInitExprFunction · 0.85
get_opcodeFunction · 0.85
ExecBuildParamSetEqualFunction · 0.85

Tested by

no test coverage detected