Class 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()  
    • 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.
    • Constructor Detail

      • SimplestPlanner

        public SimplestPlanner()
    • Method Detail

      • setStorageManager

        public void setStorageManager​(StorageManager storageManager)
        Sets the server to be used during query planning.
        Specified by:
        setStorageManager in interface Planner
        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 interface Planner
        Parameters:
        selClause - an object describing the query to be performed
        enclosingSelects - a list of enclosing queries, if selClause is a nested subquery. This is allowed to be an empty list, or null, if the query is a top-level query. If selClause is a nested subquery, enclosingSelects[0] is the outermost enclosing query, then enclosingSelects[1] is enclosed by enclosingSelects[0], and so forth. The most tightly enclosing query is the last one in enclosingSelects.
        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 interface Planner
        Parameters:
        tableName - The name of the table that is being selected from.
        predicate - An optional selection predicate, or null if no filtering is desired.
        enclosingSelects - a list of enclosing queries, if selClause is a nested subquery. This is allowed to be an empty list, or null, if the query is a top-level query. If selClause is a nested subquery, enclosingSelects[0] is the outermost enclosing query, then enclosingSelects[1] is enclosed by enclosingSelects[0], and so forth. The most tightly enclosing query is the last one in enclosingSelects.
        Returns:
        A new plan-node for evaluating the select operation.