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:28 UTC
[05/51] [abbrv] [partial] incubator-quickstep git commit: remove c++
files
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/InsertSelection.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/InsertSelection.hpp b/query_optimizer/physical/InsertSelection.hpp
deleted file mode 100644
index 4e22a6e..0000000
--- a/query_optimizer/physical/InsertSelection.hpp
+++ /dev/null
@@ -1,131 +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_INSERT_SELECTION_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_INSERT_SELECTION_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class InsertSelection;
-typedef std::shared_ptr<const InsertSelection> InsertSelectionPtr;
-
-/**
- * @brief Inserts the results from a SELECT query into a relation.
- */
-class InsertSelection : public Physical {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kInsertSelection;
- }
-
- std::string getName() const override { return "InsertSelection"; }
-
- /**
- * @return The destination relation to insert the selection to.
- */
- const PhysicalPtr& destination() const { return destination_; }
-
- /**
- * @return The selection to be inserted.
- */
- const PhysicalPtr& selection() const { return selection_; }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override {
- DCHECK_EQ(getNumChildren(), new_children.size());
- return Create(new_children[0], new_children[1]);
- }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return {};
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override {
- return selection_->getOutputAttributes();
- }
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override {
- return false;
- }
-
- /**
- * @brief Creates an InsertSelection physical node.
- *
- * @param destination The destination relation to insert the selection to.
- * @param selection The selection to be inserted.
- * @return An immutable InsertSelection node.
- */
- static InsertSelectionPtr Create(
- const PhysicalPtr &destination,
- const PhysicalPtr &selection) {
- return InsertSelectionPtr(new InsertSelection(destination, selection));
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- InsertSelection(const PhysicalPtr &destination,
- const PhysicalPtr &selection)
- : destination_(destination),
- selection_(selection) {
- addChild(destination_);
- addChild(selection_);
- }
-
- PhysicalPtr destination_;
- PhysicalPtr selection_;
-
- DISALLOW_COPY_AND_ASSIGN(InsertSelection);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_INSERT_SELECTION_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/InsertTuple.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/InsertTuple.cpp b/query_optimizer/physical/InsertTuple.cpp
deleted file mode 100644
index 3085389..0000000
--- a/query_optimizer/physical/InsertTuple.cpp
+++ /dev/null
@@ -1,49 +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/physical/InsertTuple.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/ScalarLiteral.hpp"
-#include "utility/Cast.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-void InsertTuple::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- non_container_child_field_names->push_back("input");
- non_container_child_fields->push_back(input_);
-
- container_child_field_names->push_back("column_values");
- container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(column_values_));
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/InsertTuple.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/InsertTuple.hpp b/query_optimizer/physical/InsertTuple.hpp
deleted file mode 100644
index 40f2582..0000000
--- a/query_optimizer/physical/InsertTuple.hpp
+++ /dev/null
@@ -1,138 +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_INSERT_TUPLE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_INSERT_TUPLE_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/expressions/ScalarLiteral.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class CatalogRelation;
-
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class InsertTuple;
-typedef std::shared_ptr<const InsertTuple> InsertTuplePtr;
-
-/**
- * @brief Inserts a tuple with <column_values_> into a relation
- * <catalog_relation>.
- */
-class InsertTuple : public Physical {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kInsertTuple;
- }
-
- std::string getName() const override { return "InsertTuple"; }
-
- /**
- * @return The input that produces the relation to insert the tuple to.
- */
- const PhysicalPtr& input() const { return input_; }
-
- /**
- * @return Column values to be used to compose a new tuple.
- */
- const std::vector<expressions::ScalarLiteralPtr>& column_values() const {
- return column_values_;
- }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override {
- DCHECK_EQ(getNumChildren(), new_children.size());
- return Create(new_children[0], column_values_);
- }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return {};
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override {
- return {};
- }
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override {
- return false;
- }
-
- /**
- * @brief Creates an InsertTuple physical node.
- *
- * @param input The input produces the relation to insert the tuple to.
- * @param column_values The column values of the tuple to be inserted.
- * The type checking is done in the Resolver.
- * @return An immutable InsertTuple node.
- */
- static InsertTuplePtr Create(
- const PhysicalPtr &input,
- const std::vector<expressions::ScalarLiteralPtr> &column_values) {
- return InsertTuplePtr(new InsertTuple(input, column_values));
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- InsertTuple(const PhysicalPtr &input,
- const std::vector<expressions::ScalarLiteralPtr> &column_values)
- : input_(input), column_values_(column_values) {
- addChild(input_);
- }
-
- PhysicalPtr input_;
- std::vector<expressions::ScalarLiteralPtr> column_values_;
-
- DISALLOW_COPY_AND_ASSIGN(InsertTuple);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_INSERT_TUPLE_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Join.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Join.hpp b/query_optimizer/physical/Join.hpp
deleted file mode 100644
index 305aa52..0000000
--- a/query_optimizer/physical/Join.hpp
+++ /dev/null
@@ -1,88 +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_JOIN_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_JOIN_HPP_
-
-#include <memory>
-#include <vector>
-
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Join;
-typedef std::shared_ptr<const Join> JoinPtr;
-
-/**
- * @brief Base class for physical join nodes.
- */
-class Join : public Physical {
- public:
- /**
- * @brief Destructor.
- */
- ~Join() override {}
-
- /**
- * @brief Gets the project expressions.
- *
- * @return The list of project expressions.
- */
- const std::vector<expressions::NamedExpressionPtr>& project_expressions() const {
- return project_expressions_;
- }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return expressions::ToRefVector(project_expressions_);
- }
-
- protected:
- /**
- * @brief Constructor.
- *
- * @param project_expressions The project expressions.
- */
- explicit Join(
- const std::vector<expressions::NamedExpressionPtr>& project_expressions)
- : project_expressions_(project_expressions) {}
-
- private:
- std::vector<expressions::NamedExpressionPtr> project_expressions_;
-
- DISALLOW_COPY_AND_ASSIGN(Join);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_JOIN_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/LIPFilterConfiguration.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/LIPFilterConfiguration.hpp b/query_optimizer/physical/LIPFilterConfiguration.hpp
deleted file mode 100644
index 62a6149..0000000
--- a/query_optimizer/physical/LIPFilterConfiguration.hpp
+++ /dev/null
@@ -1,171 +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_LIP_FILTER_CONFIGURATION_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_LIP_FILTER_CONFIGURATION_HPP_
-
-#include <cstddef>
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "utility/Macros.hpp"
-#include "utility/lip_filter/LIPFilter.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Physical;
-typedef std::shared_ptr<const Physical> PhysicalPtr;
-
-/**
- * @brief Optimizer information for a LIP filter builder.
- */
-struct LIPFilterBuildInfo {
- /**
- * @brief Constructor.
- *
- * @param build_attribute_in The attribute to build the LIP filter with.
- * @param filter_cardinality_in The LIP filter's cardinality.
- * @param filter_type_in The LIP filter's type.
- */
- LIPFilterBuildInfo(const expressions::AttributeReferencePtr &build_attribute_in,
- const std::size_t filter_cardinality_in,
- const LIPFilterType &filter_type_in)
- : build_attribute(build_attribute_in),
- filter_cardinality(filter_cardinality_in),
- filter_type(filter_type_in) {
- }
- const expressions::AttributeReferencePtr build_attribute;
- const std::size_t filter_cardinality;
- const LIPFilterType filter_type;
-};
-
-/**
- * @brief Optimizer information for a LIP filter prober.
- */
-struct LIPFilterProbeInfo {
- /**
- * @brief Constructor.
- *
- * @param probe_attribute_in The attribute to probe the LIP filter with.
- * @param build_attribute_in The attribute that the LIP filter is built with.
- * @param builder_in The physical node that the LIP filter's builder is attached to.
- */
- LIPFilterProbeInfo(const expressions::AttributeReferencePtr &probe_attribute_in,
- const expressions::AttributeReferencePtr &build_attribute_in,
- const PhysicalPtr &builder_in)
- : probe_attribute(probe_attribute_in),
- build_attribute(build_attribute_in),
- builder(builder_in) {
- }
- const expressions::AttributeReferencePtr probe_attribute;
- const expressions::AttributeReferencePtr build_attribute;
- const PhysicalPtr builder;
-};
-
-
-class LIPFilterConfiguration;
-typedef std::shared_ptr<const LIPFilterConfiguration> LIPFilterConfigurationPtr;
-
-/**
- * @brief Configuration information of all the LIP filters in a query plan.
- */
-class LIPFilterConfiguration {
- public:
- /**
- * @brief Constructor.
- */
- LIPFilterConfiguration() {
- }
-
- /**
- * @brief Add information for a LIP filter builder.
- *
- * @param build_attribute The attribute to build the LIP filter with.
- * @param builder The physical node to attach the LIP filter builder to.
- * @param filter_size The LIP filter's cardinality.
- * @param filter_type The LIP filter's type.
- */
- void addBuildInfo(const expressions::AttributeReferencePtr &build_attribute,
- const PhysicalPtr &builder,
- const std::size_t filter_size,
- const LIPFilterType &filter_type) {
- build_info_map_[builder].emplace_back(
- build_attribute, filter_size, filter_type);
- }
-
- /**
- * @brief Add information for a LIP filter prober.
- *
- * @param probe_attribute The attribute to probe the LIP filter with.
- * @param prober The physical node to attach the LIP filter prober to.
- * @param build_attribute The attribute that the LIP filter is built with.
- * @param builder The physical node that the LIP filter's builder is attached to.
- */
- void addProbeInfo(const expressions::AttributeReferencePtr &probe_attribute,
- const PhysicalPtr &prober,
- const expressions::AttributeReferencePtr &build_attribute,
- const PhysicalPtr &builder) {
- probe_info_map_[prober].emplace_back(
- probe_attribute, build_attribute, builder);
- }
-
- /**
- * @brief Get all the LIP filter builders.
- *
- * @return A map where each key is a physical node and each mapped value is
- * a vector of all the LIP filter builders that are attached to the
- * physical node.
- */
- const std::map<PhysicalPtr, std::vector<LIPFilterBuildInfo>>& getBuildInfoMap() const {
- return build_info_map_;
- }
-
- /**
- * @brief Get all the LIP filter probers.
- *
- * @return A map where each key is a physical node and each mapped value is
- * a vector of all the LIP filter probers that are attached to the
- * physical node.
- */
- const std::map<PhysicalPtr, std::vector<LIPFilterProbeInfo>>& getProbeInfoMap() const {
- return probe_info_map_;
- }
-
- private:
- std::map<PhysicalPtr, std::vector<LIPFilterBuildInfo>> build_info_map_;
- std::map<PhysicalPtr, std::vector<LIPFilterProbeInfo>> probe_info_map_;
-
- DISALLOW_COPY_AND_ASSIGN(LIPFilterConfiguration);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_LIP_FILTER_CONFIGURATION_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/NestedLoopsJoin.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/NestedLoopsJoin.cpp b/query_optimizer/physical/NestedLoopsJoin.cpp
deleted file mode 100644
index ba3d223..0000000
--- a/query_optimizer/physical/NestedLoopsJoin.cpp
+++ /dev/null
@@ -1,91 +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/physical/NestedLoopsJoin.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-std::vector<expressions::AttributeReferencePtr> NestedLoopsJoin::getReferencedAttributes() const {
- std::vector<expressions::AttributeReferencePtr> referenced_attributes;
- for (const expressions::NamedExpressionPtr &project_expression :
- project_expressions()) {
- const std::vector<expressions::AttributeReferencePtr> referenced_attributes_in_expression =
- project_expression->getReferencedAttributes();
- referenced_attributes.insert(referenced_attributes.end(),
- referenced_attributes_in_expression.begin(),
- referenced_attributes_in_expression.end());
- }
- const std::vector<expressions::AttributeReferencePtr> referenced_attributes_in_predicate =
- join_predicate_->getReferencedAttributes();
- referenced_attributes.insert(referenced_attributes.end(),
- referenced_attributes_in_predicate.begin(),
- referenced_attributes_in_predicate.end());
- return referenced_attributes;
-}
-
-bool NestedLoopsJoin::maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const {
- std::vector<expressions::NamedExpressionPtr> new_project_expressions;
- const std::vector<expressions::NamedExpressionPtr> ¤t_project_expressions =
- project_expressions();
- for (const expressions::NamedExpressionPtr &project_expression :
- current_project_expressions) {
- if (referenced_expressions.find(project_expression) !=
- referenced_expressions.end()) {
- new_project_expressions.emplace_back(project_expression);
- }
- }
- if (new_project_expressions.size() != current_project_expressions.size()) {
- *output = Create(left(), right(), join_predicate_, new_project_expressions);
- return true;
- }
- return false;
-}
-
-void NestedLoopsJoin::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- BinaryJoin::getFieldStringItems(inline_field_names,
- inline_field_values,
- non_container_child_field_names,
- non_container_child_fields,
- container_child_field_names,
- container_child_fields);
- non_container_child_field_names->push_back("join_predicate");
- non_container_child_fields->push_back(join_predicate_);
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/NestedLoopsJoin.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/NestedLoopsJoin.hpp b/query_optimizer/physical/NestedLoopsJoin.hpp
deleted file mode 100644
index c547ae8..0000000
--- a/query_optimizer/physical/NestedLoopsJoin.hpp
+++ /dev/null
@@ -1,133 +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_NESTED_LOOPS_JOIN_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_NESTED_LOOPS_JOIN_HPP_
-
-#include <memory>
-#include <set>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/expressions/Predicate.hpp"
-#include "query_optimizer/physical/BinaryJoin.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class NestedLoopsJoin;
-typedef std::shared_ptr<const NestedLoopsJoin> NestedLoopsJoinPtr;
-
-/**
- * @brief Physical nested loops join node.
- */
-class NestedLoopsJoin : public BinaryJoin {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kNestedLoopsJoin;
- }
-
- std::string getName() const override { return "NestedLoopsJoin"; }
-
- /**
- * @return The join predicate.
- */
- const expressions::PredicatePtr& join_predicate() const {
- return join_predicate_;
- }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override {
- DCHECK_EQ(children().size(), new_children.size());
- return Create(new_children[0],
- new_children[1],
- join_predicate_,
- project_expressions());
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override;
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override;
-
- /**
- * @brief Creates a NestedLoopsJoin.
- *
- * @param left The left operand.
- * @param right The right operand.
- * @param join_predicate The join predicate.
- * @param project_expressions The project expressions.
- * @return An immutable NestedLoopsJoin.
- */
- static NestedLoopsJoinPtr Create(
- const PhysicalPtr &left,
- const PhysicalPtr &right,
- const expressions::PredicatePtr &join_predicate,
- const std::vector<expressions::NamedExpressionPtr> &project_expressions) {
- return NestedLoopsJoinPtr(
- new NestedLoopsJoin(left, right, join_predicate, project_expressions));
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- NestedLoopsJoin(
- const PhysicalPtr &left,
- const PhysicalPtr &right,
- const expressions::PredicatePtr &join_predicate,
- const std::vector<expressions::NamedExpressionPtr> &project_expressions)
- : BinaryJoin(left, right, project_expressions),
- join_predicate_(join_predicate) {
- DCHECK(join_predicate_ != nullptr);
- }
-
- expressions::PredicatePtr join_predicate_;
-
- DISALLOW_COPY_AND_ASSIGN(NestedLoopsJoin);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_NESTED_LOOPS_JOIN_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/OptimizerPhysicalModule.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/OptimizerPhysicalModule.hpp b/query_optimizer/physical/OptimizerPhysicalModule.hpp
deleted file mode 100644
index fd2cc02..0000000
--- a/query_optimizer/physical/OptimizerPhysicalModule.hpp
+++ /dev/null
@@ -1,24 +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 OptimizerPhysical
- * @ingroup QueryOptimizer
- *
- * Physical operators used in the query optimizer.
- **/
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/PatternMatcher.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/PatternMatcher.hpp b/query_optimizer/physical/PatternMatcher.hpp
deleted file mode 100644
index 5cd6fd3..0000000
--- a/query_optimizer/physical/PatternMatcher.hpp
+++ /dev/null
@@ -1,133 +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_PATTERN_MATCHER_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PATTERN_MATCHER_HPP_
-
-#include <memory>
-#include <type_traits>
-
-#include "query_optimizer/physical/PhysicalType.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-class Aggregate;
-class BinaryJoin;
-class CopyFrom;
-class CreateTable;
-class DeleteTuples;
-class DropTable;
-class HashJoin;
-class InsertTuple;
-class Join;
-class NestedLoopsJoin;
-class Selection;
-class SharedSubplanReference;
-class Sort;
-class TableReference;
-class TopLevelPlan;
-class UpdateTable;
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-/**
- * @brief Templated matcher for each Physical node class.
- *
- * @param PhysicalClass The Physical class for the physical node to be matched with.
- * @param physical_types All the physical types of the Physical class.
- */
-template <class PhysicalClass, PhysicalType... physical_types>
-class SomePhysicalNode {
- public:
- /**
- * @brief Checks whether the object managed in \p physical is an instance
- * of the template argument PhysicalClass by checking whether
- * it is one of types in the given template arguments physical_types.
- *
- * @param physical The physical node to be checked.
- * @return True for a match; otherwise false.
- */
- template <class OtherPhysicalClass>
- static bool Matches(const std::shared_ptr<const OtherPhysicalClass> &physical) {
- for (const PhysicalType physical_type : kPhysicalTypes) {
- if (physical->getPhysicalType() == physical_type) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @brief Checks whether the object managed in \p physical is an instance
- * of the template argument PhysicalClass by checking whether
- * it is one of types in the given template arguments physical_types,
- * If true, it additionally casts \p physical to a std::shared_ptr
- * \p cast_physical of the template argument PhysicalClass.
- *
- * @param physical The physical node to be checked.
- * @param cast_physical The cast physical node.
- * @return True if the object managed in \p physical is an instance of PhysicalClass.
- */
- template <class OtherPhysicalClass>
- static bool MatchesWithConditionalCast(const std::shared_ptr<const OtherPhysicalClass> &physical,
- std::shared_ptr<const PhysicalClass> *cast_physical) {
- bool is_match = Matches(physical);
- if (is_match) {
- *cast_physical = std::static_pointer_cast<const PhysicalClass>(physical);
- }
- return is_match;
- }
-
- private:
- constexpr static PhysicalType kPhysicalTypes[] = {physical_types...};
-};
-
-template <class PhysicalClass, PhysicalType... physical_types>
-constexpr PhysicalType SomePhysicalNode<PhysicalClass, physical_types...>::kPhysicalTypes[];
-
-// Specializations for all Physical classes.
-
-using SomeAggregate = SomePhysicalNode<Aggregate, PhysicalType::kAggregate>;
-using SomeBinaryJoin = SomePhysicalNode<BinaryJoin, PhysicalType::kHashJoin, PhysicalType::kNestedLoopsJoin>;
-using SomeCopyFrom = SomePhysicalNode<CopyFrom, PhysicalType::kCopyFrom>;
-using SomeCreateTable = SomePhysicalNode<CreateTable, PhysicalType::kCreateTable>;
-using SomeDeleteTuples = SomePhysicalNode<DeleteTuples, PhysicalType::kDeleteTuples>;
-using SomeDropTable = SomePhysicalNode<DropTable, PhysicalType::kDropTable>;
-using SomeHashJoin = SomePhysicalNode<HashJoin, PhysicalType::kHashJoin>;
-using SomeInsertTuple = SomePhysicalNode<InsertTuple, PhysicalType::kInsertTuple>;
-using SomeJoin = SomePhysicalNode<Join, PhysicalType::kHashJoin, PhysicalType::kNestedLoopsJoin>;
-using SomeNestedLoopsJoin = SomePhysicalNode<NestedLoopsJoin, PhysicalType::kNestedLoopsJoin>;
-using SomeSelection = SomePhysicalNode<Selection, PhysicalType::kSelection>;
-using SomeSharedSubplanReference = SomePhysicalNode<SharedSubplanReference, PhysicalType::kSharedSubplanReference>;
-using SomeSort = SomePhysicalNode<Sort, PhysicalType::kSort>;
-using SomeTableReference = SomePhysicalNode<TableReference, PhysicalType::kTableReference>;
-using SomeTopLevelPlan = SomePhysicalNode<TopLevelPlan, PhysicalType::kTopLevelPlan>;
-using SomeUpdateTable = SomePhysicalNode<UpdateTable, PhysicalType::kUpdateTable>;
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PATTERN_MATCHER_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Physical.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Physical.hpp b/query_optimizer/physical/Physical.hpp
deleted file mode 100644
index 4bed593..0000000
--- a/query_optimizer/physical/Physical.hpp
+++ /dev/null
@@ -1,105 +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_PHYSICAL_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PHYSICAL_HPP_
-
-#include <memory>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Physical;
-typedef std::shared_ptr<const Physical> PhysicalPtr;
-
-/**
- * @brief Base class for physical plan nodes.
- */
-class Physical : public OptimizerTree<Physical> {
- public:
- /**
- * @brief Destructor.
- */
- ~Physical() override {}
-
- /**
- * @return The physical node type.
- */
- virtual PhysicalType getPhysicalType() const = 0;
-
- /**
- * @brief Gets the output attributes of this node.
- *
- * @return The output AttributeReferences by this node.
- */
- virtual std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const = 0;
-
- /**
- * @brief Returns AttributeReferences referenced by the input expressions of
- * this physical node.
- *
- * @return A vector of AttributeReference referenced by the input expressions
- * of this physical node.
- */
- virtual std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const = 0;
-
- /**
- * @brief Creates a new copy in \p output if there are some project
- * expressions that are not in \p referenced_expressions.
- * Otherwise, keeps \p output unchanged.
- *
- * @param referenced_attributes The attributes to be kept in the project
- * expression list.
- * @param output A new copy if some project expressions should be removed.
- * @return True if a new copy is generated (i.e. \p output is changed).
- */
- virtual bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const = 0;
-
- protected:
- /**
- * @brief Constructor.
- */
- Physical() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Physical);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PHYSICAL_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/PhysicalType.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/PhysicalType.hpp b/query_optimizer/physical/PhysicalType.hpp
deleted file mode 100644
index f5f35a1..0000000
--- a/query_optimizer/physical/PhysicalType.hpp
+++ /dev/null
@@ -1,62 +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_PHYSICAL_TYPE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PHYSICAL_TYPE_HPP_
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-/**
- * @brief Optimizer physical node types.
- **/
-enum class PhysicalType {
- kAggregate,
- kCopyFrom,
- kCreateIndex,
- kCreateTable,
- kDeleteTuples,
- kDropTable,
- kHashJoin,
- kInsertSelection,
- kInsertTuple,
- kNestedLoopsJoin,
- kSample,
- kSelection,
- kSharedSubplanReference,
- kSort,
- kTableGenerator,
- kTableReference,
- kTopLevelPlan,
- kUpdateTable,
- kWindowAggregate
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_PHYSICAL_TYPE_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Sample.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Sample.cpp b/query_optimizer/physical/Sample.cpp
deleted file mode 100644
index 689c3cc..0000000
--- a/query_optimizer/physical/Sample.cpp
+++ /dev/null
@@ -1,64 +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/physical/Sample.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "utility/Cast.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-namespace E = ::quickstep::optimizer::expressions;
-
-PhysicalPtr Sample::copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const {
- DCHECK_EQ(children().size(), new_children.size());
- return Create(new_children[0], is_block_sample_, percentage_);
-}
-
-void Sample::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- non_container_child_field_names->emplace_back("input");
- non_container_child_fields->emplace_back(input());
-
- inline_field_names->emplace_back("percentage");
- inline_field_values->emplace_back(std::to_string(percentage_));
-
- inline_field_names->emplace_back("is_block_sample");
- inline_field_values->emplace_back(std::to_string(is_block_sample_));
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Sample.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Sample.hpp b/query_optimizer/physical/Sample.hpp
deleted file mode 100644
index e3e8f17..0000000
--- a/query_optimizer/physical/Sample.hpp
+++ /dev/null
@@ -1,138 +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_SAMPLE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SAMPLE_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Sample;
-typedef std::shared_ptr<const Sample> SamplePtr;
-
-/**
- * @brief Sample operator that samples the data at a block level or
- * at the tuple level and outputs them as a new relation.
- */
-class Sample : public Physical {
- public:
- PhysicalType getPhysicalType() const override { return PhysicalType::kSample; }
-
- std::string getName() const override { return " SAMPLE"; }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return input_->getOutputAttributes();
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override {
- return input_->getReferencedAttributes();
- }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override;
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override {
- return false;
- }
-
- /**
- * @return the sample percentage.
- */
- int percentage() const {
- return percentage_;
- }
-
- /**
- * @return flag indicating if the sampling is block or tuple.
- */
- const bool is_block_sample() const {
- return is_block_sample_;
- }
-
- /**
- * @return Input physical node.
- */
- const PhysicalPtr& input() const { return children()[0]; }
-
- /**
- * @brief Creates a SamplePtr.
- * @param input The input node.
- * @param is_block_sample Flag indicating if the sample is block or tuple level
- * @param percentage The percentage of rows or blocks to be sampled
- * @return An immutable Sample.
- */
- static SamplePtr Create(const PhysicalPtr &input,
- const bool is_block_sample,
- const int percentage) {
- return SamplePtr(new Sample(input, is_block_sample, percentage));
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- Sample(
- const PhysicalPtr &input,
- const bool is_block_sample,
- const int percentage)
- : percentage_(percentage),
- is_block_sample_(is_block_sample),
- input_(input) {
- addChild(input);
- }
-
- const int percentage_;
- const bool is_block_sample_;
- const PhysicalPtr input_;
-
- DISALLOW_COPY_AND_ASSIGN(Sample);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif // QUICKSTEP_QUERY_OPTIMIZER_SAMPLE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Selection.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Selection.cpp b/query_optimizer/physical/Selection.cpp
deleted file mode 100644
index 36ade04..0000000
--- a/query_optimizer/physical/Selection.cpp
+++ /dev/null
@@ -1,107 +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/physical/Selection.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "utility/Cast.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-namespace E = ::quickstep::optimizer::expressions;
-
-PhysicalPtr Selection::copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const {
- DCHECK_EQ(children().size(), new_children.size());
- return Create(new_children[0], project_expressions_, filter_predicate_);
-}
-
-std::vector<E::AttributeReferencePtr> Selection::getOutputAttributes() const {
- return ToRefVector(project_expressions_);
-}
-
-std::vector<E::AttributeReferencePtr> Selection::getReferencedAttributes() const {
- std::vector<E::AttributeReferencePtr> referenced_attributes;
- for (const E::NamedExpressionPtr &project_expression : project_expressions_) {
- const std::vector<E::AttributeReferencePtr> referenced_attributes_in_expression =
- project_expression->getReferencedAttributes();
- referenced_attributes.insert(referenced_attributes.end(),
- referenced_attributes_in_expression.begin(),
- referenced_attributes_in_expression.end());
- }
- if (filter_predicate_ != nullptr) {
- const std::vector<E::AttributeReferencePtr> referenced_attributes_in_predicate =
- filter_predicate_->getReferencedAttributes();
- referenced_attributes.insert(referenced_attributes.end(),
- referenced_attributes_in_predicate.begin(),
- referenced_attributes_in_predicate.end());
- }
- return referenced_attributes;
-}
-
-bool Selection::maybeCopyWithPrunedExpressions(
- const E::UnorderedNamedExpressionSet &referenced_attributes,
- PhysicalPtr *output) const {
- std::vector<E::NamedExpressionPtr> new_project_expressions;
- for (const E::NamedExpressionPtr &project_expression : project_expressions_) {
- if (referenced_attributes.find(project_expression) !=
- referenced_attributes.end()) {
- new_project_expressions.emplace_back(project_expression);
- }
- }
- if (new_project_expressions.size() != project_expressions_.size()) {
- *output = Create(input(), new_project_expressions, filter_predicate_);
- return true;
- }
- return false;
-}
-
-void Selection::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- non_container_child_field_names->emplace_back("input");
- non_container_child_fields->emplace_back(input());
-
- if (filter_predicate_ != nullptr) {
- non_container_child_field_names->emplace_back("filter_predicate");
- non_container_child_fields->emplace_back(filter_predicate_);
- }
-
- container_child_field_names->emplace_back("project_expressions");
- container_child_fields->emplace_back(
- CastSharedPtrVector<OptimizerTreeBase>(project_expressions_));
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Selection.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Selection.hpp b/query_optimizer/physical/Selection.hpp
deleted file mode 100644
index b6874a1..0000000
--- a/query_optimizer/physical/Selection.hpp
+++ /dev/null
@@ -1,162 +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_SELECTION_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SELECTION_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/expressions/LogicalAnd.hpp"
-#include "query_optimizer/expressions/Predicate.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Selection;
-typedef std::shared_ptr<const Selection> SelectionPtr;
-
-/**
- * @brief Physical node that evaluates a predicate for each input tuple,
- * computes and outputs the values of project expressions if the
- * predicate evaluates to true.
- */
-class Selection : public Physical {
- public:
- PhysicalType getPhysicalType() const override { return PhysicalType::kSelection; }
-
- std::string getName() const override { return "Selection"; }
-
- /**
- * @return Filter predicate to evaluate during scanning the input.
- */
- inline const expressions::PredicatePtr& filter_predicate() const {
- return filter_predicate_;
- }
-
- /**
- * @return Project expressions to compute.
- */
- inline const std::vector<expressions::NamedExpressionPtr>& project_expressions() const {
- return project_expressions_;
- }
-
- /**
- * @return Input physical node.
- */
- inline const PhysicalPtr& input() const { return children()[0]; }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override;
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override;
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override;
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_attributes,
- PhysicalPtr *output) const override;
-
- /**
- * @brief Creates a Selection.
- *
- * @param input The input node.
- * @param project_expressions The project expressions.
- * @param filter_predicate The filter predicate. Can be NULL.
- * @return An immutable Selection.
- */
- static SelectionPtr Create(
- const PhysicalPtr &input,
- const std::vector<expressions::NamedExpressionPtr> &project_expressions,
- const expressions::PredicatePtr &filter_predicate) {
- return SelectionPtr(
- new Selection(input, project_expressions, filter_predicate));
- }
-
- /**
- * @brief Creates a conjunctive predicate with \p filter_predicates
- * as operands, and creates a Selection with the predicate.
- *
- * @param input The input node.
- * @param project_expressions The project expressions.
- * @param filter_predicates A list of filter predicates.
- * The predicate in the created Selection is
- * a conjunction of them.
- * @return An immutable Selection.
- */
- static SelectionPtr CreateWithConjuction(
- const PhysicalPtr &input,
- const std::vector<expressions::NamedExpressionPtr> &project_expressions,
- const std::vector<expressions::PredicatePtr> &filter_predicates) {
- if (filter_predicates.size() > 1u) {
- return Create(input, project_expressions,
- expressions::LogicalAnd::Create(filter_predicates));
- } else if (filter_predicates.size() == 1u) {
- return Create(input, project_expressions, filter_predicates[0]);
- } else {
- return Create(input, project_expressions, expressions::PredicatePtr());
- }
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- Selection(
- const PhysicalPtr &input,
- const std::vector<expressions::NamedExpressionPtr> &project_expressions,
- const expressions::PredicatePtr &filter_predicate)
- : project_expressions_(project_expressions),
- filter_predicate_(filter_predicate) {
- addChild(input);
- }
-
- std::vector<expressions::NamedExpressionPtr> project_expressions_;
- // Can be NULL. If NULL, the filter predicate is treated as the literal true.
- expressions::PredicatePtr filter_predicate_;
-
- DISALLOW_COPY_AND_ASSIGN(Selection);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SELECTION_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/SharedSubplanReference.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/SharedSubplanReference.cpp b/query_optimizer/physical/SharedSubplanReference.cpp
deleted file mode 100644
index 1ba9b16..0000000
--- a/query_optimizer/physical/SharedSubplanReference.cpp
+++ /dev/null
@@ -1,54 +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/physical/SharedSubplanReference.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "utility/Cast.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-void SharedSubplanReference::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- inline_field_names->push_back("subplan_id");
- inline_field_values->push_back(std::to_string(subplan_id_));
-
- container_child_field_names->push_back("referenced_attributes");
- container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(referenced_attributes_));
-
- container_child_field_names->push_back("output_attributes");
- container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(output_attributes_));
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/SharedSubplanReference.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/SharedSubplanReference.hpp b/query_optimizer/physical/SharedSubplanReference.hpp
deleted file mode 100644
index 60a2866..0000000
--- a/query_optimizer/physical/SharedSubplanReference.hpp
+++ /dev/null
@@ -1,148 +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_SHARED_SUBPLAN_REFERENCE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SHARED_SUBPLAN_REFERENCE_HPP_
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class SharedSubplanReference;
-typedef std::shared_ptr<const SharedSubplanReference> SharedSubplanReferencePtr;
-
-/**
- * @breif A reference to a shared subplan stored in the TopLevelPlan node.
- */
-class SharedSubplanReference : public physical::Physical {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kSharedSubplanReference;
- }
-
- std::string getName() const override {
- return "SharedSubplanReference";
- }
-
- /**
- * @return The ID of the shared subplan.
- */
- int subplan_id() const {
- return subplan_id_;
- }
-
- /**
- * @return The attributes from the referenced shared subplan.
- */
- const std::vector<expressions::AttributeReferencePtr>& referenced_attributes() const {
- return referenced_attributes_;
- }
-
- /**
- * @return The output attributes of this shared subplan reference.
- */
- const std::vector<expressions::AttributeReferencePtr>& output_attributes() const {
- return output_attributes_;
- }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return output_attributes_;
- }
-
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- PhysicalPtr copyWithNewChildren(const std::vector<PhysicalPtr> &new_children) const override {
- DCHECK(new_children.empty());
- return Create(subplan_id_, referenced_attributes_, output_attributes_);
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override {
- return referenced_attributes_;
- }
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override {
- return false;
- }
-
- /**
- * @brief Creates a SharedSubplanReference.
- *
- * @param subplan_id The ID of the shared subplan, which is the index of
- * the referenced shared subplan in <shared_subplans_> of the TopLevelPlan.
- * @param referenced_attributes The attributes from the referenced shared subplan.
- * @param output_attributes The output attributes of this shared subplan reference.
- * @return An immutable SharedSubplanReference.
- */
- static SharedSubplanReferencePtr Create(
- int subplan_id,
- const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
- const std::vector<expressions::AttributeReferencePtr> &output_attributes) {
- return SharedSubplanReferencePtr(
- new SharedSubplanReference(subplan_id, referenced_attributes, output_attributes));
- }
-
- private:
- SharedSubplanReference(int subplan_id,
- const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
- const std::vector<expressions::AttributeReferencePtr> &output_attributes)
- : subplan_id_(subplan_id),
- referenced_attributes_(referenced_attributes),
- output_attributes_(output_attributes) {
- DCHECK_EQ(output_attributes_.size(), referenced_attributes_.size());
- }
-
- int subplan_id_;
- std::vector<expressions::AttributeReferencePtr> referenced_attributes_;
- std::vector<expressions::AttributeReferencePtr> output_attributes_;
-
- DISALLOW_COPY_AND_ASSIGN(SharedSubplanReference);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SHARED_SUBPLAN_REFERENCE_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Sort.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Sort.cpp b/query_optimizer/physical/Sort.cpp
deleted file mode 100644
index b8bbbd4..0000000
--- a/query_optimizer/physical/Sort.cpp
+++ /dev/null
@@ -1,101 +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/physical/Sort.hpp"
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "utility/Cast.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-bool Sort::maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_attributes,
- PhysicalPtr *output) const {
- std::vector<expressions::AttributeReferencePtr> new_non_sort_attributes;
- for (const expressions::AttributeReferencePtr &non_sort_attribute : non_sort_attributes_) {
- if (referenced_attributes.find(non_sort_attribute) != referenced_attributes.end()) {
- new_non_sort_attributes.emplace_back(non_sort_attribute);
- }
- }
- if (new_non_sort_attributes.size() != non_sort_attributes_.size()) {
- *output = Create(input_,
- sort_attributes_,
- new_non_sort_attributes,
- sort_ascending_,
- nulls_first_flags_,
- limit_);
- return true;
- }
- return false;
-}
-
-void Sort::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
- non_container_child_field_names->push_back("input");
- non_container_child_fields->push_back(input_);
-
- inline_field_names->push_back("is_ascending");
- std::string ascending_list("[");
- for (bool is_ascending : sort_ascending_) {
- if (is_ascending) {
- ascending_list.append("true,");
- } else {
- ascending_list.append("false,");
- }
- }
- ascending_list.pop_back();
- ascending_list.append("]");
- inline_field_values->push_back(ascending_list);
-
- inline_field_names->push_back("nulls_first");
- std::string nulls_first_flags("[");
- for (bool nulls_first_flag : nulls_first_flags_) {
- if (nulls_first_flag) {
- nulls_first_flags.append("true,");
- } else {
- nulls_first_flags.append("false,");
- }
- }
- nulls_first_flags.pop_back();
- nulls_first_flags.append("]");
- inline_field_values->push_back(nulls_first_flags);
-
- if (limit_ != -1) {
- inline_field_names->push_back("limit");
- inline_field_values->push_back(std::to_string(limit_));
- }
-
- container_child_field_names->push_back("sort_attributes");
- container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(sort_attributes_));
-}
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/Sort.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Sort.hpp b/query_optimizer/physical/Sort.hpp
deleted file mode 100644
index d0c6fe8..0000000
--- a/query_optimizer/physical/Sort.hpp
+++ /dev/null
@@ -1,192 +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_SORT_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SORT_HPP_
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class Sort;
-typedef std::shared_ptr<const Sort> SortPtr;
-
-/**
- * @brief Sort operator.
- */
-class Sort : public Physical {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kSort;
- }
-
- std::string getName() const override {
- return "Sort";
- }
-
- const PhysicalPtr& input() const {
- return input_;
- }
-
- /**
- * @return The sorting attributes.
- */
- const std::vector<expressions::AttributeReferencePtr>& sort_attributes() const {
- return sort_attributes_;
- }
-
- /**
- * @brief The order direction for every sorting attributes.
- */
- const std::vector<bool>& sort_ascending() const {
- return sort_ascending_;
- }
-
- /**
- * @brief The order directions for null values.
- */
- const std::vector<bool>& nulls_first_flags() const {
- return nulls_first_flags_;
- }
-
- /**
- * @return The number of output sorted rows. -1 for a full table sort.
- */
- int limit() const {
- return limit_;
- }
-
- std::vector<expressions::AttributeReferencePtr> getOutputAttributes() const override {
- return input_->getOutputAttributes();
- }
-
- std::vector<expressions::AttributeReferencePtr> getReferencedAttributes() const override {
- std::vector<expressions::AttributeReferencePtr> referenced_attributes =
- sort_attributes_;
- referenced_attributes.insert(referenced_attributes.end(),
- non_sort_attributes_.begin(),
- non_sort_attributes_.end());
- return referenced_attributes;
- }
-
- PhysicalPtr copyWithNewChildren(const std::vector<PhysicalPtr> &new_children) const override {
- DCHECK_EQ(getNumChildren(), new_children.size());
- return Create(new_children[0],
- sort_attributes_,
- non_sort_attributes_,
- sort_ascending_,
- nulls_first_flags_,
- limit_);
- }
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_attributes,
- PhysicalPtr *output) const override;
-
- /**
- * @brief Creates a physical Sort operator.
- *
- * @param input The input to the Sort.
- * @param sort_attributes The attributes as the ordering keys.
- * @param non_sort_attributes The output attributes other than sort_attributes.
- * @param sort_ascending The vector of ordering directions.
- * @param nulls_first_flags The vector of ordering directions for null values.
- * @param limit The number of output rows. -1 for a full table sort.
- *
- * @return An immutable physical Sort.
- */
- static SortPtr Create(const PhysicalPtr &input,
- const std::vector<expressions::AttributeReferencePtr> &sort_attributes,
- const std::vector<expressions::AttributeReferencePtr> &non_sort_attributes,
- const std::vector<bool> &sort_ascending,
- const std::vector<bool> &nulls_first_flags,
- const int limit) {
- DCHECK_EQ(sort_attributes.size(), sort_ascending.size());
- DCHECK_EQ(sort_attributes.size(), nulls_first_flags.size());
-
- return SortPtr(new Sort(input,
- sort_attributes,
- non_sort_attributes,
- sort_ascending,
- nulls_first_flags,
- limit));
- }
-
- protected:
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
-
- private:
- Sort(const PhysicalPtr &input,
- const std::vector<expressions::AttributeReferencePtr> &sort_attributes,
- const std::vector<expressions::AttributeReferencePtr> &non_sort_attributes,
- const std::vector<bool> &sort_ascending,
- const std::vector<bool> &nulls_first_flags,
- const int limit)
- : input_(input),
- sort_attributes_(sort_attributes),
- non_sort_attributes_(non_sort_attributes),
- sort_ascending_(sort_ascending),
- nulls_first_flags_(nulls_first_flags),
- limit_(limit) {
- addChild(input);
- }
-
- PhysicalPtr input_;
- std::vector<expressions::AttributeReferencePtr> sort_attributes_;
- // non_sort_attributes_ is present only for Rule PruneColumns,
- // which need attributes referenced by Sort (i.e. sort_attributes_)
- // and others by its ancestors (i.e. non_sort_attributes_).
- // The output attributes by Sort may contain additional non-sorting attributes,
- // since the input physical of the Sort may not allow column pruning.
- std::vector<expressions::AttributeReferencePtr> non_sort_attributes_;
- std::vector<bool> sort_ascending_;
- std::vector<bool> nulls_first_flags_;
- int limit_;
-
- DISALLOW_COPY_AND_ASSIGN(Sort);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SORT_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/physical/TableGenerator.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/TableGenerator.hpp b/query_optimizer/physical/TableGenerator.hpp
deleted file mode 100644
index c9ff8a8..0000000
--- a/query_optimizer/physical/TableGenerator.hpp
+++ /dev/null
@@ -1,161 +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_TABLE_GENERATOR_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_TABLE_GENERATOR_HPP_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "expressions/table_generator/GeneratorFunctionHandle.hpp"
-#include "query_optimizer/OptimizerTree.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "query_optimizer/expressions/ExpressionUtil.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "utility/Cast.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-namespace physical {
-
-namespace E = ::quickstep::optimizer::expressions;
-
-/** \addtogroup OptimizerPhysical
- * @{
- */
-
-class TableGenerator;
-typedef std::shared_ptr<const TableGenerator> TableGeneratorPtr;
-
-/**
- * @brief Leaf physical node that represents a table that will be populated
- * by a generator function.
- */
-class TableGenerator : public Physical {
- public:
- PhysicalType getPhysicalType() const override {
- return PhysicalType::kTableGenerator;
- }
-
- std::string getName() const override { return "TableGenerator"; }
-
- PhysicalPtr copyWithNewChildren(
- const std::vector<PhysicalPtr> &new_children) const override {
- return TableGeneratorPtr(
- new TableGenerator(generator_function_handle_,
- table_alias_,
- attribute_list_));
- }
-
- bool maybeCopyWithPrunedExpressions(
- const expressions::UnorderedNamedExpressionSet &referenced_expressions,
- PhysicalPtr *output) const override {
- // The number of output columns is fixed for generator functions.
- return false;
- }
-
- /**
- * @return The reference to the generator function handle.
- */
- const GeneratorFunctionHandlePtr& generator_function_handle() const {
- return generator_function_handle_;
- }
-
- /**
- * @return The alias name of this table.
- */
- const std::string& table_alias() const {
- return table_alias_;
- }
-
- const std::vector<expressions::AttributeReferencePtr>& attribute_list() const {
- return attribute_list_;
- }
-
- std::vector<E::AttributeReferencePtr> getOutputAttributes() const override {
- return attribute_list_;
- }
-
- std::vector<E::AttributeReferencePtr> getReferencedAttributes() const override {
- return {};
- }
-
- 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
- std::vector<std::string> *container_child_field_names,
- std::vector<std::vector<OptimizerTreeBaseNodePtr>> *
- container_child_fields) const override {
- inline_field_names->push_back("function_name");
- inline_field_values->push_back(generator_function_handle_->getName());
-
- if (table_alias_ != generator_function_handle_->getName()) {
- inline_field_names->push_back("table_alias");
- inline_field_values->push_back(table_alias_);
- }
-
- container_child_field_names->push_back("");
- container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(attribute_list_));
- }
-
- /**
- * @brief Creates a table generator that generates a table.
- *
- * @param A generator function handle.
- * @return An immutable TableGenerator.
- */
- static TableGeneratorPtr Create(
- const GeneratorFunctionHandlePtr &generator_function_handle,
- const std::string &table_alias,
- const std::vector<E::AttributeReferencePtr> &attribute_list) {
- return TableGeneratorPtr(
- new TableGenerator(generator_function_handle,
- table_alias,
- attribute_list));
- }
-
- private:
- TableGenerator(const GeneratorFunctionHandlePtr &generator_function_handle,
- const std::string &table_alias,
- const std::vector<E::AttributeReferencePtr> &attribute_list)
- : generator_function_handle_(generator_function_handle),
- table_alias_(table_alias),
- attribute_list_(attribute_list) {
- }
-
- GeneratorFunctionHandlePtr generator_function_handle_;
- std::string table_alias_;
- std::vector<E::AttributeReferencePtr> attribute_list_;
-
- DISALLOW_COPY_AND_ASSIGN(TableGenerator);
-};
-
-/** @} */
-
-} // namespace physical
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_TABLE_GENERATOR_HPP_ */