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 0
aggregateFunction - 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

  • Constructor Details

  • 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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • selectedColumns

      public List<String> selectedColumns()
      Returns the value of the selectedColumns record component.
      Returns:
      the value of the selectedColumns record component
    • mapName

      public String mapName()
      Returns the value of the mapName record component.
      Returns:
      the value of the mapName record component
    • wherePredicate

      public Predicate wherePredicate()
      Returns the value of the wherePredicate record component.
      Returns:
      the value of the wherePredicate record component
    • orderByList

      public List<QueryPlan.OrderBy> orderByList()
      Returns the value of the orderByList record component.
      Returns:
      the value of the orderByList record component
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • explicitLimit

      public boolean explicitLimit()
      Returns the value of the explicitLimit record component.
      Returns:
      the value of the explicitLimit record component
    • aggregateFunction

      public @Nullable QueryPlan.AggregateFunction aggregateFunction()
      Returns the value of the aggregateFunction record component.
      Returns:
      the value of the aggregateFunction record component