You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sp...@apache.org on 2016/12/11 17:45:36 UTC

[13/51] [abbrv] [partial] incubator-quickstep git commit: remove c++ files

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/ExecutionGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp
deleted file mode 100644
index 55197c9..0000000
--- a/query_optimizer/ExecutionGenerator.hpp
+++ /dev/null
@@ -1,442 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_EXECUTION_GENERATOR_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_EXECUTION_GENERATOR_HPP_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#ifdef QUICKSTEP_DISTRIBUTED
-#include <unordered_set>
-#endif
-
-#include <vector>
-
-#include "catalog/CatalogTypedefs.hpp"
-#include "query_execution/QueryContext.hpp"
-#include "query_execution/QueryContext.pb.h"
-#include "query_optimizer/LIPFilterGenerator.hpp"
-#include "query_optimizer/QueryHandle.hpp"
-#include "query_optimizer/QueryPlan.hpp"
-#include "query_optimizer/cost_model/CostModel.hpp"
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/expressions/Predicate.hpp"
-#include "query_optimizer/physical/Aggregate.hpp"
-#include "query_optimizer/physical/CopyFrom.hpp"
-#include "query_optimizer/physical/CreateIndex.hpp"
-#include "query_optimizer/physical/CreateTable.hpp"
-#include "query_optimizer/physical/DeleteTuples.hpp"
-#include "query_optimizer/physical/DropTable.hpp"
-#include "query_optimizer/physical/HashJoin.hpp"
-#include "query_optimizer/physical/InsertSelection.hpp"
-#include "query_optimizer/physical/InsertTuple.hpp"
-#include "query_optimizer/physical/NestedLoopsJoin.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/Sample.hpp"
-#include "query_optimizer/physical/Selection.hpp"
-#include "query_optimizer/physical/SharedSubplanReference.hpp"
-#include "query_optimizer/physical/Sort.hpp"
-#include "query_optimizer/physical/TableGenerator.hpp"
-#include "query_optimizer/physical/TableReference.hpp"
-#include "query_optimizer/physical/TopLevelPlan.hpp"
-#include "query_optimizer/physical/UpdateTable.hpp"
-#include "query_optimizer/physical/WindowAggregate.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class CatalogAttribute;
-class CatalogDatabase;
-class CatalogRelation;
-class Predicate;
-
-namespace serialization {
-
-#ifdef QUICKSTEP_DISTRIBUTED
-class CatalogDatabase;
-#endif
-
-class InsertDestination;
-}  // namespace serialization
-
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Generates an execution plan from a physical plan.
- */
-class ExecutionGenerator {
- public:
-  /**
-   * @brief Constructor. Does not take ownership of \p query_handle.
-   *
-   * @param catalog_database The catalog database where this query is executed.
-   * @param query_handle The pointer to the output query handle.
-   */
-  ExecutionGenerator(CatalogDatabase *catalog_database,
-                     QueryHandle *query_handle)
-      : catalog_database_(DCHECK_NOTNULL(catalog_database)),
-        query_handle_(DCHECK_NOTNULL(query_handle)),
-        execution_plan_(DCHECK_NOTNULL(query_handle->getQueryPlanMutable())),
-        query_context_proto_(DCHECK_NOTNULL(query_handle->getQueryContextProtoMutable())) {
-    query_context_proto_->set_query_id(query_handle_->query_id());
-#ifdef QUICKSTEP_DISTRIBUTED
-    catalog_database_cache_proto_ = DCHECK_NOTNULL(query_handle->getCatalogDatabaseCacheProtoMutable());
-#endif
-  }
-
-  /**
-   * @brief Destructor.
-   */
-  ~ExecutionGenerator() {}
-
-  /**
-   * @brief Generates an execution plan.
-   *        The physical_plan must be rooted by a TopLevelPlan.
-   *
-   * @param physical_plan The physical plan from which
-   *        the execution plan is created.
-   */
-  void generatePlan(const physical::PhysicalPtr &physical_plan);
-
- private:
-  /**
-   * @brief A CatalogRelation and the index of its producer operator.
-   *        If the relation is a base relation, \p execution_operator_index
-   *        is kInvalidOperatorIndex.
-   */
-  struct CatalogRelationInfo {
-    CatalogRelationInfo(const QueryPlan::DAGNodeIndex producer_operator_index_in,
-                        const CatalogRelation *relation_in)
-        : producer_operator_index(producer_operator_index_in),
-          relation(relation_in) {}
-
-    /**
-     * @return True if the relation is a stored relation (i.e. not a temporary relation
-     *         created by a relational operator).
-     */
-    bool isStoredRelation() const {
-      return producer_operator_index == kInvalidOperatorIndex;
-    }
-
-    const QueryPlan::DAGNodeIndex producer_operator_index;
-    const CatalogRelation *relation;
-
-    /**
-     * @brief Represents an invalid node index.
-     */
-    static constexpr QueryPlan::DAGNodeIndex kInvalidOperatorIndex = static_cast<QueryPlan::DAGNodeIndex>(-1);
-
-    // Copyable.
-  };
-
-  /**
-   * @brief Internal implementation of generating an execution plan
-   *        for a general physical plan.
-   *
-   * @param physical_plan The physical plan from which the execution
-   *                      plan is created.
-   */
-  void generatePlanInternal(const physical::PhysicalPtr &physical_plan);
-
-  /**
-   * @brief Finds the CatalogRelationInfo from <physical_to_output_relation_map_>
-   *        by the physical node \p physical. Returns NULL if not found.
-   *
-   * @param physical The physical node.
-   * @return A mutable pointer to the catalog relation output by the physical node.
-   */
-  const CatalogRelationInfo* findRelationInfoOutputByPhysical(
-      const physical::PhysicalPtr &physical) const {
-    std::unordered_map<physical::PhysicalPtr, CatalogRelationInfo>::const_iterator it =
-        physical_to_output_relation_map_.find(physical);
-    if (it == physical_to_output_relation_map_.end()) {
-      return nullptr;
-    }
-    return &it->second;
-  }
-
-  /**
-   * @brief Creates and returns a temporary relation as the output of
-   *        \p physical in \p catalog_relation_output, and a serialized insert
-   *        destination in \p insert_destination_output.
-   *
-   * @param physical The input physical node.
-   * @param catalog_relation_output The output catalog relation.
-   * @param insert_destination_proto The output insert destination in proto
-   *        form.
-   */
-  void createTemporaryCatalogRelation(
-      const physical::PhysicalPtr &physical,
-      const CatalogRelation **catalog_relation_output,
-      serialization::InsertDestination *insert_destination_proto);
-
-  /**
-   * @brief Returns a new distinct relation name.
-   *
-   * @return A new distinct relation name.
-   */
-  std::string getNewRelationName();
-
-  /**
-   * @brief Sets up the info of the CatalogRelation represented by TableReference.
-   *        TableReference is not converted to any operator.
-   *
-   * @param physical_plan The TableReference node.
-   */
-  void convertTableReference(const physical::TableReferencePtr &physical_plan);
-
-  /**
-   * @brief Converts a Sample(block/tuple) and sample percentage to a Sample operator.
-   *
-   * @param physical_plan The Sample to be converted.
-   */
-  void convertSample(const physical::SamplePtr &physical_plan);
-
-  /**
-   * @brief Attempt to convert a group of scalar projection expressions into a
-   *        simple vector of attribute IDs.
-   *
-   * @param project_expressions_group_index The group index of scalar projection
-   *        expressions in QueryContext proto.
-   * @param attributes A vector of attribute_ids that will be filled in with
-   *        the attributes to project if scalars constitute a pure projection.
-   * @return true if all the scalar expressions in the group were attributes and
-   *         conversion was successful, false otherwise.
-   **/
-  bool convertSimpleProjection(const QueryContext::scalar_group_id project_expressions_group_index,
-                               std::vector<attribute_id> *attributes) const;
-
-  /**
-   * @brief Converts a Selection to a Select operator.
-   *
-   * @param physical_plan The Selection to be converted.
-   */
-  void convertSelection(const physical::SelectionPtr &physical_plan);
-
-  /**
-   * @brief Adds a map entry in <physical_to_execution_map_> from the
-   *        SharedSubplanReference to the execution info of the
-   *        referenced subplan.
-   *
-   * @param physical_plan The SharedSubplanReference to be converted.
-   */
-  void convertSharedSubplanReference(const physical::SharedSubplanReferencePtr &physical_plan);
-
-  /**
-   * @brief Converts a HashJoin to BuildHash, HashJoin and
-   *        DestroyHash operators.
-   *
-   * @param physical_plan The HashJoin to be converted.
-   */
-  void convertHashJoin(const physical::HashJoinPtr &physical_plan);
-
-  /**
-   * @brief Converts a NestedLoopsJoin to a NestedLoopsJoin operator.
-   *
-   * @param physical_plan The NestedLoopsJoin to be converted.
-   */
-  void convertNestedLoopsJoin(const physical::NestedLoopsJoinPtr &physical_plan);
-
-  /**
-   * @brief Converts a CopyFrom to a TextScan and a SaveBlocks.
-   *
-   * @param physical_plan The CopyFrom to be converted.
-   */
-  void convertCopyFrom(const physical::CopyFromPtr &physical_plan);
-
-  /**
-   * @brief Converts a CreateIndex to a CreateIndex operator.
-   *
-   * @param physical_plan The CreateIndex to be converted.
-   */
-  void convertCreateIndex(const physical::CreateIndexPtr &physical_plan);
-
-  /**
-   * @brief Converts a CreateTable to a CreateTable operator.
-   *
-   * @param physical_plan The CreateTable to be converted.
-   */
-  void convertCreateTable(const physical::CreateTablePtr &physical_plan);
-
-  /**
-   * @brief If there is a selection predicate in the DeleteTuples
-   *        and the predicate value is not statically true,
-   *        DeleteTuples is converted to a Delete and a SaveBlocks;
-   *        if there is not a selection predicate or the predicate value
-   *        not statically true, it is converted to a DropTableOperator;
-   *        otherwise, no operator is created.
-   *
-   * @param physical_plan The DeleteTuples to be converted.
-   */
-  void convertDeleteTuples(const physical::DeleteTuplesPtr &physical_plan);
-
-  /**
-   * @brief Converts a DropTable to a DropTable operator.
-   *
-   * @param physical_plan The DropTable to be converted.
-   */
-  void convertDropTable(const physical::DropTablePtr &physical_plan);
-
-  /**
-   * @brief Converts an InsertSelection to a Select and a SaveBlocks.
-   *
-   * @param physical_plan The InsertSelection to be converted.
-   */
-  void convertInsertSelection(const physical::InsertSelectionPtr &physical_plan);
-
-  /**
-   * @brief Converts an InsertTuple to an Insert and a SaveBlocks.
-   *
-   * @param physical_plan The InsertTuple to be converted.
-   */
-  void convertInsertTuple(const physical::InsertTuplePtr &physical_plan);
-
-  /**
-   * @brief Converts an UpdateTable to an Update and a SaveBlocks.
-   *
-   * @param physical_plan The UpdateTable to be converted.
-   */
-  void convertUpdateTable(const physical::UpdateTablePtr &physical_plan);
-
-  /**
-   * @brief Converts a physical Aggregate to an Aggregation operator
-   *
-   * @param physical_plan The Aggregate to be converted.
-   */
-  void convertAggregate(const physical::AggregatePtr &physical_plan);
-
-  /**
-   * @brief Converts a physical Sort to SortRunGeneration and SortMergeRun.
-   *
-   * @param physical_plan The Sort to be converted.
-   */
-  void convertSort(const physical::SortPtr &physical_plan);
-
-  /**
-   * @brief Converts a physical TableGenerator to a TableGeneratorOperator.
-   *
-   * @param physical_plan The TableGenerator to be converted.
-   */
-  void convertTableGenerator(const physical::TableGeneratorPtr &physical_plan);
-
-  /**
-   * @brief Converts a physical WindowAggregate to a WindowAggregation operator.
-   *
-   * @param physical_plan The WindowAggregate to be converted.
-   */
-  void convertWindowAggregate(const physical::WindowAggregatePtr &physical_plan);
-
-  /**
-   * @brief Converts a list of NamedExpressions in the optimizer expression
-   *        system to scalars proto in QueryContext proto.
-   *
-   * @param named_expressions The list of NamedExpressions to be converted.
-   * @param scalar_group_proto The corresponding scalars proto in QueryContext
-   *        proto.
-   */
-  void convertNamedExpressions(
-      const std::vector<expressions::NamedExpressionPtr> &named_expressions,
-      serialization::QueryContext::ScalarGroup *scalar_group_proto);
-
-  /**
-   * @brief Converts a Predicate in the optimizer expression system to a
-   *        Predicate in the execution expression system. The caller should
-   *        takes ownership of the returned pointer.
-   *
-   * @param optimizer_predicate The Predicate to be converted.
-   * @return The corresponding Predicate in the execution expression system.
-   */
-  Predicate* convertPredicate(const expressions::PredicatePtr &optimizer_predicate) const;
-
-  /**
-   * @brief Drops all temporary relations created by the generator
-   *        from the database. Called to avoid side effects
-   *        when some exception or error occurs.
-   */
-  void dropAllTemporaryRelations();
-
-  CatalogDatabase *catalog_database_;
-
-  QueryHandle *query_handle_;
-  QueryPlan *execution_plan_;  // A part of QueryHandle.
-  serialization::QueryContext *query_context_proto_;  // A part of QueryHandle.
-
-#ifdef QUICKSTEP_DISTRIBUTED
-  serialization::CatalogDatabase *catalog_database_cache_proto_;  // A part of QueryHandle.
-
-  // Used to bookkeep relation ids for 'catalog_database_cache_proto_'.
-  std::unordered_set<relation_id> referenced_relation_ids_;
-#endif
-
-  /**
-   * @brief Used to generate distinct relation names for temporary relations.
-   */
-  relation_id rel_id_ = 0;
-
-  /**
-   * @brief For each entry <expr_id, catalog_attribute>,
-   *        the NamedExpression with the expr_id is to be replaced with
-   *        the catalog_attribute when an expression in the optimizer
-   *        system is converted to one in the execution system.
-   */
-  std::unordered_map<expressions::ExprId, const CatalogAttribute *> attribute_substitution_map_;
-
-  /**
-   * @brief Map from a physical node to its output relation info.
-   */
-  std::unordered_map<physical::PhysicalPtr, CatalogRelationInfo> physical_to_output_relation_map_;
-
-  /**
-   * @brief All temporary relations created during query processing.
-   */
-  std::vector<CatalogRelationInfo> temporary_relation_info_vec_;
-
-  /**
-   * @brief The cost model to use for estimating aggregation hash table size.
-   */
-  std::unique_ptr<cost::CostModel> cost_model_for_aggregation_;
-
-  /**
-   * @brief The cost model to use for estimating join hash table size.
-   */
-  std::unique_ptr<cost::CostModel> cost_model_for_hash_join_;
-
-  physical::TopLevelPlanPtr top_level_physical_plan_;
-
-  // Sub-generator for deploying LIP (lookahead information passing) filters.
-  std::unique_ptr<LIPFilterGenerator> lip_filter_generator_;
-
-  DISALLOW_COPY_AND_ASSIGN(ExecutionGenerator);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_EXECUTION_GENERATOR_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/LIPFilterGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LIPFilterGenerator.cpp b/query_optimizer/LIPFilterGenerator.cpp
deleted file mode 100644
index 404037e..0000000
--- a/query_optimizer/LIPFilterGenerator.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/LIPFilterGenerator.hpp"
-
-#include <map>
-#include <utility>
-#include <vector>
-
-#include "catalog/CatalogAttribute.hpp"
-#include "query_execution/QueryContext.pb.h"
-#include "relational_operators/RelationalOperator.hpp"
-#include "types/Type.hpp"
-#include "utility/lip_filter/LIPFilter.hpp"
-#include "utility/lip_filter/LIPFilter.pb.h"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-namespace E = ::quickstep::optimizer::expressions;
-namespace P = ::quickstep::optimizer::physical;
-
-void LIPFilterGenerator::registerAttributeMap(
-    const P::PhysicalPtr &node,
-    const std::unordered_map<E::ExprId, const CatalogAttribute *> &attribute_substitution_map) {
-  // Check if a builder is attached to node.
-  const auto &build_info_map = lip_filter_configuration_->getBuildInfoMap();
-  const auto build_it = build_info_map.find(node);
-  if (build_it != build_info_map.end()) {
-    auto &map_entry = attribute_map_[node];
-    for (const auto &info : build_it->second) {
-      E::ExprId attr_id = info.build_attribute->id();
-      map_entry.emplace(attr_id, attribute_substitution_map.at(attr_id));
-    }
-  }
-  // Check if a prober is attached to node.
-  const auto &probe_info_map = lip_filter_configuration_->getProbeInfoMap();
-  const auto probe_it = probe_info_map.find(node);
-  if (probe_it != probe_info_map.end()) {
-    auto &map_entry = attribute_map_[node];
-    for (const auto &info : probe_it->second) {
-      E::ExprId attr_id = info.probe_attribute->id();
-      map_entry.emplace(attr_id, attribute_substitution_map.at(attr_id));
-    }
-  }
-}
-
-void LIPFilterGenerator::deployLIPFilters(QueryPlan *execution_plan,
-                                          serialization::QueryContext *query_context_proto) const {
-  LIPFilterBuilderMap lip_filter_builder_map;
-
-  // Deploy builders
-  const auto &build_info_map = lip_filter_configuration_->getBuildInfoMap();
-  for (const auto &info : builder_infos_) {
-    const auto build_it = build_info_map.find(info.builder_node);
-    if (build_it != build_info_map.end()) {
-      deployBuilderInternal(execution_plan,
-                            query_context_proto,
-                            info.builder_node,
-                            info.builder_operator_index,
-                            build_it->second,
-                            &lip_filter_builder_map);
-    }
-  }
-
-  // Deploy probers
-  const auto &probe_info_map = lip_filter_configuration_->getProbeInfoMap();
-  for (const auto &info : prober_infos_) {
-    const auto probe_it = probe_info_map.find(info.prober_node);
-    if (probe_it != probe_info_map.end()) {
-      deployProberInteral(execution_plan,
-                          query_context_proto,
-                          info.prober_node,
-                          info.prober_operator_index,
-                          probe_it->second,
-                          lip_filter_builder_map);
-    }
-  }
-}
-
-void LIPFilterGenerator::deployBuilderInternal(
-    QueryPlan *execution_plan,
-    serialization::QueryContext *query_context_proto,
-    const physical::PhysicalPtr &builder_node,
-    const QueryPlan::DAGNodeIndex builder_operator_index,
-    const std::vector<physical::LIPFilterBuildInfo> &build_info_vec,
-    LIPFilterBuilderMap *lip_filter_builder_map) const {
-  const auto lip_deployment_index = query_context_proto->lip_filter_deployments_size();
-  auto *lip_filter_deployment_info_proto =
-      query_context_proto->add_lip_filter_deployments();
-  lip_filter_deployment_info_proto->set_action_type(serialization::LIPFilterActionType::BUILD);
-
-  const auto &builder_attribute_map = attribute_map_.at(builder_node);
-  for (const auto &info : build_info_vec) {
-    // Add the LIPFilter information into query context.
-    const QueryContext::lip_filter_id lip_filter_id = query_context_proto->lip_filters_size();
-    serialization::LIPFilter *lip_filter_proto = query_context_proto->add_lip_filters();
-    const CatalogAttribute *target_attr = builder_attribute_map.at(info.build_attribute->id());
-    const Type &attr_type = target_attr->getType();
-
-    switch (info.filter_type) {
-      case LIPFilterType::kSingleIdentityHashFilter: {
-        DCHECK(!attr_type.isVariableLength());
-        lip_filter_proto->set_lip_filter_type(
-            serialization::LIPFilterType::SINGLE_IDENTITY_HASH_FILTER);
-        lip_filter_proto->SetExtension(
-            serialization::SingleIdentityHashFilter::filter_cardinality, info.filter_cardinality);
-        lip_filter_proto->SetExtension(
-            serialization::SingleIdentityHashFilter::attribute_size, attr_type.minimumByteLength());
-        break;
-      }
-      default:
-        LOG(FATAL) << "Unsupported LIPFilter type";
-        break;
-    }
-
-    // Register the builder information which is needed later by the probers.
-    lip_filter_builder_map->emplace(
-        std::make_pair(info.build_attribute->id(), builder_node),
-        std::make_pair(lip_filter_id, builder_operator_index));
-
-    // Add the builder deployment information into query context.
-    auto *lip_filter_entry_proto = lip_filter_deployment_info_proto->add_entries();
-    lip_filter_entry_proto->set_lip_filter_id(lip_filter_id);
-    lip_filter_entry_proto->set_attribute_id(target_attr->getID());
-    lip_filter_entry_proto->mutable_attribute_type()->CopyFrom(attr_type.getProto());
-  }
-
-  // Attach the LIPFilterDeployment information to the RelationalOperator.
-  RelationalOperator *relop =
-      execution_plan->getQueryPlanDAGMutable()->getNodePayloadMutable(builder_operator_index);
-  relop->deployLIPFilters(lip_deployment_index);
-}
-
-void LIPFilterGenerator::deployProberInteral(
-    QueryPlan *execution_plan,
-    serialization::QueryContext *query_context_proto,
-    const physical::PhysicalPtr &prober_node,
-    const QueryPlan::DAGNodeIndex prober_operator_index,
-    const std::vector<physical::LIPFilterProbeInfo> &probe_info_vec,
-    const LIPFilterBuilderMap &lip_filter_builder_map) const {
-  const auto lip_deployment_index = query_context_proto->lip_filter_deployments_size();
-  auto *lip_filter_deployment_info_proto =
-      query_context_proto->add_lip_filter_deployments();
-  lip_filter_deployment_info_proto->set_action_type(serialization::LIPFilterActionType::PROBE);
-
-  const auto &prober_attribute_map = attribute_map_.at(prober_node);
-  for (const auto &info : probe_info_vec) {
-    // Find the corresponding builder for the to-be-probed LIPFilter.
-    const auto &builder_info =
-        lip_filter_builder_map.at(
-            std::make_pair(info.build_attribute->id(), info.builder));
-    const CatalogAttribute *target_attr = prober_attribute_map.at(info.probe_attribute->id());
-
-    // Add the prober deployment information into query context.
-    auto *lip_filter_entry_proto = lip_filter_deployment_info_proto->add_entries();
-    lip_filter_entry_proto->set_lip_filter_id(builder_info.first);
-    lip_filter_entry_proto->set_attribute_id(target_attr->getID());
-    lip_filter_entry_proto->mutable_attribute_type()->CopyFrom(
-        target_attr->getType().getProto());
-
-    // A prober must wait until the corresponding builder has completed building
-    // the LIPFilter.
-    execution_plan->addOrUpgradeDirectDependency(prober_operator_index,
-                                                 builder_info.second,
-                                                 true /* is_pipeline_breaker */);
-  }
-
-  // Attach the LIPFilterDeployment information to the RelationalOperator.
-  RelationalOperator *relop =
-      execution_plan->getQueryPlanDAGMutable()->getNodePayloadMutable(prober_operator_index);
-  relop->deployLIPFilters(lip_deployment_index);
-}
-
-}  // namespace optimizer
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/LIPFilterGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LIPFilterGenerator.hpp b/query_optimizer/LIPFilterGenerator.hpp
deleted file mode 100644
index 9d191a1..0000000
--- a/query_optimizer/LIPFilterGenerator.hpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_LIP_FILTER_GENERATOR_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_LIP_FILTER_GENERATOR_HPP_
-
-#include <map>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-#include "query_execution/QueryContext.hpp"
-#include "query_optimizer/QueryPlan.hpp"
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "query_optimizer/physical/LIPFilterConfiguration.hpp"
-#include "query_optimizer/physical/Aggregate.hpp"
-#include "query_optimizer/physical/HashJoin.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/Selection.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-namespace serialization { class QueryContext; }
-
-class CatalogAttribute;
-
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Generates backend LIPFilter deployments from physical plan's information.
- */
-class LIPFilterGenerator {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param lip_filter_configuration The LIPFilter configuration information
-   *        generated by physical optimizer.
-   */
-  explicit LIPFilterGenerator(
-      const physical::LIPFilterConfigurationPtr &lip_filter_configuration)
-      : lip_filter_configuration_(lip_filter_configuration) {
-    DCHECK(lip_filter_configuration_ != nullptr);
-  }
-
-  /**
-   * @brief Collect the ExprId to CatalogAttribute mapping information for the
-   *        given physical node.
-   *
-   * @param node A physical plan node.
-   * @param attribute_substitution_map A map that maps each ExprId to the
-   *        backend relation's CatalogAttribute's.
-   */
-  void registerAttributeMap(
-      const physical::PhysicalPtr &node,
-      const std::unordered_map<expressions::ExprId, const CatalogAttribute *> &attribute_substitution_map);
-
-  /**
-   * @brief Add physical-to-execution mapping information for deploying LIPFilters
-   *        to an aggregation.
-   *
-   * @param aggregate A physical Aggregate node.
-   * @param aggregate_operator_index The index of the AggregationOperator that
-   *        corresponds to \p aggregate in the execution plan.
-   */
-  void addAggregateInfo(const physical::AggregatePtr &aggregate,
-                        const QueryPlan::DAGNodeIndex aggregate_operator_index) {
-    prober_infos_.emplace_back(aggregate, aggregate_operator_index);
-  }
-
-  /**
-   * @brief Add physical-to-execution mapping information for deploying LIPFilters
-   *        to a hash-join.
-   *
-   * @param hash_join A physical HashJoin node.
-   * @param build_operator_index The index of the BuildHashOperator that corresponds
-   *        to \p hash_join in the execution plan.
-   * @param join_operator_index The index of the HashJoinOperator that corresponds
-   *        to \p hash_join in the execution plan.
-   */
-  void addHashJoinInfo(const physical::HashJoinPtr &hash_join,
-                       const QueryPlan::DAGNodeIndex build_operator_index,
-                       const QueryPlan::DAGNodeIndex join_operator_index) {
-    builder_infos_.emplace_back(hash_join, build_operator_index);
-    prober_infos_.emplace_back(hash_join, join_operator_index);
-  }
-
-  /**
-   * @brief Add physical-to-execution mapping information for deploying LIPFilters
-   *        to a selection.
-   *
-   * @param selection A physical Selection node.
-   * @param select_operator_index The index of the SelectOperator that corresponds
-   *        to \p selection in the execution plan.
-   */
-  void addSelectionInfo(const physical::SelectionPtr &selection,
-                        const QueryPlan::DAGNodeIndex select_operator_index) {
-    prober_infos_.emplace_back(selection, select_operator_index);
-  }
-
-  /**
-   * @brief Deploy the LIPFilters to the execution plan.
-   *
-   * @param execution_plan The execution plan.
-   * @param query_context_proto QueryContext protobuf for the execution plan.
-   */
-  void deployLIPFilters(QueryPlan *execution_plan,
-                        serialization::QueryContext *query_context_proto) const;
-
- private:
-  /**
-   * @brief Internal data structure for representing a LIPFilter builder.
-   */
-  struct BuilderInfo {
-    BuilderInfo(const physical::PhysicalPtr &builder_node_in,
-                const QueryPlan::DAGNodeIndex builder_operator_index_in)
-        : builder_node(builder_node_in),
-          builder_operator_index(builder_operator_index_in) {
-    }
-    const physical::PhysicalPtr builder_node;
-    const QueryPlan::DAGNodeIndex builder_operator_index;
-  };
-
-  /**
-   * @brief Internal data structure for representing a LIPFilter prober.
-   */
-  struct ProberInfo {
-    ProberInfo(const physical::PhysicalPtr &prober_node_in,
-               const QueryPlan::DAGNodeIndex prober_operator_index_in)
-        : prober_node(prober_node_in),
-          prober_operator_index(prober_operator_index_in) {
-    }
-    const physical::PhysicalPtr prober_node;
-    const QueryPlan::DAGNodeIndex prober_operator_index;
-  };
-
-  // Maps each LIPFilter's building attribute to the LIPFilter's id in QueryContext
-  // as well as the LIPFilter's building relational operator's index.
-  typedef std::map<std::pair<expressions::ExprId, physical::PhysicalPtr>,
-                   std::pair<QueryContext::lip_filter_id, QueryPlan::DAGNodeIndex>> LIPFilterBuilderMap;
-
-  void deployBuilderInternal(QueryPlan *execution_plan,
-                             serialization::QueryContext *query_context_proto,
-                             const physical::PhysicalPtr &builder_node,
-                             const QueryPlan::DAGNodeIndex builder_operator_index,
-                             const std::vector<physical::LIPFilterBuildInfo> &build_info_vec,
-                             LIPFilterBuilderMap *lip_filter_builder_map) const;
-
-  void deployProberInteral(QueryPlan *execution_plan,
-                           serialization::QueryContext *query_context_proto,
-                           const physical::PhysicalPtr &prober_node,
-                           const QueryPlan::DAGNodeIndex prober_operator_index,
-                           const std::vector<physical::LIPFilterProbeInfo> &probe_info_vec,
-                           const LIPFilterBuilderMap &lip_filter_builder_map) const;
-
-  const physical::LIPFilterConfigurationPtr lip_filter_configuration_;
-
-  std::vector<BuilderInfo> builder_infos_;
-  std::vector<ProberInfo> prober_infos_;
-
-  std::map<physical::PhysicalPtr, std::map<expressions::ExprId, const CatalogAttribute *>> attribute_map_;
-
-  DISALLOW_COPY_AND_ASSIGN(LIPFilterGenerator);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_LIP_FILTER_GENERATOR_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/LogicalGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LogicalGenerator.cpp b/query_optimizer/LogicalGenerator.cpp
deleted file mode 100644
index abeca53..0000000
--- a/query_optimizer/LogicalGenerator.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/LogicalGenerator.hpp"
-
-#include <memory>
-#include <vector>
-
-#include "parser/ParseStatement.hpp"
-
-#include "query_optimizer/OptimizerContext.hpp"
-#include "query_optimizer/Validator.hpp"
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/resolver/Resolver.hpp"
-#include "query_optimizer/rules/CollapseProject.hpp"
-#include "query_optimizer/rules/GenerateJoins.hpp"
-#include "query_optimizer/rules/PushDownFilter.hpp"
-#include "query_optimizer/rules/PushDownSemiAntiJoin.hpp"
-#include "query_optimizer/rules/Rule.hpp"
-#include "query_optimizer/rules/UnnestSubqueries.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-namespace L = ::quickstep::optimizer::logical;
-
-LogicalGenerator::LogicalGenerator(OptimizerContext *optimizer_context)
-    : optimizer_context_(optimizer_context) {}
-
-LogicalGenerator::~LogicalGenerator() {}
-
-L::LogicalPtr LogicalGenerator::generatePlan(
-    const CatalogDatabase &catalog_database,
-    const ParseStatement &parse_statement) {
-  resolver::Resolver resolver(catalog_database, optimizer_context_);
-  DVLOG(4) << "Parse tree:\n" << parse_statement.toString();
-  logical_plan_ = resolver.resolve(parse_statement);
-  DVLOG(4) << "Initial logical plan:\n" << logical_plan_->toString();
-
-  optimizePlan();
-  DVLOG(4) << "Optimized logical plan:\n" << logical_plan_->toString();
-
-  return logical_plan_;
-}
-
-void LogicalGenerator::optimizePlan() {
-  std::vector<std::unique_ptr<Rule<L::Logical>>> rules;
-  if (optimizer_context_->has_nested_queries()) {
-    rules.emplace_back(new UnnestSubqueries(optimizer_context_));
-  }
-  rules.emplace_back(new PushDownSemiAntiJoin());
-  rules.emplace_back(new PushDownFilter());
-  rules.emplace_back(new GenerateJoins());
-  rules.emplace_back(new PushDownFilter());
-  rules.emplace_back(new CollapseProject());
-
-  for (std::unique_ptr<Rule<L::Logical>> &rule : rules) {
-    logical_plan_ = rule->apply(logical_plan_);
-    DVLOG(5) << "After applying rule " << rule->getName() << ":\n"
-             << logical_plan_->toString();
-  }
-
-#ifdef QUICKSTEP_DEBUG
-  Validate(logical_plan_);
-#endif
-}
-
-}  // namespace optimizer
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/LogicalGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LogicalGenerator.hpp b/query_optimizer/LogicalGenerator.hpp
deleted file mode 100644
index 2898e6f..0000000
--- a/query_optimizer/LogicalGenerator.hpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_GENERATOR_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_GENERATOR_HPP_
-
-#include "query_optimizer/logical/Logical.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class CatalogDatabase;
-class ParseStatement;
-
-namespace optimizer {
-
-class OptimizerContext;
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Generates a logical plan from a parse tree.
- */
-class LogicalGenerator {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param optimizer_context The optimizer context.
-   */
-  explicit LogicalGenerator(OptimizerContext *optimizer_context);
-
-  /**
-   * @brief Destructor.
-   */
-  ~LogicalGenerator();
-
-  /**
-   * @return The current logical plan.
-   */
-  const logical::LogicalPtr& logical_plan() const { return logical_plan_; }
-
-  /**
-   * @brief Converts the parse tree to a logical plan and optimizes the logical
-   *        plan by using rules.
-   *
-   * @param catalog_database The catalog database where this query is executed.
-   * @param parse_statement The parse tree to be converted.
-   * @return An optimized logical plan.
-   */
-  logical::LogicalPtr generatePlan(const CatalogDatabase &catalog_database,
-                                   const ParseStatement &parse_statement);
-
- private:
-  /**
-   * @brief Applies rules to the logical plan.
-   */
-  void optimizePlan();
-
-  OptimizerContext *optimizer_context_;
-  logical::LogicalPtr logical_plan_;
-
-  DISALLOW_COPY_AND_ASSIGN(LogicalGenerator);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_GENERATOR_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/LogicalToPhysicalMapper.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LogicalToPhysicalMapper.hpp b/query_optimizer/LogicalToPhysicalMapper.hpp
deleted file mode 100644
index 869dad0..0000000
--- a/query_optimizer/LogicalToPhysicalMapper.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_TO_PHYSICAL_MAPPER_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_TO_PHYSICAL_MAPPER_HPP_
-
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Abstract base class for PhysicalGenerator that provides a single
- *        method needed by Strategy objects. This class exists to resolve a
- *        cyclic dependency between PhysicalGenerator and the various
- *        subclasses of Strategy.
- **/
-class LogicalToPhysicalMapper {
- public:
-  virtual ~LogicalToPhysicalMapper() {
-  }
-
-  /**
-   * @brief Returns the physical plan for \p logical_plan.
-   *        Creates the physical plan if it is not yet created.
-   *
-   * @param logical_plan The input logical plan.
-   * @return The physical plan for the logical plan.
-   */
-  virtual physical::PhysicalPtr createOrGetPhysicalFromLogical(
-      const logical::LogicalPtr &logical_plan) = 0;
-
- protected:
-  LogicalToPhysicalMapper() {
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(LogicalToPhysicalMapper);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_TO_PHYSICAL_MAPPER_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/Optimizer.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/Optimizer.cpp b/query_optimizer/Optimizer.cpp
deleted file mode 100644
index b14c938..0000000
--- a/query_optimizer/Optimizer.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/Optimizer.hpp"
-
-#include "query_optimizer/ExecutionGenerator.hpp"
-#include "query_optimizer/LogicalGenerator.hpp"
-
-namespace quickstep {
-namespace optimizer {
-
-void Optimizer::generateQueryHandle(const ParseStatement &parse_statement,
-                                    CatalogDatabase *catalog_database,
-                                    OptimizerContext *optimizer_context,
-                                    QueryHandle *query_handle) {
-  LogicalGenerator logical_generator(optimizer_context);
-  ExecutionGenerator execution_generator(catalog_database, query_handle);
-
-  execution_generator.generatePlan(
-      physical_generator_.generatePlan(
-          logical_generator.generatePlan(*catalog_database, parse_statement)));
-}
-
-}  // namespace optimizer
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/Optimizer.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/Optimizer.hpp b/query_optimizer/Optimizer.hpp
deleted file mode 100644
index 36f956a..0000000
--- a/query_optimizer/Optimizer.hpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_HPP_
-
-#include "query_optimizer/PhysicalGenerator.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-class CatalogDatabase;
-class ParseStatement;
-class QueryHandle;
-
-namespace optimizer {
-
-class OptimizerContext;
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Main class of the optimizer that creates and optimizes all types of query
- *        plans.
- */
-class Optimizer {
- public:
-  /**
-   * @brief Constructor.
-   */
-  Optimizer() {}
-
-  /**
-   * @brief Destructor.
-   */
-  ~Optimizer() {}
-
-  /**
-   * @brief Fills an execution plan as a list of operators,
-   *        and the query result relation in
-   *        \p query_handle for \p parse_statement.
-   * @note Does not take ownership of \p query_handle.
-   *
-   * @param parse_statement The parse tree of the input query.
-   * @param catalog_database The database that the query is executed on.
-   * @param optimizer_context The optimizer context of the input query.
-   * @param query_handle The generated query handle to output.
-   */
-  void generateQueryHandle(const ParseStatement &parse_statement,
-                           CatalogDatabase *catalog_database,
-                           OptimizerContext *optimizer_context,
-                           QueryHandle *query_handle);
-
- private:
-  PhysicalGenerator physical_generator_;
-
-  DISALLOW_COPY_AND_ASSIGN(Optimizer);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/OptimizerContext.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/OptimizerContext.cpp b/query_optimizer/OptimizerContext.cpp
deleted file mode 100644
index de7ba8c..0000000
--- a/query_optimizer/OptimizerContext.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/OptimizerContext.hpp"
-
-#include <string>
-
-namespace quickstep {
-namespace optimizer {
-
-const char *OptimizerContext::kInternalTemporaryRelationNamePrefix = "_qstemp_result_";
-
-}  // namespace optimizer
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/OptimizerContext.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/OptimizerContext.hpp b/query_optimizer/OptimizerContext.hpp
deleted file mode 100644
index d52c96c..0000000
--- a/query_optimizer/OptimizerContext.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_CONTEXT_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_CONTEXT_HPP_
-
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Stores stateful or common info used throughout the optimization of a
- *        query.
- */
-class OptimizerContext {
- public:
-  static const char *kInternalTemporaryRelationNamePrefix;
-
-  /**
-   * @brief Constructor.
-   */
-  OptimizerContext()
-      : current_expr_id_(-1),
-        has_nested_queries_(false),
-        is_catalog_changed_(false) {}
-
-  /**
-   * @brief Destructor.
-   */
-  ~OptimizerContext() {}
-
-  /**
-   * @brief Gets the next ExprId.
-   *
-   * @return A new ExprId.
-   */
-  expressions::ExprId nextExprId() {
-    return ++current_expr_id_;
-  }
-
-  /**
-   * @brief Indicate that the query has a nested subquery.
-   */
-  void set_has_nested_queries() {
-    has_nested_queries_ = true;
-  }
-
-  /**
-   * @return True if the query has a nested subquery.
-   */
-  bool has_nested_queries() const {
-    return has_nested_queries_;
-  }
-
-  /**
-   * @brief Sets <is_catalog_changed_> to be true to indicate the query will
-   *        modify the catalog permanently.
-   */
-  void set_is_catalog_changed() { is_catalog_changed_ = true; }
-
-  /**
-   * @return True if the catalog will be permanently changed after the query.
-   */
-  bool is_catalog_changed() const { return is_catalog_changed_; }
-
- private:
-  expressions::ExprId current_expr_id_;
-
-  bool has_nested_queries_;
-
-  bool is_catalog_changed_;
-
-  DISALLOW_COPY_AND_ASSIGN(OptimizerContext);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_CONTEXT_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/OptimizerTree.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/OptimizerTree.hpp b/query_optimizer/OptimizerTree.hpp
deleted file mode 100644
index 8ea2c6f..0000000
--- a/query_optimizer/OptimizerTree.hpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_TREE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_TREE_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "storage/StorageBlockLayout.pb.h"
-#include "utility/Macros.hpp"
-#include "utility/TreeStringSerializable.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Base class of OptimizerTree. This class is needed so that we may
- *        attach non-child type nodes to a tree in the string representation
- *        as long as the non-child type is a subclass of OptimizerTreeBase.
- *        For example, a Logical node may have a child tree node of an
- *        Expression type.
- */
-class OptimizerTreeBase
-    : public TreeStringSerializable<std::shared_ptr<const OptimizerTreeBase>> {
- public:
-  typedef std::shared_ptr<const OptimizerTreeBase> OptimizerTreeBaseNodePtr;
-
-  /**
-   * @brief Destructor.
-   */
-  ~OptimizerTreeBase() override {}
-
- protected:
-  /**
-   * @brief Constructor.
-   */
-  OptimizerTreeBase() {}
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(OptimizerTreeBase);
-};
-
-/**
- * @brief Base class for expressions, logical/physical trees.
- */
-template <class NodeType>
-class OptimizerTree : public OptimizerTreeBase {
- public:
-  typedef std::shared_ptr<const NodeType> OptimizerTreeNodePtr;
-
-  /**
-   * @brief Destructor.
-   */
-  ~OptimizerTree() override {}
-
-  /**
-   * @brief Returns the child node list.
-   *
-   * @return A vector of children.
-   */
-  const std::vector<OptimizerTreeNodePtr>& children() const {
-    return children_;
-  }
-
-  /**
-   * @brief Returns the number of child nodes.
-   *
-   * @return The number of child nodes.
-   */
-  std::size_t getNumChildren() const { return children_.size(); }
-
-  /**
-   * @brief Creates a copy with the child nodes replaced by \p new_children.
-   *
-   * @param new_children The children to be substituted for the existing ones.
-   * @return A copy with \p new_children as child nodes.
-   */
-  virtual OptimizerTreeNodePtr copyWithNewChildren(
-      const std::vector<OptimizerTreeNodePtr> &new_children) const = 0;
-
- protected:
-  /**
-   * @brief Constructor.
-   */
-  OptimizerTree() {}
-
-  /**
-   * @brief Adds a new child node to this tree node->
-   *
-   * @param child The node to add as a new child.
-   */
-  void addChild(const OptimizerTreeNodePtr &child) {
-    children_.push_back(child);
-  }
-
- private:
-  std::vector<OptimizerTreeNodePtr> children_;
-
-  DISALLOW_COPY_AND_ASSIGN(OptimizerTree);
-};
-
-/**
- * @brief A helper class for printing Protobuf messages in a simple flat-format.
- * @details Holds key-value pairs of a proto message. Key values are added as strings.
- *          To use, create a representation and then add properties:
- *             auto foo = new OptimizerProtoRepresentation<OptimizerPtrType>();
- *             foo.addProperty("friendly_name", proto.GetExtension(ProtoType::friendly_name));
- */
-template<class TreeNodeType>
-class OptimizerProtoRepresentation : public OptimizerTreeBase {
-  /**
-   * @brief Inner class which represents key-value properties of the given proto.
-   */
-  class OptimizerProtoPropertyRepresentation : public OptimizerTreeBase {
-   public:
-    OptimizerProtoPropertyRepresentation(std::string key, std::string value)
-        : key_(key), value_(value) {  }
-
-    std::string getName() const {
-      return "ProtoProperty";
-    }
-
-    void getFieldStringItems(std::vector<std::string> *inline_field_names,
-                             std::vector<std::string> *inline_field_values,
-                             std::vector<std::string> *non_container_child_field_names,
-                             std::vector<TreeNodeType> *non_container_child_fields,
-                             std::vector<std::string> *container_child_field_names,
-                             std::vector<std::vector<TreeNodeType>> *container_child_fields) const {
-      inline_field_names->push_back(std::string("Property"));
-      inline_field_values->push_back(key_);
-
-      inline_field_names->push_back(std::string("Value"));
-      inline_field_values->push_back(value_);
-    }
-
-   private:
-    std::string key_;
-    std::string value_;
-  };  // class OptimizerProtoRepresentation
-
- public:
-  OptimizerProtoRepresentation() : properties_() { }
-
-  std::string getName() const {
-    return "ProtoDescription";
-  }
-
-  /**
-   * @brief Add a key-value type property to this proto representation.
-   * @details Internally, the instance creates another node to represent the
-   *          given values.
-   *
-   * @param key A string key.
-   * @param value A string value.
-   */
-  void addProperty(std::string key, std::string value) {
-    std::shared_ptr<const OptimizerProtoPropertyRepresentation> property(
-        new OptimizerProtoPropertyRepresentation(key, value));
-    properties_.push_back(property);
-  }
-
-  /**
-   * @brief Add a key-value type property to this proto representation.
-   * @details Internally, the instance creates another node to represent the
-   *          given values.
-   *
-   * @param key A string key.
-   * @param value An int value which is converted into a string.
-   */
-  void addProperty(std::string key, int value) {
-    std::shared_ptr<const OptimizerProtoPropertyRepresentation> property(
-        new OptimizerProtoPropertyRepresentation(key, std::to_string(value)));
-    properties_.push_back(property);
-  }
-
-  void getFieldStringItems(std::vector<std::string> *inline_field_names,
-                           std::vector<std::string> *inline_field_values,
-                           std::vector<std::string> *non_container_child_field_names,
-                           std::vector<TreeNodeType> *non_container_child_fields,
-                           std::vector<std::string> *container_child_field_names,
-                           std::vector<std::vector<TreeNodeType>> *container_child_fields) const {
-    for (auto property : properties_) {
-      non_container_child_field_names->push_back("Property");
-      non_container_child_fields->push_back(property);
-    }
-  }
-  // A list of managed properties.
-  std::vector<std::shared_ptr<const OptimizerProtoPropertyRepresentation> > properties_;
-};
-
-/**
- * @brief Returns an optimizer node representation of a LayoutDescription.
- *
- * @param description A valid StorageBlockLayoutDescription.
- * @return A caller-managed optimizer tree node of the proto message.
- */
-template<class TreeNodeType>
-OptimizerProtoRepresentation<TreeNodeType>* getOptimizerRepresentationForProto(
-    const StorageBlockLayoutDescription *description) {
-  if (description == nullptr) {
-    return nullptr;
-  }
-
-  std::unique_ptr<OptimizerProtoRepresentation<TreeNodeType> >
-      node(new OptimizerProtoRepresentation<TreeNodeType>());
-
-  // Add properties based on the tuple storage block type.
-  const ::quickstep::TupleStorageSubBlockDescription &storage_block_description
-      = description->tuple_store_description();
-  switch (storage_block_description.sub_block_type()) {
-    case TupleStorageSubBlockDescription::PACKED_ROW_STORE: {
-      node->addProperty("blocktype", "rowstore");
-      break;
-    }
-    case TupleStorageSubBlockDescription::SPLIT_ROW_STORE: {
-      node->addProperty("blocktype", "split_rowstore");
-      break;
-    }
-    case TupleStorageSubBlockDescription::BASIC_COLUMN_STORE: {
-      node->addProperty("blocktype", "columnstore");
-      node->addProperty("sort",
-          storage_block_description.GetExtension(
-              quickstep::BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-      break;
-    }
-    case TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE: {
-      node->addProperty("blocktype", "compressed_columnstore");
-      node->addProperty("sort",
-          storage_block_description.GetExtension(
-              quickstep::CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-      for (int compressed_attribute = 0;
-           compressed_attribute < storage_block_description.ExtensionSize(
-               quickstep::CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id);
-           ++compressed_attribute) {
-        node->addProperty("compress",
-            storage_block_description.GetExtension(
-                quickstep::CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id,
-                compressed_attribute));
-      }
-      break;
-    }
-    case TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE: {
-      node->addProperty("blocktype", "compressed_packed_rowstore");
-      for (int compressed_attribute = 0;
-           compressed_attribute < storage_block_description.ExtensionSize(
-               quickstep::CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id);
-           ++compressed_attribute) {
-        node->addProperty("compress",
-            storage_block_description.GetExtension(
-                quickstep::CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id,
-                compressed_attribute));
-      }
-      break;
-    }
-    default: {
-      LOG(WARNING) << "Unrecognized block type in protobuf message.";
-      break;
-    }
-  }
-  // Every case will specify a slots number.
-  node->addProperty("slots", description->num_slots());
-  return node.release();
-}
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_OPTIMIZER_TREE_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/PhysicalGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp
deleted file mode 100644
index 7cb97dc..0000000
--- a/query_optimizer/PhysicalGenerator.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/PhysicalGenerator.hpp"
-
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-#include "query_optimizer/Validator.hpp"
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/rules/AttachLIPFilters.hpp"
-#include "query_optimizer/rules/PruneColumns.hpp"
-#include "query_optimizer/rules/StarSchemaHashJoinOrderOptimization.hpp"
-#include "query_optimizer/rules/SwapProbeBuild.hpp"
-#include "query_optimizer/strategy/Aggregate.hpp"
-#include "query_optimizer/strategy/Join.hpp"
-#include "query_optimizer/strategy/OneToOne.hpp"
-#include "query_optimizer/strategy/Selection.hpp"
-#include "query_optimizer/strategy/Strategy.hpp"
-#include "utility/PlanVisualizer.hpp"
-
-#include "gflags/gflags.h"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-DEFINE_bool(reorder_hash_joins, true,
-            "If true, apply hash join order optimization to each group of hash "
-            "joins. The optimization applies a greedy algorithm to favor smaller "
-            "cardinality and selective tables to be joined first, which is suitable "
-            "for queries on star-schema tables.");
-
-DEFINE_bool(use_lip_filters, true,
-            "If true, use LIP (Lookahead Information Passing) filters to accelerate "
-            "query processing. LIP filters are effective for queries on star schema "
-            "tables (e.g. the SSB benchmark) and snowflake schema tables (e.g. the "
-            "TPC-H benchmark).");
-
-DEFINE_bool(visualize_plan, false,
-            "If true, visualize the final physical plan into a graph in DOT format "
-            "(DOT is a plain text graph description language). Then print the "
-            "generated graph through stderr.");
-
-namespace L = ::quickstep::optimizer::logical;
-namespace P = ::quickstep::optimizer::physical;
-namespace S = ::quickstep::optimizer::strategy;
-
-void PhysicalGenerator::createStrategies() {
-  // Note that the ordering matters.
-  // The strategy that can create better plans should be inserted first.
-  strategies_.emplace_back(new S::Join(this));
-  strategies_.emplace_back(new S::Aggregate(this));
-  strategies_.emplace_back(new S::Selection(this));
-  strategies_.emplace_back(new S::OneToOne(this));
-}
-
-P::PhysicalPtr PhysicalGenerator::generatePlan(
-    const L::LogicalPtr &logical_plan) {
-  physical_plan_ = generateInitialPlan(logical_plan);
-  return optimizePlan();
-}
-
-P::PhysicalPtr PhysicalGenerator::generateInitialPlan(
-    const L::LogicalPtr &logical_plan) {
-  // Choose the first generated physical plan as the best one.
-  P::PhysicalPtr physical_plan;
-  for (std::unique_ptr<S::Strategy> &strategy : strategies_) {
-    DVLOG(5) << "Apply strategy " << strategy->getName() << " to "
-             << logical_plan->getShortString();
-    if (strategy->generatePlan(logical_plan, &physical_plan)) {
-      DVLOG(5) << "Result:\n" << physical_plan->toString();
-      break;
-    }
-  }
-  CHECK(physical_plan != nullptr) << "No strategy for a logical plan:\n"
-                                  << logical_plan->toString();
-
-  // Memorize the created physical plan.
-  setBestPhysicalForLogical(logical_plan, physical_plan);
-  return physical_plan;
-}
-
-P::PhysicalPtr PhysicalGenerator::optimizePlan() {
-  std::vector<std::unique_ptr<Rule<P::Physical>>> rules;
-  rules.emplace_back(new PruneColumns());
-  if (FLAGS_reorder_hash_joins) {
-    rules.emplace_back(new StarSchemaHashJoinOrderOptimization());
-    rules.emplace_back(new PruneColumns());
-  } else {
-    rules.emplace_back(new SwapProbeBuild());
-  }
-  if (FLAGS_use_lip_filters) {
-    rules.emplace_back(new AttachLIPFilters());
-  }
-
-  for (std::unique_ptr<Rule<P::Physical>> &rule : rules) {
-    physical_plan_ = rule->apply(physical_plan_);
-    DVLOG(5) << "After applying rule " << rule->getName() << ":\n"
-             << physical_plan_->toString();
-  }
-
-  DVLOG(4) << "Optimized physical plan:\n" << physical_plan_->toString();
-
-  if (FLAGS_visualize_plan) {
-    quickstep::PlanVisualizer plan_visualizer;
-    std::cerr << "\n" << plan_visualizer.visualize(physical_plan_) << "\n";
-  }
-
-#ifdef QUICKSTEP_DEBUG
-  Validate(physical_plan_);
-#endif
-  return physical_plan_;
-}
-
-void PhysicalGenerator::setBestPhysicalForLogical(
-    const L::LogicalPtr &logical_plan, const P::PhysicalPtr &physical_plan) {
-  DCHECK(logical_plan != nullptr);
-  DCHECK(physical_plan != nullptr);
-  logical_to_physical_map_.emplace(logical_plan, physical_plan);
-}
-
-P::PhysicalPtr PhysicalGenerator::createOrGetPhysicalFromLogical(
-    const L::LogicalPtr &logical_plan) {
-  DCHECK(logical_plan != nullptr);
-  // Check if we have created the physical plan.
-  const std::unordered_map<L::LogicalPtr, P::PhysicalPtr>::const_iterator it =
-      logical_to_physical_map_.find(logical_plan);
-  if (it != logical_to_physical_map_.end()) {
-    return it->second;
-  }
-
-  return generateInitialPlan(logical_plan);
-}
-
-}  // namespace optimizer
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/PhysicalGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/PhysicalGenerator.hpp b/query_optimizer/PhysicalGenerator.hpp
deleted file mode 100644
index 886a173..0000000
--- a/query_optimizer/PhysicalGenerator.hpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_GENERATOR_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_GENERATOR_HPP_
-
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-#include "query_optimizer/LogicalToPhysicalMapper.hpp"
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/strategy/Strategy.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief Converts logical plans to physical plans.
- */
-class PhysicalGenerator : public LogicalToPhysicalMapper {
- public:
-  /**
-   * @brief Constructor
-   */
-  PhysicalGenerator() {
-    createStrategies();
-  }
-
-  /**
-   * @brief Destructor.
-   */
-  ~PhysicalGenerator() {}
-
-  /**
-   * @return The generated physical plan.
-   */
-  const physical::PhysicalPtr& physical_plan() const { return physical_plan_; }
-
-  /**
-   * @brief Generates and optimizes a physical plan for \p logical_plan.
-   *
-   * @param logical_plan The logical plan to be converted to a physical plan.
-   * @return The physical plan.
-   */
-  physical::PhysicalPtr generatePlan(const logical::LogicalPtr &logical_plan);
-
-  /**
-   * @brief Sets the best physical plan for \p logical_plan is \p physical_plan.
-   *
-   * @param logical_plan Logical plan.
-   * @param physical_plan The physical plan for the logical plan.
-   */
-  void setBestPhysicalForLogical(const logical::LogicalPtr &logical_plan,
-                                 const physical::PhysicalPtr &physical_plan);
-
-  physical::PhysicalPtr createOrGetPhysicalFromLogical(
-      const logical::LogicalPtr &logical_plan) final;
-
- private:
-  /**
-   * @brief Creates an initial physical plan for \p logical_plan.
-   *        It tries each strategy to the logical plan in order,
-   *        and the physical plan generated by the first strategy that can
-   *        be applied is chosen as the best initial physical plan.
-   *
-   *
-   * @param logical_plan The logical plan to be converted to a physical plan.
-   * @return The initial physical plan.
-   */
-  physical::PhysicalPtr generateInitialPlan(
-      const logical::LogicalPtr &logical_plan);
-
-  /**
-   * @brief Creates strategies for different types of physical nodes.
-   */
-  void createStrategies();
-
-  /**
-   * @brief Applies physical rules to the initial physical plan.
-   *
-   * @return The optimized physical plan.
-   */
-  physical::PhysicalPtr optimizePlan();
-
-  std::vector<std::unique_ptr<strategy::Strategy>> strategies_;
-
-  /**
-   * @brief Maps a logical plan to its initial physical plan.
-   *        We memorize every generated sub-physical plan in this map.
-   *        This map is currently useless, because each logical node is
-   *        visited only once and its physical plan won't be retrieved
-   *        from the map. This is used to allow strategy tests to change
-   *        the plans created for a logical plan by putting intended plans
-   *        into the map so that the generator won't apply a strategy to
-   *        create a plan for a logical node. It also makes testing on
-   *        different strategies to be relatively independent. A strategy test
-   *        only checks one type of physical plans, and manually provides other
-   *        types of physical plans that are not interested. This map will become
-   *        more useful when we have a cost model to evaluate the cost of a
-   *        physical plan. The best physical plan for a logical subplan may be shared
-   *        in multiple physical plans during the plan enumeration.
-   */
-  std::unordered_map<logical::LogicalPtr, physical::PhysicalPtr> logical_to_physical_map_;
-
-  /**
-   * @brief The complete physical plan.
-   */
-  physical::PhysicalPtr physical_plan_;
-
-  DISALLOW_COPY_AND_ASSIGN(PhysicalGenerator);
-};
-
-/** @} */
-
-}  // namespace optimizer
-}  // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_GENERATOR_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/QueryHandle.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryHandle.hpp b/query_optimizer/QueryHandle.hpp
deleted file mode 100644
index 1ca6021..0000000
--- a/query_optimizer/QueryHandle.hpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_QUERY_HANDLE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_QUERY_HANDLE_HPP_
-
-#include <cstddef>
-#include <cstdint>
-#include <memory>
-
-#include "catalog/Catalog.pb.h"
-#include "query_execution/QueryContext.pb.h"
-#include "query_optimizer/QueryPlan.hpp"
-#include "utility/Macros.hpp"
-
-#include "tmb/id_typedefs.h"
-
-namespace quickstep {
-
-class CatalogRelation;
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief A handle to hold the query plan and resultant relation, if any.
- **/
-class QueryHandle {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param query_id The given query id.
-   * @param cli_id The client id of the CLI which submits the query.
-   * @param query_priority The priority of this query.
-   */
-  explicit QueryHandle(const std::size_t query_id,
-                       const tmb::client_id cli_id,
-                       const std::uint64_t query_priority = 1)
-      : query_id_(query_id),
-        cli_id_(cli_id),
-        query_priority_(query_priority),
-        query_plan_(new QueryPlan()),
-        query_result_relation_(nullptr) {}
-
-  ~QueryHandle() {}
-
-  /**
-   * @brief Get the query id.
-   *
-   * @return The query id.
-   */
-  std::size_t query_id() const {
-    return query_id_;
-  }
-
-  /**
-   * @brief Get the client id of the CLI which submits the query.
-   */
-  tmb::client_id getClientId() const {
-    return cli_id_;
-  }
-
-  /**
-   * @brief Get the query priority.
-   **/
-  const std::uint64_t query_priority() const {
-    return query_priority_;
-  }
-
-  /**
-   * @return The mutable query plan.
-   */
-  QueryPlan* getQueryPlanMutable() {
-    return query_plan_.get();
-  }
-
-  /**
-   * @return The query context in the protobuf format.
-   */
-  const serialization::QueryContext& getQueryContextProto() const {
-    return query_context_proto_;
-  }
-
-  /**
-   * @return The mutable query context in the protobuf format.
-   */
-  serialization::QueryContext* getQueryContextProtoMutable() {
-    return &query_context_proto_;
-  }
-
-  /**
-    * @return The catalog database cache in the protobuf format.
-    */
-  const serialization::CatalogDatabase& getCatalogDatabaseCacheProto() const {
-    return catalog_database_cache_proto_;
-  }
-
-  /**
-   * @return The mutable catalog database cache in the protobuf format.
-   */
-  serialization::CatalogDatabase* getCatalogDatabaseCacheProtoMutable() {
-    return &catalog_database_cache_proto_;
-  }
-
-  /**
-   * @brief Get the query result relation.
-   */
-  const CatalogRelation* getQueryResultRelation() const {
-    return query_result_relation_;
-  }
-
-  /**
-   * @brief Set the query result relation.
-   */
-  void setQueryResultRelation(const CatalogRelation *relation) {
-    query_result_relation_ = relation;
-  }
-
- private:
-  const std::size_t query_id_;
-
-  // The client id of the CLI which submits the query.
-  const tmb::client_id cli_id_;
-
-  const std::uint64_t query_priority_;
-
-  std::unique_ptr<QueryPlan> query_plan_;
-
-  serialization::QueryContext query_context_proto_;
-
-  // TODO(quickstep-team): Use Catalog to support multiple databases.
-  serialization::CatalogDatabase catalog_database_cache_proto_;
-
-  // NOTE(zuyu): The relation gets created by the optimizer,
-  //             and deleted by the Cli shell.
-  const CatalogRelation *query_result_relation_;
-
-  DISALLOW_COPY_AND_ASSIGN(QueryHandle);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_QUERY_OPTIMIZER_QUERY_HANDLE_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/QueryOptimizerConfig.h.in
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryOptimizerConfig.h.in b/query_optimizer/QueryOptimizerConfig.h.in
deleted file mode 100644
index 3bdb6ce..0000000
--- a/query_optimizer/QueryOptimizerConfig.h.in
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#cmakedefine QUICKSTEP_DISTRIBUTED

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/QueryOptimizerModule.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryOptimizerModule.hpp b/query_optimizer/QueryOptimizerModule.hpp
deleted file mode 100644
index d7cb00a..0000000
--- a/query_optimizer/QueryOptimizerModule.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-/** @defgroup QueryOptimizer
- *
- * A system to prepare and optimize query plans for parsed SQL statements.
- **/

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/QueryPlan.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryPlan.hpp b/query_optimizer/QueryPlan.hpp
deleted file mode 100644
index ef6dff4..0000000
--- a/query_optimizer/QueryPlan.hpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_QUERY_PLAN_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_QUERY_PLAN_HPP_
-
-#include <unordered_map>
-#include <utility>
-
-#include "relational_operators/RelationalOperator.hpp"
-#include "utility/DAG.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-
-/** \addtogroup QueryOptimizer
- *  @{
- */
-
-/**
- * @brief A plan to execute a query.
- **/
-class QueryPlan {
- public:
-  typedef DAG<RelationalOperator, bool>::size_type_nodes DAGNodeIndex;
-
-  /**
-   * @brief Constructor.
-   */
-  QueryPlan() {}
-
-  /**
-   * @brief Create a relational operator node in the plan, and set its node
-   *        index.
-   *
-   * @param relational_operator The relational operator to be added to the plan.
-   * @return The node index in the exeuciton plan.
-   */
-  inline DAGNodeIndex addRelationalOperator(RelationalOperator *relational_operator) {
-    const DAGNodeIndex node_index = dag_operators_.createNode(relational_operator);
-    relational_operator->setOperatorIndex(node_index);
-    return node_index;
-  }
-
-  /**
-   * @brief Creates a link from \p producer_operator_index to \p consumer_operator_index
-   *        in the DAG.
-   *
-   * @param consumer_operator_index The index of the consumer operator.
-   * @param producer_operator_index The index of the producer operator.
-   * @param is_pipeline_breaker True if the result from the producer cannot be
-   *                            pipelined to the consumer, otherwise false.
-   */
-  inline void addDirectDependency(DAGNodeIndex consumer_operator_index,
-                                  DAGNodeIndex producer_operator_index,
-                                  bool is_pipeline_breaker) {
-    dag_operators_.createLink(producer_operator_index, consumer_operator_index, is_pipeline_breaker);
-  }
-
-  /**
-   * @brief Creates a link or upgrades the existing link from \p producer_operator_index
-   *        to \p consumer_operator_index in the DAG.
-   *
-   * Depending on whether there is an existing link from \p producer_operator_index
-   * to \p consumer_operator_index:
-   *   - Case 1, no existing link:
-   *         Creates a link with metadata set to is_pipeline_breaker.
-   *   - Case 2, existing link with metadata \p m:
-   *         Set m = (m | is_pipeline_break).
-   *
-   * @param consumer_operator_index The index of the consumer operator.
-   * @param producer_operator_index The index of the producer operator.
-   * @param is_pipeline_breaker True if the result from the producer cannot be
-   *                            pipelined to the consumer, otherwise false.
-   */
-  inline void addOrUpgradeDirectDependency(DAGNodeIndex consumer_operator_index,
-                                           DAGNodeIndex producer_operator_index,
-                                           bool is_pipeline_breaker) {
-    const auto &dependents = dag_operators_.getDependents(producer_operator_index);
-    const auto consumer_it = dependents.find(consumer_operator_index);
-    if (consumer_it == dependents.end()) {
-      dag_operators_.createLink(producer_operator_index,
-                                consumer_operator_index,
-                                is_pipeline_breaker);
-    } else {
-      dag_operators_.setLinkMetadata(producer_operator_index,
-                                     consumer_operator_index,
-                                     consumer_it->second | is_pipeline_breaker);
-    }
-  }
-
-  /**
-   * @brief Creates dependencies for a DropTable operator with index
-   *        \p drop_operator_index. If \p producer_operator_index
-   *        has any dependent, creates a link from \p drop_operator_index
-   *        to each dependent of \p producer_operator_index in the DAG;
-   *        otherwise, create a direct link between \p drop_operator_index
-   *        and \p producer_operator_index.
-   *
-   * @param dependent_operator_index The index of the DropTable operator node.
-   * @param dependency_operator_index The index of the operator node that outputs
-   *                                  the relation to be dropped by the operator
-   *                                  at \p dependent_operator_index.
-   */
-  inline void addDependenciesForDropOperator(DAGNodeIndex drop_operator_index,
-                                             DAGNodeIndex producer_operator_index) {
-    const std::unordered_map<DAGNodeIndex, bool> &direct_dependents =
-        dag_operators_.getDependents(producer_operator_index);
-    if (!direct_dependents.empty()) {
-      for (const std::pair<const DAGNodeIndex, bool> &direct_dependent : direct_dependents) {
-        dag_operators_.createLink(direct_dependent.first,
-                                  drop_operator_index,
-                                  true /* is_pipeline_breaker */);
-      }
-    } else {
-      dag_operators_.createLink(producer_operator_index,
-                                drop_operator_index,
-                                true /* is_pipeline_breaker */);
-    }
-  }
-
-  /**
-   * @return The DAG query plan.
-   */
-  const DAG<RelationalOperator, bool>& getQueryPlanDAG() const {
-    return dag_operators_;
-  }
-
-  /**
-   * @return The DAG query plan.
-   */
-  DAG<RelationalOperator, bool>* getQueryPlanDAGMutable() {
-    return &dag_operators_;
-  }
-
- private:
-  // A false value of the second template argument indicates that the
-  // link between two RelationalOperators is not a pipeline breaker.
-  // while a true value indicates that the link is a pipeline
-  // breaker. Streamed data won't move through pipeline breaker links.
-  DAG<RelationalOperator, bool> dag_operators_;
-
-  DISALLOW_COPY_AND_ASSIGN(QueryPlan);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_QUERY_OPTIMIZER_QUERY_PLAN_HPP_