Class SubqueryMemo
java.lang.Object
dev.frostlake.executor.expressions.SubqueryMemo
Per-(outer-query) memo for subqueries that are evaluated once per outer row. A subquery is
uncorrelated if its execution reads no outer (lateral) value — in which case its result is
identical for every outer row, so it can be executed once and reused instead of re-executed per row.
Correlation is classified empirically: ExpressionEvaluatorVisitor counts actual
lateral-value reads, and a subquery whose first execution reads zero is provably row-independent
(any branch decision that depended on an outer value would itself have read one). The classification
is therefore exact and conservative — anything that touches the outer context is treated as
correlated and never cached.
Scope is one ExpressionEvaluator instance — i.e. one outer query's row loop, evaluated on
a single thread — so plain HashMap/HashSet suffice and cached results never leak
across queries.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncachedInSet(String subquery) Prepared IN-membership index for an uncorrelated subquery, ornullif not yet built.cachedResult(String subquery) The cached result of a proven-uncorrelated subquery, ornullif not (yet) cached.booleanisCorrelated(String subquery) True if this subquery has been proven correlated and must be re-executed per outer row.voidrecordCorrelated(String subquery) voidrecordInSet(String subquery, PreparedInSet set) voidrecordUncorrelated(String subquery, List<ResultSet> result)
-
Constructor Details
-
SubqueryMemo
public SubqueryMemo()
-
-
Method Details
-
cachedResult
The cached result of a proven-uncorrelated subquery, ornullif not (yet) cached. -
cachedInSet
Prepared IN-membership index for an uncorrelated subquery, ornullif not yet built. -
recordInSet
-