Code style fix.
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 8dd93d0..f8f7c9d 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -687,7 +687,7 @@
void ExecutionGenerator::convertSelection(
const P::SelectionPtr &physical_selection) {
- const P::PhysicalPtr input = physical_selection->input();
+ const P::PhysicalPtr &input = physical_selection->input();
const CatalogRelationInfo *input_relation_info =
findRelationInfoOutputByPhysical(input);
DCHECK(input_relation_info != nullptr);
@@ -829,7 +829,7 @@
}
void ExecutionGenerator::convertFilterJoin(const P::FilterJoinPtr &physical_plan) {
- P::PhysicalPtr probe_physical = physical_plan->left();
+ const P::PhysicalPtr &probe_physical = physical_plan->left();
P::PhysicalPtr build_physical = physical_plan->right();
// Let B denote the build side child. If B is also a FilterJoin, then the
@@ -891,13 +891,13 @@
// HashJoin is converted to three operators:
// BuildHash, HashJoin, DestroyHash. The second is the primary operator.
- P::PhysicalPtr probe_physical = physical_plan->left();
- P::PhysicalPtr build_physical = physical_plan->right();
+ const P::PhysicalPtr &probe_physical = physical_plan->left();
+ const P::PhysicalPtr &build_physical = physical_plan->right();
std::vector<attribute_id> probe_attribute_ids;
std::vector<attribute_id> build_attribute_ids;
- std::size_t build_cardinality =
+ const std::size_t build_cardinality =
cost_model_for_hash_join_->estimateCardinality(build_physical);
bool any_probe_attributes_nullable = false;
@@ -1487,7 +1487,6 @@
*catalog_database_->getRelationById(
input_relation_info->relation->getID());
-
// Construct the tuple proto to be inserted.
std::vector<QueryContext::tuple_id> tuple_indexes;
diff --git a/query_optimizer/expressions/AggregateFunction.hpp b/query_optimizer/expressions/AggregateFunction.hpp
index 108c661..22c7adb 100644
--- a/query_optimizer/expressions/AggregateFunction.hpp
+++ b/query_optimizer/expressions/AggregateFunction.hpp
@@ -164,7 +164,7 @@
}
const ::quickstep::AggregateFunction &aggregate_;
- std::vector<ScalarPtr> arguments_;
+ const std::vector<ScalarPtr> arguments_;
const bool is_vector_aggregate_;
const bool is_distinct_;
diff --git a/query_optimizer/expressions/Alias.cpp b/query_optimizer/expressions/Alias.cpp
index 30dade7..f2b2795 100644
--- a/query_optimizer/expressions/Alias.cpp
+++ b/query_optimizer/expressions/Alias.cpp
@@ -38,7 +38,7 @@
namespace optimizer {
namespace expressions {
-Alias::Alias(attribute_id id,
+Alias::Alias(const attribute_id id,
const ExpressionPtr &expression,
const std::string &attribute_name,
const std::string &attribute_alias,
diff --git a/query_optimizer/expressions/Alias.hpp b/query_optimizer/expressions/Alias.hpp
index e07f9fe..e0ee959 100644
--- a/query_optimizer/expressions/Alias.hpp
+++ b/query_optimizer/expressions/Alias.hpp
@@ -97,7 +97,7 @@
* @param relation_name The name of the source relation.
* @return An immutable Alias.
*/
- static AliasPtr Create(ExprId id,
+ static AliasPtr Create(const ExprId id,
const ExpressionPtr &expression,
const std::string &attribute_name,
const std::string &attribute_alias,
@@ -119,7 +119,7 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- Alias(ExprId id,
+ Alias(const ExprId id,
const ExpressionPtr &expression,
const std::string &attribute_name,
const std::string &attribute_alais,
diff --git a/query_optimizer/expressions/AttributeReference.hpp b/query_optimizer/expressions/AttributeReference.hpp
index 5ace894..ca796ba 100644
--- a/query_optimizer/expressions/AttributeReference.hpp
+++ b/query_optimizer/expressions/AttributeReference.hpp
@@ -95,7 +95,7 @@
/**
* @brief Creates an immutable AttributReference.
*
- * @param attribute_id The ExprId of the expression this AttributeReference
+ * @param attr_id The ExprId of the expression this AttributeReference
* references to.
* @param attribute_name The attribute name. This is only for printing purpose.
* @param attribute_alias The attribute alias (or display name). This is only
@@ -107,14 +107,14 @@
* @param scope The scope of the referenced attribute.
* @return An immutable AttributeReference.
*/
- static AttributeReferencePtr Create(ExprId attribute_id,
+ static AttributeReferencePtr Create(const ExprId attr_id,
const std::string &attribute_name,
const std::string &attribute_alias,
const std::string &relation_name,
const Type &type,
const AttributeReferenceScope scope) {
return AttributeReferencePtr(new AttributeReference(
- attribute_id, attribute_name, attribute_alias, relation_name, type, scope));
+ attr_id, attribute_name, attribute_alias, relation_name, type, scope));
}
protected:
@@ -129,13 +129,13 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- AttributeReference(attribute_id attribute_id,
+ AttributeReference(const ExprId attr_id,
const std::string &attribute_name,
const std::string &attribute_alias,
const std::string &relation_name,
const Type &type,
const AttributeReferenceScope scope)
- : NamedExpression(attribute_id,
+ : NamedExpression(attr_id,
attribute_name,
attribute_alias,
relation_name),
diff --git a/query_optimizer/expressions/BinaryExpression.hpp b/query_optimizer/expressions/BinaryExpression.hpp
index 6a37679..df7454c 100644
--- a/query_optimizer/expressions/BinaryExpression.hpp
+++ b/query_optimizer/expressions/BinaryExpression.hpp
@@ -116,8 +116,8 @@
const BinaryOperation &operation_;
- ScalarPtr left_;
- ScalarPtr right_;
+ const ScalarPtr left_;
+ const ScalarPtr right_;
DISALLOW_COPY_AND_ASSIGN(BinaryExpression);
};
diff --git a/query_optimizer/expressions/Cast.hpp b/query_optimizer/expressions/Cast.hpp
index 11be775..fa40242 100644
--- a/query_optimizer/expressions/Cast.hpp
+++ b/query_optimizer/expressions/Cast.hpp
@@ -110,7 +110,7 @@
DCHECK(target_type.isCoercibleFrom(operand->getValueType()));
}
- ScalarPtr operand_;
+ const ScalarPtr operand_;
const Type &target_type_;
DISALLOW_COPY_AND_ASSIGN(Cast);
diff --git a/query_optimizer/expressions/ComparisonExpression.hpp b/query_optimizer/expressions/ComparisonExpression.hpp
index 011e04e..f119f71 100644
--- a/query_optimizer/expressions/ComparisonExpression.hpp
+++ b/query_optimizer/expressions/ComparisonExpression.hpp
@@ -121,8 +121,8 @@
const ScalarPtr &right);
const Comparison &comparison_;
- ScalarPtr left_;
- ScalarPtr right_;
+ const ScalarPtr left_;
+ const ScalarPtr right_;
DISALLOW_COPY_AND_ASSIGN(ComparisonExpression);
};
diff --git a/query_optimizer/expressions/Exists.hpp b/query_optimizer/expressions/Exists.hpp
index 0b75de5..e90348e 100644
--- a/query_optimizer/expressions/Exists.hpp
+++ b/query_optimizer/expressions/Exists.hpp
@@ -113,7 +113,7 @@
addChild(exists_subquery_);
}
- SubqueryExpressionPtr exists_subquery_;
+ const SubqueryExpressionPtr exists_subquery_;
DISALLOW_COPY_AND_ASSIGN(Exists);
};
diff --git a/query_optimizer/expressions/ExpressionUtil.cpp b/query_optimizer/expressions/ExpressionUtil.cpp
index c9541ef..a9f1a0d 100644
--- a/query_optimizer/expressions/ExpressionUtil.cpp
+++ b/query_optimizer/expressions/ExpressionUtil.cpp
@@ -40,8 +40,11 @@
std::vector<AttributeReferencePtr> GetNullableAttributeVector(
const std::vector<AttributeReferencePtr> &attributes) {
std::vector<AttributeReferencePtr> nullable_attributes;
+ nullable_attributes.reserve(attributes.size());
for (const auto &attr : attributes) {
- if (!attr->getValueType().isNullable()) {
+ if (attr->getValueType().isNullable()) {
+ nullable_attributes.emplace_back(attr);
+ } else {
nullable_attributes.emplace_back(
AttributeReference::Create(attr->id(),
attr->attribute_name(),
@@ -49,8 +52,6 @@
attr->relation_name(),
attr->getValueType().getNullableVersion(),
attr->scope()));
- } else {
- nullable_attributes.emplace_back(attr);
}
}
return nullable_attributes;
@@ -60,6 +61,7 @@
const std::vector<AttributeReferencePtr> &attributes,
const AttributeReferenceScope scope) {
std::vector<AttributeReferencePtr> filtered_attributes;
+ filtered_attributes.reserve(attributes.size());
for (const auto &attr_it : attributes) {
if (attr_it->scope() == scope) {
filtered_attributes.emplace_back(attr_it);
diff --git a/query_optimizer/expressions/ExpressionUtil.hpp b/query_optimizer/expressions/ExpressionUtil.hpp
index 29d90f0..576d3a2 100644
--- a/query_optimizer/expressions/ExpressionUtil.hpp
+++ b/query_optimizer/expressions/ExpressionUtil.hpp
@@ -207,6 +207,7 @@
std::vector<AttributeReferencePtr> ToRefVector(
const std::vector<std::shared_ptr<const NamedExpressionType>> &expressions) {
std::vector<AttributeReferencePtr> cast_expressions;
+ cast_expressions.reserve(expressions.size());
for (const std::shared_ptr<const NamedExpressionType> &expression :
expressions) {
cast_expressions.push_back(ToRef(expression));
@@ -225,6 +226,7 @@
std::vector<NamedExpressionPtr> ToNamedExpressions(
const std::vector<std::shared_ptr<const ExpressionType>> &expressions) {
std::vector<NamedExpressionPtr> cast_expressions;
+ cast_expressions.reserve(expressions.size());
for (const std::shared_ptr<const ExpressionType> &expression : expressions) {
NamedExpressionPtr cast_expression;
CHECK(SomeNamedExpression::MatchesWithConditionalCast(expression, &cast_expression))
diff --git a/query_optimizer/expressions/InTableQuery.hpp b/query_optimizer/expressions/InTableQuery.hpp
index 8e6d0e7..245ff0d 100644
--- a/query_optimizer/expressions/InTableQuery.hpp
+++ b/query_optimizer/expressions/InTableQuery.hpp
@@ -130,8 +130,8 @@
addChild(table_query_);
}
- ScalarPtr test_expression_;
- SubqueryExpressionPtr table_query_;
+ const ScalarPtr test_expression_;
+ const SubqueryExpressionPtr table_query_;
DISALLOW_COPY_AND_ASSIGN(InTableQuery);
};
diff --git a/query_optimizer/expressions/InValueList.hpp b/query_optimizer/expressions/InValueList.hpp
index 0ef3bba..e0f1f57 100644
--- a/query_optimizer/expressions/InValueList.hpp
+++ b/query_optimizer/expressions/InValueList.hpp
@@ -144,8 +144,8 @@
}
}
- ScalarPtr test_expression_;
- std::vector<ScalarPtr> match_expressions_;
+ const ScalarPtr test_expression_;
+ const std::vector<ScalarPtr> match_expressions_;
DISALLOW_COPY_AND_ASSIGN(InValueList);
};
diff --git a/query_optimizer/expressions/LogicalAnd.cpp b/query_optimizer/expressions/LogicalAnd.cpp
index 1497874..a3908bd 100644
--- a/query_optimizer/expressions/LogicalAnd.cpp
+++ b/query_optimizer/expressions/LogicalAnd.cpp
@@ -42,6 +42,7 @@
LogicalAnd::LogicalAnd(const std::vector<PredicatePtr> &operands) {
// Flatten the predicate tree.
+ operands_.reserve(operands.size());
for (const PredicatePtr &operand : operands) {
LogicalAndPtr logical_and;
PredicateLiteralPtr literal;
diff --git a/query_optimizer/expressions/LogicalAnd.hpp b/query_optimizer/expressions/LogicalAnd.hpp
index 8152728..8785fc8 100644
--- a/query_optimizer/expressions/LogicalAnd.hpp
+++ b/query_optimizer/expressions/LogicalAnd.hpp
@@ -116,6 +116,7 @@
explicit LogicalAnd(const std::vector<PredicatePtr> &operands);
std::vector<PredicatePtr> operands_;
+
DISALLOW_COPY_AND_ASSIGN(LogicalAnd);
};
diff --git a/query_optimizer/expressions/LogicalNot.hpp b/query_optimizer/expressions/LogicalNot.hpp
index 90a98cd..7c4e660 100644
--- a/query_optimizer/expressions/LogicalNot.hpp
+++ b/query_optimizer/expressions/LogicalNot.hpp
@@ -100,7 +100,7 @@
addChild(operand_);
}
- PredicatePtr operand_;
+ const PredicatePtr operand_;
DISALLOW_COPY_AND_ASSIGN(LogicalNot);
};
diff --git a/query_optimizer/expressions/LogicalOr.cpp b/query_optimizer/expressions/LogicalOr.cpp
index 3ae3e5d..c89fd5a 100644
--- a/query_optimizer/expressions/LogicalOr.cpp
+++ b/query_optimizer/expressions/LogicalOr.cpp
@@ -40,6 +40,7 @@
LogicalOr::LogicalOr(const std::vector<PredicatePtr> &operands) {
// Flatten the predicate tree.
+ operands_.reserve(operands.size());
for (const PredicatePtr &operand : operands) {
LogicalOrPtr logical_or;
PredicateLiteralPtr literal;
diff --git a/query_optimizer/expressions/LogicalOr.hpp b/query_optimizer/expressions/LogicalOr.hpp
index f96b6cd..2e40c56 100644
--- a/query_optimizer/expressions/LogicalOr.hpp
+++ b/query_optimizer/expressions/LogicalOr.hpp
@@ -116,6 +116,7 @@
explicit LogicalOr(const std::vector<PredicatePtr> &operands);
std::vector<PredicatePtr> operands_;
+
DISALLOW_COPY_AND_ASSIGN(LogicalOr);
};
diff --git a/query_optimizer/expressions/NamedExpression.hpp b/query_optimizer/expressions/NamedExpression.hpp
index 6725567..58fc713 100644
--- a/query_optimizer/expressions/NamedExpression.hpp
+++ b/query_optimizer/expressions/NamedExpression.hpp
@@ -101,10 +101,10 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- ExprId id_;
- std::string attribute_name_;
- std::string attribute_alias_;
- std::string relation_name_;
+ const ExprId id_;
+ const std::string attribute_name_;
+ const std::string attribute_alias_;
+ const std::string relation_name_;
DISALLOW_COPY_AND_ASSIGN(NamedExpression);
};
diff --git a/query_optimizer/expressions/PredicateLiteral.hpp b/query_optimizer/expressions/PredicateLiteral.hpp
index 234b6e1..f354a83 100644
--- a/query_optimizer/expressions/PredicateLiteral.hpp
+++ b/query_optimizer/expressions/PredicateLiteral.hpp
@@ -94,7 +94,7 @@
private:
explicit PredicateLiteral(bool is_true) : is_true_(is_true) {}
- bool is_true_;
+ const bool is_true_;
DISALLOW_COPY_AND_ASSIGN(PredicateLiteral);
};
diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/ScalarLiteral.hpp
index bff52bb..7fab1d0 100644
--- a/query_optimizer/expressions/ScalarLiteral.hpp
+++ b/query_optimizer/expressions/ScalarLiteral.hpp
@@ -113,6 +113,7 @@
const TypedValue value_;
const Type &value_type_;
+
DISALLOW_COPY_AND_ASSIGN(ScalarLiteral);
};
diff --git a/query_optimizer/expressions/SearchedCase.hpp b/query_optimizer/expressions/SearchedCase.hpp
index 79c37a5..3466396 100644
--- a/query_optimizer/expressions/SearchedCase.hpp
+++ b/query_optimizer/expressions/SearchedCase.hpp
@@ -152,11 +152,11 @@
}
}
- std::vector<PredicatePtr> condition_predicates_;
- std::vector<ScalarPtr> conditional_result_expressions_;
+ const std::vector<PredicatePtr> condition_predicates_;
+ const std::vector<ScalarPtr> conditional_result_expressions_;
// May be NULL.
- ScalarPtr else_result_expression_;
+ const ScalarPtr else_result_expression_;
const Type &value_type_;
diff --git a/query_optimizer/expressions/SimpleCase.hpp b/query_optimizer/expressions/SimpleCase.hpp
index 0820fa3..b42c034 100644
--- a/query_optimizer/expressions/SimpleCase.hpp
+++ b/query_optimizer/expressions/SimpleCase.hpp
@@ -171,12 +171,12 @@
}
}
- ScalarPtr case_operand_;
- std::vector<ScalarPtr> condition_operands_;
- std::vector<ScalarPtr> conditional_result_expressions_;
+ const ScalarPtr case_operand_;
+ const std::vector<ScalarPtr> condition_operands_;
+ const std::vector<ScalarPtr> conditional_result_expressions_;
// May be NULL.
- ScalarPtr else_result_expression_;
+ const ScalarPtr else_result_expression_;
const Type &value_type_;
diff --git a/query_optimizer/expressions/SubqueryExpression.hpp b/query_optimizer/expressions/SubqueryExpression.hpp
index a128e7f..184bc8c 100644
--- a/query_optimizer/expressions/SubqueryExpression.hpp
+++ b/query_optimizer/expressions/SubqueryExpression.hpp
@@ -116,7 +116,7 @@
DCHECK(!subquery->getOutputAttributes().empty());
}
- logical::LogicalPtr subquery_;
+ const logical::LogicalPtr subquery_;
// Set to the first output attribute if the subquery is a multi-column table query.
const AttributeReferencePtr output_attribute_;
diff --git a/query_optimizer/expressions/UnaryExpression.hpp b/query_optimizer/expressions/UnaryExpression.hpp
index 14201ff..9b99377 100644
--- a/query_optimizer/expressions/UnaryExpression.hpp
+++ b/query_optimizer/expressions/UnaryExpression.hpp
@@ -121,7 +121,7 @@
}
const UnaryOperation &operation_;
- ScalarPtr operand_;
+ const ScalarPtr operand_;
DISALLOW_COPY_AND_ASSIGN(UnaryExpression);
};
diff --git a/query_optimizer/expressions/WindowAggregateFunction.hpp b/query_optimizer/expressions/WindowAggregateFunction.hpp
index 04b4b51..e4a8154 100644
--- a/query_optimizer/expressions/WindowAggregateFunction.hpp
+++ b/query_optimizer/expressions/WindowAggregateFunction.hpp
@@ -229,7 +229,7 @@
// AggregationFunction, a new class for WindowAggregationFunction should be
// created as quickstep::WindowAggregateFunction.
const ::quickstep::WindowAggregateFunction &window_aggregate_;
- std::vector<ScalarPtr> arguments_;
+ const std::vector<ScalarPtr> arguments_;
const WindowInfo window_info_;
const std::string window_name_;
const bool is_distinct_;
diff --git a/query_optimizer/logical/Aggregate.hpp b/query_optimizer/logical/Aggregate.hpp
index d8c02ba..0100b2c 100644
--- a/query_optimizer/logical/Aggregate.hpp
+++ b/query_optimizer/logical/Aggregate.hpp
@@ -92,7 +92,7 @@
* @return An immutable Aggregate node.
*/
static AggregatePtr Create(
- LogicalPtr input,
+ const LogicalPtr &input,
const std::vector<expressions::NamedExpressionPtr> &grouping_expressions,
const std::vector<expressions::AliasPtr> &aggregate_expressions) {
return AggregatePtr(
@@ -109,7 +109,7 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- Aggregate(LogicalPtr input,
+ Aggregate(const LogicalPtr &input,
const std::vector<expressions::NamedExpressionPtr> &grouping_expressions,
const std::vector<expressions::AliasPtr> &aggregate_expressions)
: input_(input),
@@ -120,9 +120,9 @@
addInputExpressions(aggregate_expressions_);
}
- LogicalPtr input_;
- std::vector<expressions::NamedExpressionPtr> grouping_expressions_;
- std::vector<expressions::AliasPtr> aggregate_expressions_;
+ const LogicalPtr input_;
+ const std::vector<expressions::NamedExpressionPtr> grouping_expressions_;
+ const std::vector<expressions::AliasPtr> aggregate_expressions_;
DISALLOW_COPY_AND_ASSIGN(Aggregate);
};
diff --git a/query_optimizer/logical/BinaryJoin.hpp b/query_optimizer/logical/BinaryJoin.hpp
index ca68ced..2945899 100644
--- a/query_optimizer/logical/BinaryJoin.hpp
+++ b/query_optimizer/logical/BinaryJoin.hpp
@@ -89,8 +89,8 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- LogicalPtr left_;
- LogicalPtr right_;
+ const LogicalPtr left_;
+ const LogicalPtr right_;
DISALLOW_COPY_AND_ASSIGN(BinaryJoin);
};
diff --git a/query_optimizer/logical/DeleteTuples.hpp b/query_optimizer/logical/DeleteTuples.hpp
index 8ecd82f..219913b 100644
--- a/query_optimizer/logical/DeleteTuples.hpp
+++ b/query_optimizer/logical/DeleteTuples.hpp
@@ -111,8 +111,8 @@
addChild(input_);
}
- LogicalPtr input_;
- expressions::PredicatePtr predicate_;
+ const LogicalPtr input_;
+ const expressions::PredicatePtr predicate_;
DISALLOW_COPY_AND_ASSIGN(DeleteTuples);
};
diff --git a/query_optimizer/logical/HashJoin.hpp b/query_optimizer/logical/HashJoin.hpp
index b0e63e7..3676637 100644
--- a/query_optimizer/logical/HashJoin.hpp
+++ b/query_optimizer/logical/HashJoin.hpp
@@ -228,9 +228,9 @@
}
}
- std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
- std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
- expressions::PredicatePtr residual_predicate_;
+ const std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
+ const std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
+ const expressions::PredicatePtr residual_predicate_;
const JoinType join_type_;
DISALLOW_COPY_AND_ASSIGN(HashJoin);
diff --git a/query_optimizer/logical/InsertSelection.hpp b/query_optimizer/logical/InsertSelection.hpp
index 9cdbb1c..0c0a6d6 100644
--- a/query_optimizer/logical/InsertSelection.hpp
+++ b/query_optimizer/logical/InsertSelection.hpp
@@ -107,8 +107,8 @@
addChild(selection);
}
- LogicalPtr destination_;
- LogicalPtr selection_;
+ const LogicalPtr destination_;
+ const LogicalPtr selection_;
DISALLOW_COPY_AND_ASSIGN(InsertSelection);
};
diff --git a/query_optimizer/logical/InsertTuple.hpp b/query_optimizer/logical/InsertTuple.hpp
index dd35510..bd4b34d 100644
--- a/query_optimizer/logical/InsertTuple.hpp
+++ b/query_optimizer/logical/InsertTuple.hpp
@@ -108,8 +108,8 @@
addChild(input_);
}
- LogicalPtr input_;
- std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
+ const LogicalPtr input_;
+ const std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
DISALLOW_COPY_AND_ASSIGN(InsertTuple);
};
diff --git a/query_optimizer/logical/MultiwayCartesianJoin.hpp b/query_optimizer/logical/MultiwayCartesianJoin.hpp
index 6f9121d..99570da 100644
--- a/query_optimizer/logical/MultiwayCartesianJoin.hpp
+++ b/query_optimizer/logical/MultiwayCartesianJoin.hpp
@@ -99,7 +99,8 @@
addChild(operand);
}
}
- std::vector<LogicalPtr> operands_;
+
+ const std::vector<LogicalPtr> operands_;
DISALLOW_COPY_AND_ASSIGN(MultiwayCartesianJoin);
};
diff --git a/query_optimizer/logical/NestedLoopsJoin.hpp b/query_optimizer/logical/NestedLoopsJoin.hpp
index 5950e1d..1824a1f 100644
--- a/query_optimizer/logical/NestedLoopsJoin.hpp
+++ b/query_optimizer/logical/NestedLoopsJoin.hpp
@@ -140,7 +140,7 @@
addInputExpression(join_predicate);
}
- expressions::PredicatePtr join_predicate_;
+ const expressions::PredicatePtr join_predicate_;
DISALLOW_COPY_AND_ASSIGN(NestedLoopsJoin);
};
diff --git a/query_optimizer/logical/Project.hpp b/query_optimizer/logical/Project.hpp
index 83b352c..0dd6532 100644
--- a/query_optimizer/logical/Project.hpp
+++ b/query_optimizer/logical/Project.hpp
@@ -107,8 +107,8 @@
addInputExpressions(project_expressions_);
}
- LogicalPtr input_;
- std::vector<expressions::NamedExpressionPtr> project_expressions_;
+ const LogicalPtr input_;
+ const std::vector<expressions::NamedExpressionPtr> project_expressions_;
DISALLOW_COPY_AND_ASSIGN(Project);
};
diff --git a/query_optimizer/logical/Sample.hpp b/query_optimizer/logical/Sample.hpp
index e2403c5..0e8c696 100644
--- a/query_optimizer/logical/Sample.hpp
+++ b/query_optimizer/logical/Sample.hpp
@@ -119,7 +119,7 @@
addChild(input);
}
- LogicalPtr input_;
+ const LogicalPtr input_;
const bool is_block_sample_;
const int percentage_;
diff --git a/query_optimizer/logical/SharedSubplanReference.hpp b/query_optimizer/logical/SharedSubplanReference.hpp
index 79ef4ad..825953d 100644
--- a/query_optimizer/logical/SharedSubplanReference.hpp
+++ b/query_optimizer/logical/SharedSubplanReference.hpp
@@ -105,7 +105,7 @@
* @return An immutable SharedSubplanReference.
*/
static SharedSubplanReferencePtr Create(
- int subplan_id,
+ const int subplan_id,
const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
const std::vector<expressions::AttributeReferencePtr> &output_attributes) {
return SharedSubplanReferencePtr(
@@ -113,7 +113,7 @@
}
private:
- SharedSubplanReference(int subplan_id,
+ SharedSubplanReference(const int subplan_id,
const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
const std::vector<expressions::AttributeReferencePtr> &output_attributes)
: subplan_id_(subplan_id),
@@ -122,9 +122,9 @@
DCHECK_EQ(output_attributes_.size(), referenced_attributes_.size());
}
- int subplan_id_;
- std::vector<expressions::AttributeReferencePtr> referenced_attributes_;
- std::vector<expressions::AttributeReferencePtr> output_attributes_;
+ const int subplan_id_;
+ const std::vector<expressions::AttributeReferencePtr> referenced_attributes_;
+ const std::vector<expressions::AttributeReferencePtr> output_attributes_;
DISALLOW_COPY_AND_ASSIGN(SharedSubplanReference);
};
diff --git a/query_optimizer/logical/Sort.hpp b/query_optimizer/logical/Sort.hpp
index 129c6d4..5be3238 100644
--- a/query_optimizer/logical/Sort.hpp
+++ b/query_optimizer/logical/Sort.hpp
@@ -166,12 +166,12 @@
addChild(input_);
}
- LogicalPtr input_;
- std::vector<expressions::AttributeReferencePtr> sort_attributes_;
+ const LogicalPtr input_;
+ const std::vector<expressions::AttributeReferencePtr> sort_attributes_;
// Has 1:1 matching with <sort_expressions_>.
- std::vector<bool> sort_ascending_;
- std::vector<bool> nulls_first_flags_;
- int limit_;
+ const std::vector<bool> sort_ascending_;
+ const std::vector<bool> nulls_first_flags_;
+ const int limit_;
DISALLOW_COPY_AND_ASSIGN(Sort);
};
diff --git a/query_optimizer/logical/TableGenerator.hpp b/query_optimizer/logical/TableGenerator.hpp
index 15ca985..2f74ffc 100644
--- a/query_optimizer/logical/TableGenerator.hpp
+++ b/query_optimizer/logical/TableGenerator.hpp
@@ -99,6 +99,26 @@
return {};
}
+ /**
+ * @brief Creates a logical TableGenerator node.
+ *
+ * @param generator_function_handle The shared_ptr reference to a generator
+ function handle.
+ * @param table_alias The alias name of this table.
+ * @param optimizer_context The OptimizerContext for the query
+ * @return An immutable TableGenerator.
+ */
+ static TableGeneratorPtr Create(
+ const GeneratorFunctionHandlePtr &generator_function_handle,
+ const std::string &table_alias,
+ OptimizerContext *optimizer_context) {
+ return TableGeneratorPtr(
+ new TableGenerator(generator_function_handle,
+ table_alias,
+ optimizer_context));
+ }
+
+ protected:
void getFieldStringItems(
std::vector<std::string> *inline_field_names,
std::vector<std::string> *inline_field_values,
@@ -119,34 +139,16 @@
container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(attribute_list_));
}
- /**
- * @brief Creates a logical TableGenerator node.
- *
- * @param generator_function_handle The shared_ptr reference to a generator
- function handle.
- * @param table_alias The alias name of this table.
- * @param optimizer_context The OptimizerContext for the query
- * @return An immutable TableGenerator.
- */
- static TableGeneratorPtr Create(
- const GeneratorFunctionHandlePtr &generator_function_handle,
- const std::string &table_alias,
- OptimizerContext *optimizer_context) {
- return TableGeneratorPtr(
- new TableGenerator(generator_function_handle,
- table_alias,
- optimizer_context));
- }
-
private:
TableGenerator(const GeneratorFunctionHandlePtr &generator_function_handle,
const std::string &table_alias,
OptimizerContext *optimizer_context)
: generator_function_handle_(generator_function_handle),
table_alias_(table_alias) {
- int num_attrs = generator_function_handle->getNumberOfOutputColumns();
+ const int num_attrs = generator_function_handle->getNumberOfOutputColumns();
const std::string &table_name = generator_function_handle->getName();
+ attribute_list_.reserve(num_attrs);
for (int i = 0; i < num_attrs; ++i) {
attribute_list_.emplace_back(
E::AttributeReference::Create(
@@ -167,8 +169,8 @@
attribute_list_(attribute_list) {
}
- GeneratorFunctionHandlePtr generator_function_handle_;
- std::string table_alias_;
+ const GeneratorFunctionHandlePtr generator_function_handle_;
+ const std::string table_alias_;
std::vector<E::AttributeReferencePtr> attribute_list_;
DISALLOW_COPY_AND_ASSIGN(TableGenerator);
diff --git a/query_optimizer/logical/TableReference.cpp b/query_optimizer/logical/TableReference.cpp
index 6d94665..0ee2d07 100644
--- a/query_optimizer/logical/TableReference.cpp
+++ b/query_optimizer/logical/TableReference.cpp
@@ -41,6 +41,7 @@
OptimizerContext *optimizer_context)
: catalog_relation_(catalog_relation),
relation_alias_(relation_alias) {
+ attribute_list_.reserve(catalog_relation_->size());
for (CatalogRelation::const_iterator attribute_it = catalog_relation_->begin();
attribute_it < catalog_relation_->end();
++attribute_it) {
diff --git a/query_optimizer/logical/TableReference.hpp b/query_optimizer/logical/TableReference.hpp
index 6788c82..03033a7 100644
--- a/query_optimizer/logical/TableReference.hpp
+++ b/query_optimizer/logical/TableReference.hpp
@@ -128,7 +128,7 @@
attribute_list_(attribute_list) {}
const CatalogRelation *catalog_relation_;
- std::string relation_alias_;
+ const std::string relation_alias_;
std::vector<expressions::AttributeReferencePtr> attribute_list_;
DISALLOW_COPY_AND_ASSIGN(TableReference);
diff --git a/query_optimizer/logical/TopLevelPlan.hpp b/query_optimizer/logical/TopLevelPlan.hpp
index 0b8f1a4..68b2a42 100644
--- a/query_optimizer/logical/TopLevelPlan.hpp
+++ b/query_optimizer/logical/TopLevelPlan.hpp
@@ -137,11 +137,11 @@
}
}
- LogicalPtr plan_;
+ const LogicalPtr plan_;
// Stored in the topological ordering based on dependencies.
- std::vector<LogicalPtr> shared_subplans_;
+ const std::vector<LogicalPtr> shared_subplans_;
- std::unordered_map<expressions::ExprId, int> uncorrelated_subquery_map_;
+ const std::unordered_map<expressions::ExprId, int> uncorrelated_subquery_map_;
DISALLOW_COPY_AND_ASSIGN(TopLevelPlan);
};
diff --git a/query_optimizer/logical/UpdateTable.hpp b/query_optimizer/logical/UpdateTable.hpp
index ec0d50f..bf84842 100644
--- a/query_optimizer/logical/UpdateTable.hpp
+++ b/query_optimizer/logical/UpdateTable.hpp
@@ -125,13 +125,13 @@
addChild(input);
}
- LogicalPtr input_;
+ const LogicalPtr input_;
// The attributes to be assigned values to.
- std::vector<expressions::AttributeReferencePtr> assignees_;
+ const std::vector<expressions::AttributeReferencePtr> assignees_;
// The expressions for which the values are assigned. Has 1:1 matching with
// <assignees_>.
- std::vector<expressions::ScalarPtr> assignment_expressions_;
- expressions::PredicatePtr predicate_;
+ const std::vector<expressions::ScalarPtr> assignment_expressions_;
+ const expressions::PredicatePtr predicate_;
DISALLOW_COPY_AND_ASSIGN(UpdateTable);
};
diff --git a/query_optimizer/physical/BinaryJoin.hpp b/query_optimizer/physical/BinaryJoin.hpp
index 39d5e31..a870b38 100644
--- a/query_optimizer/physical/BinaryJoin.hpp
+++ b/query_optimizer/physical/BinaryJoin.hpp
@@ -94,8 +94,8 @@
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- PhysicalPtr left_;
- PhysicalPtr right_;
+ const PhysicalPtr left_;
+ const PhysicalPtr right_;
DISALLOW_COPY_AND_ASSIGN(BinaryJoin);
};
diff --git a/query_optimizer/physical/CrossReferenceCoalesceAggregate.hpp b/query_optimizer/physical/CrossReferenceCoalesceAggregate.hpp
index 44f8a33..2ec7741 100644
--- a/query_optimizer/physical/CrossReferenceCoalesceAggregate.hpp
+++ b/query_optimizer/physical/CrossReferenceCoalesceAggregate.hpp
@@ -168,7 +168,7 @@
const PhysicalPtr &right_child,
const std::vector<expressions::AttributeReferencePtr> &left_join_attributes,
const std::vector<expressions::AttributeReferencePtr> &right_join_attributes,
- const expressions::PredicatePtr right_filter_predicate,
+ const expressions::PredicatePtr &right_filter_predicate,
const std::vector<expressions::AliasPtr> &aggregate_expressions,
const std::size_t group_by_key_value_range) {
return CrossReferenceCoalesceAggregatePtr(
@@ -196,7 +196,7 @@
const PhysicalPtr &right_child,
const std::vector<expressions::AttributeReferencePtr> &left_join_attributes,
const std::vector<expressions::AttributeReferencePtr> &right_join_attributes,
- const expressions::PredicatePtr right_filter_predicate,
+ const expressions::PredicatePtr &right_filter_predicate,
const std::vector<expressions::AliasPtr> &aggregate_expressions,
const std::size_t group_by_key_value_range)
: left_child_(left_child),
@@ -212,13 +212,13 @@
// TODO(jianqiao): For the left child, support filter predicate fusing and
// attachment of LIPFilters.
- PhysicalPtr left_child_;
- PhysicalPtr right_child_;
- std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
- std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
- expressions::PredicatePtr right_filter_predicate_;
- std::vector<expressions::AliasPtr> aggregate_expressions_;
- std::size_t group_by_key_value_range_;
+ const PhysicalPtr left_child_;
+ const PhysicalPtr right_child_;
+ const std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
+ const std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
+ const expressions::PredicatePtr right_filter_predicate_;
+ const std::vector<expressions::AliasPtr> aggregate_expressions_;
+ const std::size_t group_by_key_value_range_;
DISALLOW_COPY_AND_ASSIGN(CrossReferenceCoalesceAggregate);
};
diff --git a/query_optimizer/physical/DeleteTuples.hpp b/query_optimizer/physical/DeleteTuples.hpp
index bd1e847..a11f671 100644
--- a/query_optimizer/physical/DeleteTuples.hpp
+++ b/query_optimizer/physical/DeleteTuples.hpp
@@ -123,8 +123,8 @@
addChild(input_);
}
- PhysicalPtr input_;
- expressions::PredicatePtr predicate_;
+ const PhysicalPtr input_;
+ const expressions::PredicatePtr predicate_;
DISALLOW_COPY_AND_ASSIGN(DeleteTuples);
};
diff --git a/query_optimizer/physical/HashJoin.hpp b/query_optimizer/physical/HashJoin.hpp
index 1f0df0c..ee51bbb 100644
--- a/query_optimizer/physical/HashJoin.hpp
+++ b/query_optimizer/physical/HashJoin.hpp
@@ -218,11 +218,11 @@
join_type_(join_type) {
}
- std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
- std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
- expressions::PredicatePtr residual_predicate_;
- expressions::PredicatePtr build_predicate_;
- JoinType join_type_;
+ const std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
+ const std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
+ const expressions::PredicatePtr residual_predicate_;
+ const expressions::PredicatePtr build_predicate_;
+ const JoinType join_type_;
DISALLOW_COPY_AND_ASSIGN(HashJoin);
};
diff --git a/query_optimizer/physical/InsertSelection.hpp b/query_optimizer/physical/InsertSelection.hpp
index 4e22a6e..eb64b87 100644
--- a/query_optimizer/physical/InsertSelection.hpp
+++ b/query_optimizer/physical/InsertSelection.hpp
@@ -116,8 +116,8 @@
addChild(selection_);
}
- PhysicalPtr destination_;
- PhysicalPtr selection_;
+ const PhysicalPtr destination_;
+ const PhysicalPtr selection_;
DISALLOW_COPY_AND_ASSIGN(InsertSelection);
};
diff --git a/query_optimizer/physical/InsertTuple.hpp b/query_optimizer/physical/InsertTuple.hpp
index 10c7c5b..f1417ce 100644
--- a/query_optimizer/physical/InsertTuple.hpp
+++ b/query_optimizer/physical/InsertTuple.hpp
@@ -123,8 +123,8 @@
addChild(input_);
}
- PhysicalPtr input_;
- std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
+ const PhysicalPtr input_;
+ const std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
DISALLOW_COPY_AND_ASSIGN(InsertTuple);
};
diff --git a/query_optimizer/physical/Join.hpp b/query_optimizer/physical/Join.hpp
index 63f67c8..c50a131 100644
--- a/query_optimizer/physical/Join.hpp
+++ b/query_optimizer/physical/Join.hpp
@@ -74,14 +74,14 @@
* @param partition_scheme_header The optional output partition scheme header.
*/
explicit Join(
- const std::vector<expressions::NamedExpressionPtr>& project_expressions,
+ const std::vector<expressions::NamedExpressionPtr> &project_expressions,
const bool has_repartition = false,
PartitionSchemeHeader *partition_scheme_header = nullptr)
: Physical(has_repartition, partition_scheme_header),
project_expressions_(project_expressions) {}
private:
- std::vector<expressions::NamedExpressionPtr> project_expressions_;
+ const std::vector<expressions::NamedExpressionPtr> project_expressions_;
DISALLOW_COPY_AND_ASSIGN(Join);
};
diff --git a/query_optimizer/physical/NestedLoopsJoin.hpp b/query_optimizer/physical/NestedLoopsJoin.hpp
index 87db5c3..92d90a7 100644
--- a/query_optimizer/physical/NestedLoopsJoin.hpp
+++ b/query_optimizer/physical/NestedLoopsJoin.hpp
@@ -140,7 +140,7 @@
DCHECK(join_predicate_ != nullptr);
}
- expressions::PredicatePtr join_predicate_;
+ const expressions::PredicatePtr join_predicate_;
DISALLOW_COPY_AND_ASSIGN(NestedLoopsJoin);
};
diff --git a/query_optimizer/physical/SharedSubplanReference.hpp b/query_optimizer/physical/SharedSubplanReference.hpp
index 849bd3a..a233f5f 100644
--- a/query_optimizer/physical/SharedSubplanReference.hpp
+++ b/query_optimizer/physical/SharedSubplanReference.hpp
@@ -116,7 +116,7 @@
* @return An immutable SharedSubplanReference.
*/
static SharedSubplanReferencePtr Create(
- int subplan_id,
+ const int subplan_id,
const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
const std::vector<expressions::AttributeReferencePtr> &output_attributes) {
return SharedSubplanReferencePtr(
@@ -124,7 +124,7 @@
}
private:
- SharedSubplanReference(int subplan_id,
+ SharedSubplanReference(const int subplan_id,
const std::vector<expressions::AttributeReferencePtr> &referenced_attributes,
const std::vector<expressions::AttributeReferencePtr> &output_attributes)
: subplan_id_(subplan_id),
@@ -133,9 +133,9 @@
DCHECK_EQ(output_attributes_.size(), referenced_attributes_.size());
}
- int subplan_id_;
- std::vector<expressions::AttributeReferencePtr> referenced_attributes_;
- std::vector<expressions::AttributeReferencePtr> output_attributes_;
+ const int subplan_id_;
+ const std::vector<expressions::AttributeReferencePtr> referenced_attributes_;
+ const std::vector<expressions::AttributeReferencePtr> output_attributes_;
DISALLOW_COPY_AND_ASSIGN(SharedSubplanReference);
};
diff --git a/query_optimizer/physical/Sort.hpp b/query_optimizer/physical/Sort.hpp
index 4a49aa3..acf81a8 100644
--- a/query_optimizer/physical/Sort.hpp
+++ b/query_optimizer/physical/Sort.hpp
@@ -169,17 +169,17 @@
addChild(input);
}
- PhysicalPtr input_;
- std::vector<expressions::AttributeReferencePtr> sort_attributes_;
+ const PhysicalPtr input_;
+ const 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_;
+ const std::vector<expressions::AttributeReferencePtr> non_sort_attributes_;
+ const std::vector<bool> sort_ascending_;
+ const std::vector<bool> nulls_first_flags_;
+ const int limit_;
DISALLOW_COPY_AND_ASSIGN(Sort);
};
diff --git a/query_optimizer/physical/TableGenerator.hpp b/query_optimizer/physical/TableGenerator.hpp
index 0798165..ff0b6e7 100644
--- a/query_optimizer/physical/TableGenerator.hpp
+++ b/query_optimizer/physical/TableGenerator.hpp
@@ -162,9 +162,9 @@
attribute_list_(attribute_list) {
}
- GeneratorFunctionHandlePtr generator_function_handle_;
- std::string table_alias_;
- std::vector<E::AttributeReferencePtr> attribute_list_;
+ const GeneratorFunctionHandlePtr generator_function_handle_;
+ const std::string table_alias_;
+ const std::vector<E::AttributeReferencePtr> attribute_list_;
DISALLOW_COPY_AND_ASSIGN(TableGenerator);
};
diff --git a/query_optimizer/physical/TopLevelPlan.hpp b/query_optimizer/physical/TopLevelPlan.hpp
index 9e567e1..059144f 100644
--- a/query_optimizer/physical/TopLevelPlan.hpp
+++ b/query_optimizer/physical/TopLevelPlan.hpp
@@ -192,11 +192,11 @@
}
}
- PhysicalPtr plan_;
+ const PhysicalPtr plan_;
// Stored in the topological ordering based on dependencies.
- std::vector<PhysicalPtr> shared_subplans_;
- std::unordered_map<expressions::ExprId, int> uncorrelated_subquery_map_;
- LIPFilterConfigurationPtr lip_filter_configuration_;
+ const std::vector<PhysicalPtr> shared_subplans_;
+ const std::unordered_map<expressions::ExprId, int> uncorrelated_subquery_map_;
+ const LIPFilterConfigurationPtr lip_filter_configuration_;
DISALLOW_COPY_AND_ASSIGN(TopLevelPlan);
};
diff --git a/query_optimizer/physical/UpdateTable.hpp b/query_optimizer/physical/UpdateTable.hpp
index 1c93e17..943d74d 100644
--- a/query_optimizer/physical/UpdateTable.hpp
+++ b/query_optimizer/physical/UpdateTable.hpp
@@ -142,13 +142,13 @@
addChild(input);
}
- PhysicalPtr input_;
+ const PhysicalPtr input_;
// The attributes to be assigned values to.
- std::vector<expressions::AttributeReferencePtr> assignees_;
+ const std::vector<expressions::AttributeReferencePtr> assignees_;
// The expressions for which the values are assigned. Has 1:1 matching with
// <assignees_>.
- std::vector<expressions::ScalarPtr> assignment_expressions_;
- expressions::PredicatePtr predicate_;
+ const std::vector<expressions::ScalarPtr> assignment_expressions_;
+ const expressions::PredicatePtr predicate_;
DISALLOW_COPY_AND_ASSIGN(UpdateTable);
};