Package edu.caltech.nanodb.queryeval
Class SimplestPlanner
- java.lang.Object
-
- edu.caltech.nanodb.queryeval.SimplestPlanner
-
- All Implemented Interfaces:
Planner
public class SimplestPlanner extends java.lang.Object implements Planner
This class generates execution plans for very simple SQL SELECT * FROM tbl [WHERE P] queries. The primary responsibility is to generate plans for SQL SELECT statements, but UPDATE and DELETE expressions will also use this class to generate simple plans to identify the tuples to update or delete.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.protected StorageManager
storageManager
The storage manager used during query planning.
-
Constructor Summary
Constructors Constructor Description SimplestPlanner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlanNode
makePlan(SelectClause selClause, java.util.List<SelectClause> enclosingSelects)
Returns the root of a plan tree suitable for executing the specified query.SelectNode
makeSimpleSelect(java.lang.String tableName, Expression predicate, java.util.List<SelectClause> enclosingSelects)
Constructs a simple select plan that reads directly from a table, with an optional predicate for selecting rows.void
setStorageManager(StorageManager storageManager)
Sets the server to be used during query planning.
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
storageManager
protected StorageManager storageManager
The storage manager used during query planning.
-
-
Method Detail
-
setStorageManager
public void setStorageManager(StorageManager storageManager)
Sets the server to be used during query planning.- Specified by:
setStorageManager
in interfacePlanner
- Parameters:
storageManager
- the storage manager instance for the planner implementation to use
-
makePlan
public PlanNode makePlan(SelectClause selClause, java.util.List<SelectClause> enclosingSelects)
Returns the root of a plan tree suitable for executing the specified query.- Specified by:
makePlan
in interfacePlanner
- Parameters:
selClause
- an object describing the query to be performedenclosingSelects
- a list of enclosing queries, ifselClause
is a nested subquery. This is allowed to be an empty list, ornull
, if the query is a top-level query. IfselClause
is a nested subquery,enclosingSelects[0]
is the outermost enclosing query, thenenclosingSelects[1]
is enclosed byenclosingSelects[0]
, and so forth. The most tightly enclosing query is the last one inenclosingSelects
.- Returns:
- a plan tree for executing the specified query
-
makeSimpleSelect
public SelectNode makeSimpleSelect(java.lang.String tableName, Expression predicate, java.util.List<SelectClause> enclosingSelects)
Constructs a simple select plan that reads directly from a table, with an optional predicate for selecting rows.While this method can be used for building up larger SELECT queries, the returned plan is also suitable for use in UPDATE and DELETE command evaluation. In these cases, the plan must only generate tuples of type
PageTuple
, so that the command can modify or delete the actual tuple in the file's page data.- Specified by:
makeSimpleSelect
in interfacePlanner
- Parameters:
tableName
- The name of the table that is being selected from.predicate
- An optional selection predicate, ornull
if no filtering is desired.enclosingSelects
- a list of enclosing queries, ifselClause
is a nested subquery. This is allowed to be an empty list, ornull
, if the query is a top-level query. IfselClause
is a nested subquery,enclosingSelects[0]
is the outermost enclosing query, thenenclosingSelects[1]
is enclosed byenclosingSelects[0]
, and so forth. The most tightly enclosing query is the last one inenclosingSelects
.- Returns:
- A new plan-node for evaluating the select operation.
-
-