Record Class QueryPlan
java.lang.Object
java.lang.Record
com.loomcache.server.query.QueryPlan
- Record Components:
selectedColumns- list of column names to project (non-empty; "*" means all columns)mapName- the map/table to query (non-null, non-blank)wherePredicate- the filter condition (non-null; TruePredicate if no WHERE clause)orderByList- list of sort specifications (non-null; empty if no ORDER BY)limit- maximum rows to return (Integer.MAX_VALUE= no limit)explicitLimit- true when the SQL text contained a LIMIT clause, including LIMIT 0aggregateFunction- aggregate function if present (e.g., COUNT, SUM), or null
public record QueryPlan(List<String> selectedColumns, String mapName, Predicate wherePredicate, List<QueryPlan.OrderBy> orderByList, int limit, boolean explicitLimit, @Nullable QueryPlan.AggregateFunction aggregateFunction)
extends Record
Represents a parsed SQL query in executable form.
Immutable record containing all information needed to execute the query. Validates constraints at construction time.
Typical workflow: 1. SqlParser parses SQL text → QueryPlan 2. QueryEngine executes QueryPlan → SqlResult 3. Client iterates/consumes SqlResult
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAggregate function specification (e.g., COUNT, SUM, AVG, MIN, MAX).static final recordJoin specification for SQL JOIN operations.static final recordOrderBy clause specifying column and sort direction. -
Constructor Summary
ConstructorsConstructorDescriptionQueryPlan(List<String> selectedColumns, String mapName, Predicate wherePredicate, List<QueryPlan.OrderBy> orderByList, int limit, boolean explicitLimit, @Nullable QueryPlan.AggregateFunction aggregateFunction) Compact constructor for validation.QueryPlan(List<String> selectedColumns, String mapName, Predicate wherePredicate, List<QueryPlan.OrderBy> orderByList, int limit, @Nullable QueryPlan.AggregateFunction aggregateFunction) -
Method Summary
Modifier and TypeMethodDescription@Nullable QueryPlan.AggregateFunctionReturns the value of theaggregateFunctionrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theexplicitLimitrecord component.booleanChecks if this query has an aggregate function.final inthashCode()Returns a hash code value for this object.booleanhasLimit()Checks if this query has a LIMIT clause.booleanChecks if this query has an ORDER BY clause.intlimit()Returns the value of thelimitrecord component.mapName()Returns the value of themapNamerecord component.Returns the value of theorderByListrecord component.Returns the value of theselectedColumnsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thewherePredicaterecord component.
-
Constructor Details
-
QueryPlan
public QueryPlan(List<String> selectedColumns, String mapName, Predicate wherePredicate, List<QueryPlan.OrderBy> orderByList, int limit, @Nullable QueryPlan.AggregateFunction aggregateFunction) -
QueryPlan
public QueryPlan(List<String> selectedColumns, String mapName, Predicate wherePredicate, List<QueryPlan.OrderBy> orderByList, int limit, boolean explicitLimit, @Nullable QueryPlan.AggregateFunction aggregateFunction) Compact constructor for validation.- Throws:
IllegalArgumentException- if constraints are violatedNullPointerException- if any required field is null
-
-
Method Details
-
hasAggregateFunction
public boolean hasAggregateFunction()Checks if this query has an aggregate function.- Returns:
- true if aggregateFunction is not null
-
hasOrderBy
public boolean hasOrderBy()Checks if this query has an ORDER BY clause.- Returns:
- true if orderByList is not empty
-
hasLimit
public boolean hasLimit()Checks if this query has a LIMIT clause.- Returns:
- true if SQL contained a LIMIT clause, including LIMIT 0
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
selectedColumns
Returns the value of theselectedColumnsrecord component.- Returns:
- the value of the
selectedColumnsrecord component
-
mapName
-
wherePredicate
Returns the value of thewherePredicaterecord component.- Returns:
- the value of the
wherePredicaterecord component
-
orderByList
Returns the value of theorderByListrecord component.- Returns:
- the value of the
orderByListrecord component
-
limit
-
explicitLimit
public boolean explicitLimit()Returns the value of theexplicitLimitrecord component.- Returns:
- the value of the
explicitLimitrecord component
-
aggregateFunction
Returns the value of theaggregateFunctionrecord component.- Returns:
- the value of the
aggregateFunctionrecord component
-