[2/3] incubator-quickstep git commit: Updates for grail
Updates for grail Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a0024a2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a0024a2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a0024a2e Branch: refs/heads/trace Commit: a0024a2e9ec76d14013fcdee0e8d714d8776c1a3 Parents: 56e0a4e Author: Jianqiao Zhu Authored: Tue May 8 17:53:57 2018 -0500 Committer: Jianqiao Zhu Committed: Tue May 8 17:53:57 2018 -0500 -- .../aggregation/AggregationHandleMax.hpp| 2 + .../aggregation/AggregationHandleMin.hpp| 2 + query_execution/WorkOrdersContainer.hpp | 8 ++- query_optimizer/ExecutionGenerator.cpp | 6 +-- .../cost_model/StarSchemaSimpleCostModel.cpp| 6 +-- relational_operators/UnionAllOperator.cpp | 6 ++- storage/AggregationOperationState.cpp | 2 +- storage/PackedPayloadHashTable.cpp | 8 +-- storage/StorageManager.cpp | 42 ++-- utility/ShardedLockManager.hpp | 52 +--- 10 files changed, 29 insertions(+), 105 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a0024a2e/expressions/aggregation/AggregationHandleMax.hpp -- diff --git a/expressions/aggregation/AggregationHandleMax.hpp b/expressions/aggregation/AggregationHandleMax.hpp index 8f8c0d8..d6fdd12 100644 --- a/expressions/aggregation/AggregationHandleMax.hpp +++ b/expressions/aggregation/AggregationHandleMax.hpp @@ -191,6 +191,7 @@ class AggregationHandleMax : public AggregationConcreteHandle { if (state->max_.isNull() || fast_comparator_->compareTypedValues(value, state->max_)) { state->max_ = value; + state->max_.ensureNotReference(); } } @@ -200,6 +201,7 @@ class AggregationHandleMax : public AggregationConcreteHandle { if (max_ptr->isNull() || fast_comparator_->compareTypedValues(value, *max_ptr)) { *max_ptr = value; + max_ptr->ensureNotReference(); } } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a0024a2e/expressions/aggregation/AggregationHandleMin.hpp -- diff --git a/expressions/aggregation/AggregationHandleMin.hpp b/expressions/aggregation/AggregationHandleMin.hpp index 0e62be5..441af52 100644 --- a/expressions/aggregation/AggregationHandleMin.hpp +++ b/expressions/aggregation/AggregationHandleMin.hpp @@ -191,6 +191,7 @@ class AggregationHandleMin : public AggregationConcreteHandle { if (state->min_.isNull() || fast_comparator_->compareTypedValues(value, state->min_)) { state->min_ = value; + state->min_.ensureNotReference(); } } @@ -200,6 +201,7 @@ class AggregationHandleMin : public AggregationConcreteHandle { if (min_ptr->isNull() || fast_comparator_->compareTypedValues(value, *min_ptr)) { *min_ptr = value; + min_ptr->ensureNotReference(); } } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a0024a2e/query_execution/WorkOrdersContainer.hpp -- diff --git a/query_execution/WorkOrdersContainer.hpp b/query_execution/WorkOrdersContainer.hpp index 431a270..55ec185 100644 --- a/query_execution/WorkOrdersContainer.hpp +++ b/query_execution/WorkOrdersContainer.hpp @@ -362,7 +362,13 @@ class WorkOrdersContainer { return nullptr; } - std::cerr << "# work orders: " << workorders_.size() << "\r"; + /* + const std::size_t num_remaining_workorders = workorders_.size(); + if (num_remaining_workorders % 1000 == 0) { +std::cerr << "# work orders: " << num_remaining_workorders + << "\r"; + } + */ WorkOrder *work_order = workorders_.front().release(); workorders_.pop(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a0024a2e/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 8ca367b..75f15ac 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -190,7 +190,7 @@ static const volatile bool num_aggregation_partitions_dummy = gflags::RegisterFlagValidator(&FLAGS_num_aggregation_partitions, &ValidateNumAggregationPartitions); DEFINE_uint64(partition_aggregation_num_groups_threshold, - 10, + 1, "The threshold used for deciding whether the aggregation is done "
[3/3] incubator-quickstep git commit: Updates for aggregation result type
Updates for aggregation result type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/f477c5d3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/f477c5d3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/f477c5d3 Branch: refs/heads/trace Commit: f477c5d319e8dc6e501c9ce1a366d3552ec907e0 Parents: a0024a2 Author: Jianqiao Zhu Authored: Wed May 16 14:42:54 2018 -0500 Committer: Jianqiao Zhu Committed: Wed May 16 14:42:54 2018 -0500 -- expressions/aggregation/AggregateFunction.hpp | 3 ++- .../aggregation/AggregateFunctionAvg.cpp| 19 --- .../aggregation/AggregateFunctionAvg.hpp| 3 ++- .../aggregation/AggregateFunctionCount.cpp | 3 ++- .../aggregation/AggregateFunctionCount.hpp | 3 ++- .../aggregation/AggregateFunctionMax.cpp| 10 ++ .../aggregation/AggregateFunctionMax.hpp| 3 ++- .../aggregation/AggregateFunctionMin.cpp| 10 ++ .../aggregation/AggregateFunctionMin.hpp| 3 ++- .../aggregation/AggregateFunctionSum.cpp| 20 .../aggregation/AggregateFunctionSum.hpp| 3 ++- .../tests/AggregationHandleAvg_unittest.cpp | 4 ++-- .../tests/AggregationHandleCount_unittest.cpp | 4 ++-- .../tests/AggregationHandleMax_unittest.cpp | 4 ++-- .../tests/AggregationHandleMin_unittest.cpp | 4 ++-- .../tests/AggregationHandleSum_unittest.cpp | 4 ++-- .../expressions/AggregateFunction.cpp | 6 -- types/Type.cpp | 4 types/Type.hpp | 2 ++ 19 files changed, 70 insertions(+), 42 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f477c5d3/expressions/aggregation/AggregateFunction.hpp -- diff --git a/expressions/aggregation/AggregateFunction.hpp b/expressions/aggregation/AggregateFunction.hpp index 699..5f290d1 100644 --- a/expressions/aggregation/AggregateFunction.hpp +++ b/expressions/aggregation/AggregateFunction.hpp @@ -112,7 +112,8 @@ class AggregateFunction { * applicable to the specified Type(s). **/ virtual const Type* resultTypeForArgumentTypes( - const std::vector &argument_types) const = 0; + const std::vector &argument_types, + const bool is_vector_aggregate) const = 0; /** * @brief Create an AggregationHandle to compute aggregates. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f477c5d3/expressions/aggregation/AggregateFunctionAvg.cpp -- diff --git a/expressions/aggregation/AggregateFunctionAvg.cpp b/expressions/aggregation/AggregateFunctionAvg.cpp index 040d7d9..e966d4a 100644 --- a/expressions/aggregation/AggregateFunctionAvg.cpp +++ b/expressions/aggregation/AggregateFunctionAvg.cpp @@ -48,22 +48,27 @@ bool AggregateFunctionAvg::canApplyToTypes( } const Type* AggregateFunctionAvg::resultTypeForArgumentTypes( -const std::vector &argument_types) const { +const std::vector &argument_types, +const bool is_vector_aggregate) const { if (!canApplyToTypes(argument_types)) { return nullptr; } - // The type used to sum values is nullable, and we automatically widen int to - // long and float to double to have more headroom when adding up many values. - const Type *sum_type = &(argument_types.front()->getNullableVersion()); - switch (sum_type->getTypeID()) { + // We automatically widen int to long and float to double to have more + // headroom when adding up many values. + const Type *argument_type = argument_types.front(); + const bool nullable = argument_type->isNullable() || !is_vector_aggregate; + + const Type *sum_type; + switch (argument_type->getTypeID()) { case kInt: - sum_type = &TypeFactory::GetType(kLong, true); + sum_type = &TypeFactory::GetType(kLong, nullable); break; case kFloat: - sum_type = &TypeFactory::GetType(kDouble, true); + sum_type = &TypeFactory::GetType(kDouble, nullable); break; default: + sum_type = &TypeFactory::GetType(argument_type->getTypeID(), nullable); break; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f477c5d3/expressions/aggregation/AggregateFunctionAvg.hpp -- diff --git a/expressions/aggregation/AggregateFunctionAvg.hpp b/expressions/aggregation/AggregateFunctionAvg.hpp index 9d08d1c..d040607 100644 --- a/expressions/aggregation/AggregateFunctionAvg.hpp +++ b/expressions/aggregation/AggregateFunctionAvg.hpp @@ -54,7 +54,8 @@ class AggregateFun
[02/11] incubator-quickstep git commit: Updates to save blocks and analyze
Updates to save blocks and analyze Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/b45cdbc6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b45cdbc6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b45cdbc6 Branch: refs/heads/transitive-closure Commit: b45cdbc63be488aad3211b5146dfe6f8fbfdc024 Parents: df20e4c Author: Jianqiao Zhu Authored: Mon Nov 27 16:21:03 2017 -0600 Committer: Jianqiao Zhu Committed: Mon Nov 27 16:21:03 2017 -0600 -- catalog/CatalogRelationStatistics.hpp | 9 ++ cli/CommandExecutor.cpp | 249 - cli/Constants.hpp | 2 + storage/StorageManager.cpp| 12 +- 4 files changed, 222 insertions(+), 50 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b45cdbc6/catalog/CatalogRelationStatistics.hpp -- diff --git a/catalog/CatalogRelationStatistics.hpp b/catalog/CatalogRelationStatistics.hpp index df95231..55fc747 100644 --- a/catalog/CatalogRelationStatistics.hpp +++ b/catalog/CatalogRelationStatistics.hpp @@ -68,6 +68,15 @@ class CatalogRelationStatistics { serialization::CatalogRelationStatistics getProto() const; /** + * @brief Clear all statistics. + */ + void clear() { +num_tuples_ = kNullValue; +column_stats_.clear(); +is_exact_ = true; + } + + /** * @brief Check whether the statistics are exact for the relation. * * return True if the statistics are exact for the relation, false otherwise. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b45cdbc6/cli/CommandExecutor.cpp -- diff --git a/cli/CommandExecutor.cpp b/cli/CommandExecutor.cpp index 6a84672..7976d7d 100644 --- a/cli/CommandExecutor.cpp +++ b/cli/CommandExecutor.cpp @@ -201,9 +201,28 @@ void ExecuteAnalyze(const PtrVector &arguments, CatalogRelationStatistics *mutable_stat = mutable_relation->getStatisticsMutable(); +mutable_stat->clear(); + const std::string rel_name = EscapeQuotes(relation.getName(), '"'); -// Get the number of distinct values for each column. +// Get the number of tuples for the relation. +std::string query_string = "SELECT COUNT(*) FROM \""; +query_string.append(rel_name); +query_string.append("\";"); + +TypedValue num_tuples = +ExecuteQueryForSingleResult(main_thread_client_id, +foreman_client_id, +query_string, +bus, +storage_manager, +query_processor, +parser_wrapper.get()); + +DCHECK_EQ(TypeID::kLong, num_tuples.getTypeID()); +mutable_stat->setNumTuples(num_tuples.getLiteral()); + +// Get the min/max values for each column. for (const CatalogAttribute &attribute : relation) { const std::string attr_name = EscapeQuotes(attribute.getName(), '"'); const Type &attr_type = attribute.getType(); @@ -211,24 +230,15 @@ void ExecuteAnalyze(const PtrVector &arguments, AggregateFunctionMin::Instance().canApplyToTypes({&attr_type}); bool is_max_applicable = AggregateFunctionMax::Instance().canApplyToTypes({&attr_type}); + if (!is_min_applicable || !is_max_applicable) { +continue; + } - // NOTE(jianqiao): Note that the relation name and the attribute names may - // contain non-letter characters, e.g. CREATE TABLE "with space"("1" int). - // So here we need to format the names with double quotes ("). - std::string query_string = "SELECT COUNT(DISTINCT \""; + std::string query_string = "SELECT MIN(\""; query_string.append(attr_name); - query_string.append("\")"); - if (is_min_applicable) { -query_string.append(", MIN(\""); -query_string.append(attr_name); -query_string.append("\")"); - } - if (is_max_applicable) { -query_string.append(", MAX(\""); -query_string.append(attr_name); -query_string.append("\")"); - } - query_string.append(" FROM \""); + query_string.append("\"), MAX(\""); + query_string.append(attr_name); + query_string.append("\") FROM \""); query_string.append(rel_name); query_string.append("\";"); @@ -240,42 +250,181 @@ void ExecuteAnalyze(const PtrVector &arguments, storage_manager, query_processor, parser_wrapper.get()); - - aut
[01/11] incubator-quickstep git commit: Updates to compact key hash table
Repository: incubator-quickstep Updated Branches: refs/heads/transitive-closure [created] 2aefd7bce Updates to compact key hash table Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/df20e4c0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/df20e4c0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/df20e4c0 Branch: refs/heads/transitive-closure Commit: df20e4c09ec3a8490b1d1ddcd590d813a873181e Parents: 3595bc1 Author: Jianqiao Zhu Authored: Sun Nov 26 21:16:46 2017 -0600 Committer: Jianqiao Zhu Committed: Mon Nov 27 16:06:44 2017 -0600 -- query_optimizer/CMakeLists.txt | 1 + query_optimizer/ExecutionGenerator.cpp | 109 ++--- .../cost_model/StarSchemaSimpleCostModel.cpp| 39 +++- .../cost_model/StarSchemaSimpleCostModel.hpp| 4 +- query_optimizer/rules/FuseAggregateJoin.cpp | 6 - .../FinalizeAggregationOperator.cpp | 29 +-- .../FinalizeAggregationOperator.hpp | 3 - .../InitializeAggregationOperator.cpp | 24 +- .../InitializeAggregationOperator.hpp | 7 +- storage/AggregationOperationState.cpp | 134 ++- storage/AggregationOperationState.hpp | 38 +-- storage/AggregationOperationState.proto | 3 - storage/CMakeLists.txt | 24 ++ storage/CollisionFreeVectorTable.cpp| 58 - storage/CollisionFreeVectorTable.hpp| 42 ++-- storage/CompactKeySeparateChainingHashTable.cpp | 195 storage/CompactKeySeparateChainingHashTable.hpp | 234 +++ storage/Flags.hpp | 1 - storage/HashTable.proto | 15 +- storage/HashTableBase.hpp | 1 + storage/HashTableFactory.hpp| 24 +- utility/CMakeLists.txt | 10 + utility/Range.hpp | 188 +++ utility/ScopedArray.hpp | 78 +++ 24 files changed, 977 insertions(+), 290 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/df20e4c0/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 5e0db44..011cecb 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -148,6 +148,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_relationaloperators_UpdateOperator quickstep_relationaloperators_WindowAggregationOperator quickstep_storage_AggregationOperationState_proto + quickstep_storage_Flags quickstep_storage_HashTableFactory quickstep_storage_HashTable_proto quickstep_storage_InsertDestination_proto http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/df20e4c0/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index b0d3c48..3ef74ee 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -132,6 +132,7 @@ #include "relational_operators/UpdateOperator.hpp" #include "relational_operators/WindowAggregationOperator.hpp" #include "storage/AggregationOperationState.pb.h" +#include "storage/Flags.hpp" #include "storage/HashTable.pb.h" #include "storage/HashTableFactory.hpp" #include "storage/InsertDestination.pb.h" @@ -199,70 +200,6 @@ namespace S = ::quickstep::serialization; namespace { -size_t CacheLineAlignedBytes(const size_t actual_bytes) { - return (actual_bytes + kCacheLineBytes - 1) / kCacheLineBytes * kCacheLineBytes; -} - -size_t CalculateNumInitializationPartitionsForCollisionFreeVectorTable(const size_t memory_size) { - // At least 1 partition, at most (#workers * 2) partitions. - return std::max(1uL, std::min(memory_size / kCollisonFreeVectorInitBlobSize, -static_cast(2 * FLAGS_num_workers))); -} - -void CalculateCollisionFreeAggregationInfo( -const size_t num_entries, const vector>> &group_by_aggrs_info, -S::CollisionFreeVectorInfo *collision_free_vector_info) { - size_t memory_size = CacheLineAlignedBytes( - BarrieredReadWriteConcurrentBitVector::BytesNeeded(num_entries)); - - for (std::size_t i = 0; i < group_by_aggrs_info.size(); ++i) { -const auto &group_by_aggr_info = group_by_aggrs_info[i]; - -size_t state_size = 0; -switch (group_by_
[04/11] incubator-quickstep git commit: Updates to fix the union all + reorder column problem.
Updates to fix the union all + reorder column problem. Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a08044e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a08044e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a08044e4 Branch: refs/heads/transitive-closure Commit: a08044e42418a93091d7440a04cc944d4bfede8a Parents: a57638e Author: Jianqiao Zhu Authored: Fri Dec 1 02:15:05 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Dec 1 02:16:10 2017 -0600 -- cli/QuickstepCli.cpp | 20 +++- query_optimizer/resolver/Resolver.cpp| 2 +- query_optimizer/rules/ReorderColumns.cpp | 6 +- storage/StorageManager.cpp | 11 +++ 4 files changed, 32 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a08044e4/cli/QuickstepCli.cpp -- diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp index e8ca56c..15d8ede 100644 --- a/cli/QuickstepCli.cpp +++ b/cli/QuickstepCli.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,8 @@ DEFINE_string(mode, "local", DECLARE_bool(profile_and_report_workorder_perf); DECLARE_bool(visualize_execution_dag); +DEFINE_string(execution_dag_log, "", "The log file for writing execution dag to."); + } // namespace quickstep int main(int argc, char* argv[]) { @@ -299,6 +302,13 @@ int main(int argc, char* argv[]) { std::unique_ptr parser_wrapper(new SqlParserWrapper()); std::chrono::time_point start, end; + std::unique_ptr execution_dag_log_out; + const bool has_execution_dag_log = !quickstep::FLAGS_execution_dag_log.empty(); + if (has_execution_dag_log) { +execution_dag_log_out = std::make_unique( +quickstep::FLAGS_execution_dag_log, std::ios::out | std::ios::app); + } + #ifdef QUICKSTEP_ENABLE_GOOGLE_PROFILER bool started_profiling = false; #endif @@ -353,6 +363,9 @@ int main(int argc, char* argv[]) { } // Here the statement is presumed to be a query. const std::size_t query_id = query_processor->query_id(); +if (has_execution_dag_log) { + *execution_dag_log_out << "#QUERY ID " << query_id << "#" << "\n"; +} const CatalogRelation *query_result_relation = nullptr; std::unique_ptr dag_visualizer; @@ -418,7 +431,12 @@ int main(int argc, char* argv[]) { if (profiling_stats) { dag_visualizer->bindProfilingStats(*profiling_stats); } -std::cerr << "\n" << dag_visualizer->toDOT() << "\n"; +if (has_execution_dag_log) { + CHECK(execution_dag_log_out != nullptr); + *execution_dag_log_out << "\n" << dag_visualizer->toDOT() << "\n"; +} else { + std::cerr << "\n" << dag_visualizer->toDOT() << "\n"; +} } } catch (const std::exception &e) { fprintf(io_handle->err(), "QUERY EXECUTION ERROR: %s\n", e.what()); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a08044e4/query_optimizer/resolver/Resolver.cpp -- diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp index 0b6dc22..dc4bc2e 100644 --- a/query_optimizer/resolver/Resolver.cpp +++ b/query_optimizer/resolver/Resolver.cpp @@ -1586,7 +1586,7 @@ L::LogicalPtr Resolver::resolveSetOperations( possible_attributes.push_back(possible_attribute); } - for (std::size_t opid = 0; opid < operation_attributes.size(); ++opid) { + for (std::size_t opid = 0; opid < attribute_matrix.size(); ++opid) { // Generate a cast operation if needed. std::vector cast_expressions; for (std::size_t aid = 0; aid < operation_attributes.size(); ++aid) { http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a08044e4/query_optimizer/rules/ReorderColumns.cpp -- diff --git a/query_optimizer/rules/ReorderColumns.cpp b/query_optimizer/rules/ReorderColumns.cpp index 4783a8d..d12e8c7 100644 --- a/query_optimizer/rules/ReorderColumns.cpp +++ b/query_optimizer/rules/ReorderColumns.cpp @@ -61,7 +61,11 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input, if (skip_transform) { std::vector new_children; for (const P::PhysicalPtr &child : input->children()) { - new_children.emplace_back(applyInternal(child, lock_ordering && is_not_transformable)); + bool child_lock_ordering = lock_ordering && is_not_transformable; + if (child->getPhysi
[05/11] incubator-quickstep git commit: Updates to cost model
Updates to cost model Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/d725bcaf Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/d725bcaf Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/d725bcaf Branch: refs/heads/transitive-closure Commit: d725bcafec86b7637ce08a24c309b2ea1981a618 Parents: a08044e Author: Jianqiao Zhu Authored: Fri Dec 1 17:20:25 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Dec 1 17:20:25 2017 -0600 -- query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d725bcaf/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp -- diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp index f7417b6..729a563 100644 --- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp +++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp @@ -486,7 +486,7 @@ std::size_t StarSchemaSimpleCostModel::getNumDistinctValues( return stat.getNumDistinctValues(rel_attr_id); } } - return estimateCardinalityForTableReference(table_reference); + return estimateCardinalityForTableReference(table_reference) * 0.5; } bool StarSchemaSimpleCostModel::impliesUniqueAttributes( @@ -520,7 +520,7 @@ bool StarSchemaSimpleCostModel::impliesUniqueAttributes( std::static_pointer_cast(physical_plan); const CatalogRelationStatistics &stat = table_reference->relation()->getStatistics(); - if (stat.hasNumTuples()) { + if (stat.isExact() && stat.hasNumTuples()) { const std::size_t num_tuples = stat.getNumTuples(); for (const auto &attr : attributes) { const attribute_id rel_attr_id =
[11/11] incubator-quickstep git commit: Updates to transitive closure
Updates to transitive closure Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/2aefd7bc Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/2aefd7bc Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/2aefd7bc Branch: refs/heads/transitive-closure Commit: 2aefd7bce5bad9bb6063b4fd71ec37876d58662d Parents: 734ddc1 Author: Jianqiao Zhu Authored: Mon Dec 11 14:45:08 2017 -0600 Committer: Jianqiao Zhu Committed: Mon Dec 11 16:07:23 2017 -0600 -- query_optimizer/ExecutionGenerator.cpp | 19 ++- query_optimizer/PhysicalGenerator.cpp | 2 +- .../BuildTransitiveClosureOperator.cpp | 2 - relational_operators/CMakeLists.txt | 5 + .../InitializeTransitiveClosureOperator.cpp | 6 +- .../TransitiveClosureOperator.cpp | 158 +++ .../TransitiveClosureOperator.hpp | 86 +- storage/TransitiveClosureState.hpp | 8 + types/containers/ColumnVector.hpp | 7 + .../BarrieredReadWriteConcurrentBitVector.hpp | 7 + utility/BitVector.hpp | 28 +++- 11 files changed, 314 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2aefd7bc/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 8f29271..648b937 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -2488,18 +2488,23 @@ void ExecutionGenerator::convertTransitiveClosure( &output_relation, insert_destination_proto); + const QueryPlan::DAGNodeIndex tc_operator_index = + execution_plan_->addRelationalOperator( + new TransitiveClosureOperator(query_handle_->query_id(), +transitive_closure_state_index, +*output_relation, +insert_destination_index)); + insert_destination_proto->set_relational_op_index(tc_operator_index); - (void)insert_destination_index; + execution_plan_->addDirectDependency(tc_operator_index, + build_tc_operator_index, + true /* is_pipeline_breaker */); - // TODO: fix - insert_destination_proto->set_relational_op_index(build_tc_operator_index /* FIX */); physical_to_output_relation_map_.emplace( std::piecewise_construct, std::forward_as_tuple(physical_plan), - std::forward_as_tuple(build_tc_operator_index /* FIX */, output_relation)); - - temporary_relation_info_vec_.emplace_back(build_tc_operator_index /* FIX */, -output_relation); + std::forward_as_tuple(tc_operator_index, output_relation)); + temporary_relation_info_vec_.emplace_back(tc_operator_index, output_relation); } } // namespace optimizer http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2aefd7bc/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index b7b0db0..865cd11 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -194,7 +194,7 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { << physical_plan_->toString(); } - std::cerr << "Optimized physical plan:\n" << physical_plan_->toString(); + DVLOG(4) << "Optimized physical plan:\n" << physical_plan_->toString(); if (FLAGS_visualize_plan) { quickstep::PlanVisualizer plan_visualizer; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2aefd7bc/relational_operators/BuildTransitiveClosureOperator.cpp -- diff --git a/relational_operators/BuildTransitiveClosureOperator.cpp b/relational_operators/BuildTransitiveClosureOperator.cpp index e151756..919a974 100644 --- a/relational_operators/BuildTransitiveClosureOperator.cpp +++ b/relational_operators/BuildTransitiveClosureOperator.cpp @@ -107,7 +107,6 @@ void BuildTransitiveClosureWorkOrder::execute() { } void BuildTransitiveClosureWorkOrder::buildStartRelation(ValueAccessor *accessor) { - std::cout << "BuildStartRelation: " << block_ << "\n"; InvokeOnAnyValueAccessor( accessor, [&](auto *accessor) -> void { @@ -119,7 +118,6 @@ void BuildTransitiveClosureWorkOrder::buildStartRelation(ValueAccessor *accessor } void BuildT
[24/41] incubator-quickstep git commit: Updates for adding generic types
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ebf44cd2/types/TypeRegistrar.hpp -- diff --git a/types/TypeRegistrar.hpp b/types/TypeRegistrar.hpp index ffe2b7e..9e6c50b 100644 --- a/types/TypeRegistrar.hpp +++ b/types/TypeRegistrar.hpp @@ -20,13 +20,14 @@ #ifndef QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ #define QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ +#include #include #include +#include #include "types/DatetimeLit.hpp" #include "types/IntervalLit.hpp" #include "types/NullLit.hpp" -#include "types/Type.hpp" #include "types/TypeID.hpp" #include "types/TypeIDSelectors.hpp" #include "utility/meta/Common.hpp" @@ -39,6 +40,14 @@ namespace quickstep { * @{ */ +class Type; +class TypedValue; + +using UntypedLiteral = void; + +using ArrayLiteral = std::vector; +using MetaTypeLiteral = const Type*; + template struct TypeIDTrait; @@ -48,36 +57,40 @@ struct TypeIDTrait; typedef type_class TypeClass; \ typedef cpp_type cpptype; \ static constexpr TypeID kStaticTypeID = type_id; \ -static constexpr Type::SuperTypeID kStaticSuperTypeID = super_type_id; \ +static constexpr SuperTypeID kStaticSuperTypeID = super_type_id; \ static constexpr MemoryLayout kMemoryLayout = memory_layout; \ -static constexpr bool kIsParameterizedPod = \ -(memory_layout == kParNativePod || memory_layout == kParIndirectPod); \ +static constexpr bool kIsParPod = \ +(memory_layout == kParInlinePod || memory_layout == kParOutOfLinePod); \ }; -REGISTER_TYPE(BoolType, kBool, \ - Type::kNumeric, kCxxNativePod, bool); -REGISTER_TYPE(IntType, kInt, \ - Type::kNumeric, kCxxNativePod, int); -REGISTER_TYPE(LongType, kLong, \ - Type::kNumeric, kCxxNativePod, std::int64_t); -REGISTER_TYPE(FloatType, kFloat, \ - Type::kNumeric, kCxxNativePod, float); -REGISTER_TYPE(DoubleType, kDouble, \ - Type::kNumeric, kCxxNativePod, double); -REGISTER_TYPE(DateType, kDate, \ - Type::kOther, kCxxNativePod, DateLit); -REGISTER_TYPE(DatetimeType, kDatetime, \ - Type::kOther, kCxxNativePod, DatetimeLit); -REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, \ - Type::kOther, kCxxNativePod, DatetimeIntervalLit); -REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, \ - Type::kOther, kCxxNativePod, YearMonthIntervalLit); -REGISTER_TYPE(CharType, kChar, \ - Type::kAsciiString, kParNativePod, void); -REGISTER_TYPE(VarCharType, kVarChar, \ - Type::kAsciiString, kParIndirectPod, void); -REGISTER_TYPE(NullType, kNullType, \ - Type::kOther, kCxxNativePod, NullLit); +REGISTER_TYPE(BoolType, kBool, + SuperTypeID::kNumeric, kCxxInlinePod, bool); +REGISTER_TYPE(IntType, kInt, + SuperTypeID::kNumeric, kCxxInlinePod, int); +REGISTER_TYPE(LongType, kLong, + SuperTypeID::kNumeric, kCxxInlinePod, std::int64_t); +REGISTER_TYPE(FloatType, kFloat, + SuperTypeID::kNumeric, kCxxInlinePod, float); +REGISTER_TYPE(DoubleType, kDouble, + SuperTypeID::kNumeric, kCxxInlinePod, double); +REGISTER_TYPE(DateType, kDate, + SuperTypeID::kOther, kCxxInlinePod, DateLit); +REGISTER_TYPE(DatetimeType, kDatetime, + SuperTypeID::kOther, kCxxInlinePod, DatetimeLit); +REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, + SuperTypeID::kOther, kCxxInlinePod, DatetimeIntervalLit); +REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, + SuperTypeID::kOther, kCxxInlinePod, YearMonthIntervalLit); +REGISTER_TYPE(CharType, kChar, + SuperTypeID::kAsciiString, kParInlinePod, TypedValue); +REGISTER_TYPE(VarCharType, kVarChar, + SuperTypeID::kAsciiString, kParOutOfLinePod, TypedValue); +REGISTER_TYPE(ArrayType, kArray, + SuperTypeID::kOther, kCxxGeneric, ArrayLiteral); +REGISTER_TYPE(MetaType, kMetaType, + SuperTypeID::kOther, kCxxGeneric, MetaTypeLiteral); +REGISTER_TYPE(NullType, kNullType, + SuperTypeID::kOther, kCxxInlinePod, NullLit); #undef REGISTER_TYPE @@ -91,8 +104,8 @@ auto InvokeOnTypeID(const TypeID type_id, const FunctorT &functor); namespace internal { template -inline auto InvokeOnTypeIDInner(const int value, -const FunctorT &functor) { +inline auto InvokeOnTypeIDInternal(const int value, + const FunctorT &functor) { DCHECK_LE(l, r); if (l == r) { constexpr TypeID type_id = static_cast(r); @@ -101,9 +114,9 @@ inline auto InvokeOnTypeIDInner(const int value, } constexpr int m = (l + r) >> 1; if (value <= m) { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, functor); } else { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, funct
[04/41] incubator-quickstep git commit: Updates to meta type
Updates to meta type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/bef66ad4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/bef66ad4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/bef66ad4 Branch: refs/heads/refactor-type Commit: bef66ad47a6edb69f76f29c56d528a28ba7760b8 Parents: 1e69fb1 Author: Jianqiao Zhu Authored: Tue Oct 3 01:52:29 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 13:37:54 2017 -0500 -- types/ArrayType.cpp | 29 +++ types/ArrayType.hpp | 7 +++- types/CMakeLists.txt | 22 ++-- types/MetaType.cpp| 36 --- types/MetaType.hpp| 44 +-- types/MetaTypeLite.cpp| 52 +++ types/MetaTypeLite.hpp| 72 ++ types/ParameterizedPodLit.hpp | 0 types/Type.proto | 4 +++ types/TypeSynthesizer.hpp | 8 ++--- types/TypedValue.cpp | 15 ++-- 11 files changed, 200 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bef66ad4/types/ArrayType.cpp -- diff --git a/types/ArrayType.cpp b/types/ArrayType.cpp index c0f3a87..df2b9de 100644 --- a/types/ArrayType.cpp +++ b/types/ArrayType.cpp @@ -19,14 +19,43 @@ #include "types/ArrayType.hpp" +#include #include +#include "types/Type.pb.h" #include "types/TypeID.hpp" #include "glog/logging.h" namespace quickstep { +TypedValue ArrayType::marshallValue(const UntypedLiteral *value) const { + const ArrayLiteral &array = *static_cast(value); + serialization::ArrayLiteral proto; + for (const auto &element : array) { +// TODO(refactor-type): Improve performance. +TypedValue value = element_type_.marshallValue(element); +proto.add_data(value.getDataPtr(), value.getDataSize()); + } + const std::size_t data_size = proto.ByteSize(); + void *data = std::malloc(data_size); + proto.SerializeToArray(data, data_size); + return TypedValue::CreateWithOwnedData(kArray, data, data_size); +} + +UntypedLiteral* ArrayType::unmarshallValue(const void *data, + const std::size_t data_size) const { + std::unique_ptr array = std::make_unique(); + serialization::ArrayLiteral proto; + proto.ParseFromArray(data, data_size); + for (int i = 0; i < proto.data_size(); ++i) { +const std::string &element_data = proto.data(i); +array->emplace_back( +element_type_.unmarshallValue(element_data.c_str(), element_data.size())); + } + return array.release(); +} + std::string ArrayType::printValueToString(const UntypedLiteral *value) const { DCHECK(value != nullptr); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bef66ad4/types/ArrayType.hpp -- diff --git a/types/ArrayType.hpp b/types/ArrayType.hpp index fe81c3e..a48cfa3 100644 --- a/types/ArrayType.hpp +++ b/types/ArrayType.hpp @@ -44,6 +44,11 @@ class ArrayType : public TypeSynthesizer { return 16; } + TypedValue marshallValue(const UntypedLiteral *value) const override; + + UntypedLiteral* unmarshallValue(const void *data, + const std::size_t length) const override; + std::string printValueToString(const UntypedLiteral *value) const override; bool parseTypedValueFromString(const std::string &value_string, @@ -63,7 +68,7 @@ class ArrayType : public TypeSynthesizer { DCHECK_EQ(1u, parameters.size()); const GenericValue &value = parameters.front(); DCHECK(value.getType().getTypeID() == kMetaType); -return *static_cast(value.getValue()); +return **static_cast(value.getValue()); } const Type &element_type_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bef66ad4/types/CMakeLists.txt -- diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index 07f9d97..69ac906 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -49,13 +49,13 @@ add_library(quickstep_types_IntervalLit ../empty_src.cpp IntervalLit.hpp) add_library(quickstep_types_IntervalParser IntervalParser.cpp IntervalParser.hpp) add_library(quickstep_types_LongType LongType.cpp LongType.hpp) add_library(quickstep_types_MetaType MetaType.cpp MetaType.hpp) +add_library(quickstep_types_MetaTypeLite MetaTypeLite.cpp MetaTypeLite.hpp) add_library(quickstep_types_NullCoercibilityCheckMacro ../empty_src.cpp NullCoercibilityCheckMacro.hpp) add_library(quickstep_types_NullLit ../empty_src.cpp NullLit.hpp) add_library(qu
[39/41] incubator-quickstep git commit: Updates to casts
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/477c385d/types/operations/OperationFactory.cpp -- diff --git a/types/operations/OperationFactory.cpp b/types/operations/OperationFactory.cpp index 74cc3c1..df536ed 100644 --- a/types/operations/OperationFactory.cpp +++ b/types/operations/OperationFactory.cpp @@ -33,7 +33,7 @@ #include "types/operations/OperationSignature.hpp" #include "types/operations/binary_operations/ArithmeticBinaryFunctors.hpp" #include "types/operations/binary_operations/AsciiStringBinaryFunctors.hpp" -#include "types/operations/binary_operations/BinaryOperationWrapper.hpp" +#include "types/operations/binary_operations/BinaryOperationSynthesizer.hpp" #include "types/operations/binary_operations/CMathBinaryFunctors.hpp" #include "types/operations/unary_operations/ArithmeticUnaryFunctors.hpp" #include "types/operations/unary_operations/AsciiStringUnaryFunctors.hpp" @@ -41,9 +41,11 @@ #include "types/operations/unary_operations/CastOperation.hpp" #include "types/operations/unary_operations/DateExtractOperation.hpp" #include "types/operations/unary_operations/SubstringOperation.hpp" -#include "types/operations/unary_operations/UnaryOperationWrapper.hpp" +#include "types/operations/unary_operations/UnaryOperationSynthesizer.hpp" #include "utility/StringUtil.hpp" +#include "glog/logging.h" + namespace quickstep { namespace { @@ -52,13 +54,13 @@ struct FunctorPackDispatcher { template inline static std::list Generate( std::enable_if_t* = 0) { -return { std::make_shared>() }; +return { std::make_shared>() }; } template inline static std::list Generate( std::enable_if_t* = 0) { -return { std::make_shared>() }; +return { std::make_shared>() }; } template @@ -94,6 +96,98 @@ OperationFactory::OperationFactory() { registerFunctorPack(); } +bool OperationFactory::HasOperation(const std::string &operation_name, +const std::size_t arity) { + const auto &primary_index = Instance().primary_index_; + const auto indices_it = + primary_index.find(std::make_pair(operation_name, arity)); + return indices_it != primary_index.end(); +} + +bool OperationFactory::HasOperation(const OperationSignaturePtr &op_signature) { + const auto &operations = Instance().operations_; + return operations.find(op_signature) != operations.end(); +} + +bool OperationFactory::CanApplyUnaryOperation( +const std::string &operation_name, +const Type &type, +const std::vector &static_arguments) { + std::vector argument_type_ids = {type.getTypeID()}; + std::vector static_tv_arguments; + for (const auto &value : static_arguments) { +argument_type_ids.emplace_back(value.getTypeID()); +// TODO(refactor-type): Remove this. +static_tv_arguments.emplace_back(value.toTypedValue()); + } + const OperationSignaturePtr op_signature = + OperationSignature::Create( + operation_name, argument_type_ids, static_arguments.size()); + if (!HasOperation(op_signature)) { +return false; + } + return GetUnaryOperation(op_signature)->canApplyTo(type, static_tv_arguments); +} + +bool OperationFactory::CanApplyBinaryOperation( +const std::string &operation_name, +const Type &left, const Type &right, +const std::vector &static_arguments) { + std::vector argument_type_ids = {left.getTypeID(), right.getTypeID()}; + std::vector static_tv_arguments; + for (const auto &value : static_arguments) { +argument_type_ids.emplace_back(value.getTypeID()); +// TODO(refactor-type): Remove this. +static_tv_arguments.emplace_back(value.toTypedValue()); + } + // TODO(refactor-type): Handle this. + DCHECK_EQ(0u, static_arguments.size()); + const OperationSignaturePtr op_signature = + OperationSignature::Create( + operation_name, argument_type_ids, static_arguments.size()); + if (!HasOperation(op_signature)) { +return false; + } + return GetBinaryOperation(op_signature)->canApplyTo(left, right, static_tv_arguments); +} + +OperationPtr OperationFactory::GetOperation( +const OperationSignaturePtr &op_signature) { + DCHECK(HasOperation(op_signature)); + return Instance().operations_.at(op_signature); +} + + +UnaryOperationPtr OperationFactory::GetUnaryOperation( +const OperationSignaturePtr &op_signature) { + const OperationPtr operation = GetOperation(op_signature); + DCHECK(operation->getOperationSuperTypeID() == Operation::kUnaryOperation); + return std::static_pointer_cast(operation); +} + +BinaryOperationPtr OperationFactory::GetBinaryOperation( +const OperationSignaturePtr &op_signature) { + const OperationPtr operation = GetOperation(op_signature); + DCHECK(operation->getOperationSuperTypeID() == Operation::kBinaryOperation); + return std::static_pointer_cast(operation); +} + +OperationSignaturePtr OperationFactory::ResolveOperation( +const std
[33/41] incubator-quickstep git commit: Updates for array type
Updates for array type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/1e69fb18 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/1e69fb18 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/1e69fb18 Branch: refs/heads/refactor-type Commit: 1e69fb18eb9e7f31c48d85aaef781dca1ba8290a Parents: b6fd31f Author: Jianqiao Zhu Authored: Mon Oct 2 23:46:48 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 13:37:54 2017 -0500 -- query_optimizer/expressions/CMakeLists.txt| 1 + query_optimizer/expressions/ScalarLiteral.hpp | 3 +- query_optimizer/resolver/CMakeLists.txt | 4 + query_optimizer/resolver/Resolver.cpp | 70 ++- types/GenericValue.hpp| 18 +- types/Type.cpp| 18 + types/Type.hpp| 23 +- types/Type.proto | 2 +- types/TypeSynthesizer.hpp | 479 - utility/CharStream.hpp| 34 +- utility/meta/Common.hpp | 58 ++- validate_cmakelists.py| 8 +- 12 files changed, 450 insertions(+), 268 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e69fb18/query_optimizer/expressions/CMakeLists.txt -- diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt index dc722e7..cf2727f 100644 --- a/query_optimizer/expressions/CMakeLists.txt +++ b/query_optimizer/expressions/CMakeLists.txt @@ -97,6 +97,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_BinaryExpression quickstep_queryoptimizer_expressions_PatternMatcher quickstep_queryoptimizer_expressions_Scalar quickstep_queryoptimizer_expressions_ScalarLiteral + quickstep_types_GenericValue quickstep_types_operations_OperationSignature quickstep_types_operations_binaryoperations_BinaryOperation quickstep_utility_HashPair http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e69fb18/query_optimizer/expressions/ScalarLiteral.hpp -- diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/ScalarLiteral.hpp index 180ae39..f6a14f4 100644 --- a/query_optimizer/expressions/ScalarLiteral.hpp +++ b/query_optimizer/expressions/ScalarLiteral.hpp @@ -108,7 +108,8 @@ class ScalarLiteral : public Scalar { ScalarLiteral(const GenericValue &literal_value) : value_(literal_value) {} - const GenericValue &value_; + const GenericValue value_; + DISALLOW_COPY_AND_ASSIGN(ScalarLiteral); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e69fb18/query_optimizer/resolver/CMakeLists.txt -- diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt index a759ce3..8a1116a 100644 --- a/query_optimizer/resolver/CMakeLists.txt +++ b/query_optimizer/resolver/CMakeLists.txt @@ -120,7 +120,11 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver quickstep_queryoptimizer_resolver_NameResolver quickstep_storage_StorageBlockLayout_proto quickstep_storage_StorageConstants + quickstep_types_ArrayType + quickstep_types_GenericValue quickstep_types_IntType + quickstep_types_MetaType + quickstep_types_NullType quickstep_types_Type quickstep_types_TypeUtil quickstep_types_TypedValue http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e69fb18/query_optimizer/resolver/Resolver.cpp -- diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp index 2cd24bd..d4ff5c6 100644 --- a/query_optimizer/resolver/Resolver.cpp +++ b/query_optimizer/resolver/Resolver.cpp @@ -115,8 +115,11 @@ #include "query_optimizer/resolver/NameResolver.hpp" #include "storage/StorageBlockLayout.pb.h" #include "storage/StorageConstants.hpp" +#include "types/ArrayType.hpp" #include "types/GenericValue.hpp" #include "types/IntType.hpp" +#include "types/MetaType.hpp" +#include "types/NullType.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeU
incubator-quickstep git commit: Updates to implicit casts
Repository: incubator-quickstep Updated Branches: refs/heads/refactor-type 4bf0857c5 -> 8c3996c68 Updates to implicit casts Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8c3996c6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8c3996c6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8c3996c6 Branch: refs/heads/refactor-type Commit: 8c3996c686ac22d19e01d5e4e1f7bfb415f8321c Parents: 4bf0857 Author: Jianqiao Zhu Authored: Wed Oct 11 03:38:40 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 03:38:40 2017 -0500 -- query_optimizer/expressions/Cast.cpp | 16 ++ query_optimizer/expressions/Cast.hpp | 19 +- query_optimizer/expressions/Expression.hpp| 5 + query_optimizer/expressions/ScalarLiteral.hpp | 8 +- query_optimizer/resolver/Resolver.cpp | 27 ++- types/TextType.cpp| 9 + types/TextType.hpp| 2 + types/TypeUtil.hpp| 27 +++ types/operations/OperationFactory.cpp | 218 ++--- types/operations/OperationFactory.hpp | 56 -- 10 files changed, 285 insertions(+), 102 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8c3996c6/query_optimizer/expressions/Cast.cpp -- diff --git a/query_optimizer/expressions/Cast.cpp b/query_optimizer/expressions/Cast.cpp index 2315f92..7df4159 100644 --- a/query_optimizer/expressions/Cast.cpp +++ b/query_optimizer/expressions/Cast.cpp @@ -73,6 +73,22 @@ ExpressionPtr Cast::copyWithNewChildren( std::make_shared>(std::move(meta_type_value))); } +TypedValue Cast::getConstantValue() const { + DCHECK(isConstant()); + const Type &source_type = operand_->getValueType(); + const UnaryOperationPtr cast_operation = + OperationFactory::GetCastOperation(source_type.getTypeID()); + + std::vector meta_type_value = + { GenericValue::CreateWithLiteral( +MetaType::InstanceNonNullable(), &target_type_).toTypedValue() }; + DCHECK(cast_operation->canApplyTo(source_type, meta_type_value)); + + std::unique_ptr cast_op( + cast_operation->makeUncheckedUnaryOperator(source_type, meta_type_value)); + return cast_op->applyToTypedValue(operand_->getConstantValue()); +} + std::size_t Cast::computeHash() const { return CombineHashes( CombineHashes(static_cast(ExpressionType::kCast), http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8c3996c6/query_optimizer/expressions/Cast.hpp -- diff --git a/query_optimizer/expressions/Cast.hpp b/query_optimizer/expressions/Cast.hpp index 11be775..5da0e8c 100644 --- a/query_optimizer/expressions/Cast.hpp +++ b/query_optimizer/expressions/Cast.hpp @@ -55,13 +55,23 @@ typedef std::shared_ptr CastPtr; */ class Cast : public Scalar { public: - ExpressionType getExpressionType() const override { return ExpressionType::kCast; } + ExpressionType getExpressionType() const override { +return ExpressionType::kCast; + } + + std::string getName() const override { +return "Cast"; + } - std::string getName() const override { return "Cast"; } + const Type& getValueType() const override { +return target_type_; + } - const Type& getValueType() const override { return target_type_; } + bool isConstant() const override { +return operand_->isConstant(); + } - bool isConstant() const override { return operand_->isConstant(); } + TypedValue getConstantValue() const override; /** * @return The expression to be coerced. @@ -78,6 +88,7 @@ class Cast : public Scalar { ::quickstep::Scalar* concretize( const std::unordered_map &substitution_map) const override; + bool equals(const ScalarPtr &other) const override; /** http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8c3996c6/query_optimizer/expressions/Expression.hpp -- diff --git a/query_optimizer/expressions/Expression.hpp b/query_optimizer/expressions/Expression.hpp index 7127047..fc6fc53 100644 --- a/query_optimizer/expressions/Expression.hpp +++ b/query_optimizer/expressions/Expression.hpp @@ -80,6 +80,11 @@ class Expression : public OptimizerTree { */ virtual bool isConstant() const = 0; + virtual TypedValue getConstantValue() const { +LOG(FATAL) << "Not implemented"; + } + + protected: Expression() {} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8c3996c6/query_optimizer/expressions/ScalarLiteral.hpp
[40/41] incubator-quickstep git commit: Updates to casts
Updates to casts Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/477c385d Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/477c385d Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/477c385d Branch: refs/heads/refactor-type Commit: 477c385d427483d4c2708449927f14268e53c311 Parents: 1cb97e3 Author: Jianqiao Zhu Authored: Tue Oct 10 13:20:17 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 13:37:54 2017 -0500 -- expressions/ExpressionFactories.cpp | 4 +- .../aggregation/AggregateFunctionAvg.cpp| 13 +- .../aggregation/AggregateFunctionSum.cpp| 4 +- .../aggregation/AggregationHandleAvg.cpp| 16 +- .../aggregation/AggregationHandleSum.cpp| 8 +- expressions/scalar/ScalarCaseExpression.cpp | 8 +- .../WindowAggregateFunctionAvg.cpp | 3 +- .../WindowAggregateFunctionSum.cpp | 2 +- .../WindowAggregationHandle.cpp | 4 +- .../WindowAggregationHandleAvg.cpp | 4 +- query_optimizer/expressions/CMakeLists.txt | 11 +- query_optimizer/expressions/Cast.cpp| 2 +- query_optimizer/resolver/Resolver.cpp | 80 ++- query_optimizer/rules/Partition.cpp | 2 +- .../rules/ReuseAggregateExpressions.cpp | 2 +- storage/SMAIndexSubBlock.cpp| 7 +- storage/WindowAggregationOperationState.cpp | 4 +- types/ArrayLit.hpp | 112 types/ArrayType.cpp | 30 +- types/ArrayType.hpp | 10 +- types/AsciiStringSuperType.hpp | 8 - types/BoolType.hpp | 2 +- types/CMakeLists.txt| 7 +- types/CharType.hpp | 2 +- types/DateType.hpp | 2 +- types/DatetimeIntervalType.hpp | 2 +- types/DatetimeType.hpp | 3 +- types/DoubleType.hpp| 2 +- types/FloatType.hpp | 2 +- types/IntType.hpp | 2 +- types/LongType.hpp | 2 +- types/MetaType-decl.hpp | 2 +- types/MetaType.cpp | 2 +- types/NullType.hpp | 2 +- types/NumericSuperType.hpp | 5 - types/TextType.hpp | 2 +- types/Type.cpp | 22 +- types/Type.hpp | 9 +- types/Type.proto| 4 +- types/TypeRegistrar.hpp | 16 +- types/TypeSynthesizer.hpp | 34 +- types/VarCharType.hpp | 2 +- types/YearMonthIntervalType.hpp | 2 +- types/containers/CMakeLists.txt | 1 + types/containers/ColumnVector.cpp | 43 +- types/containers/ColumnVector.hpp | 124 +++- types/containers/ColumnVectorUtil.hpp | 6 +- types/containers/ColumnVectorsValueAccessor.hpp | 41 +- types/operations/CMakeLists.txt | 5 +- types/operations/OperationFactory.cpp | 160 - types/operations/OperationFactory.hpp | 138 ++-- .../ArithmeticBinaryFunctors.hpp| 2 +- .../AsciiStringBinaryFunctors.hpp | 24 +- .../BinaryOperationSynthesizer.hpp | 660 +++ .../BinaryOperationWrapper.hpp | 629 -- .../operations/binary_operations/CMakeLists.txt | 15 +- .../binary_operations/CMathBinaryFunctors.hpp | 2 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../comparisons/LiteralComparators-inl.hpp | 10 +- .../ArithmeticUnaryFunctors.hpp | 2 +- .../AsciiStringUnaryFunctors.hpp| 2 +- .../operations/unary_operations/CMakeLists.txt | 29 +- .../unary_operations/CMathUnaryFunctors.hpp | 2 +- .../unary_operations/CastFunctorOverloads.hpp | 195 +++--- .../unary_operations/CastOperation.cpp | 6 +- .../unary_operations/CastOperation.hpp | 4 +- .../unary_operations/DateExtractOperation.cpp | 20 +- .../UnaryOperationSynthesizer.hpp | 273 .../unary_operations/UnaryOperationWrapper.hpp | 250 --- types/operations/utility/CMakeLists.txt | 11 +- types/operations/utility/CastUtil.cpp | 66 ++ types/operations/utility/CastUtil.hpp | 50 ++ .../utility/OperationSynthesizeUtil.hpp | 184 +- utility/Cast.hpp| 7 +- utility/met
[25/41] incubator-quickstep git commit: Updates for adding generic types
Updates for adding generic types Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/ebf44cd2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/ebf44cd2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/ebf44cd2 Branch: refs/heads/refactor-type Commit: ebf44cd2dd230bd45c849cb008005ad9c07b2d60 Parents: 0200550 Author: Jianqiao Zhu Authored: Mon Oct 2 00:26:05 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 13:37:54 2017 -0500 -- cli/PrintToScreen.cpp | 2 +- compression/CompressionDictionaryBuilder.cpp| 3 +- compression/CompressionDictionaryBuilder.hpp| 6 +- .../aggregation/AggregationHandleAvg.hpp| 8 +- .../aggregation/AggregationHandleMax.hpp| 6 +- .../aggregation/AggregationHandleMin.hpp| 6 +- .../aggregation/AggregationHandleSum.hpp| 7 +- expressions/scalar/ScalarBinaryExpression.cpp | 2 +- expressions/scalar/ScalarCaseExpression.cpp | 2 +- expressions/scalar/ScalarLiteral.cpp| 2 +- expressions/scalar/ScalarUnaryExpression.cpp| 2 +- parser/ParseLiteralValue.cpp| 2 +- parser/SqlLexer.lpp | 2 + parser/SqlParser.ypp| 2 + query_optimizer/expressions/ScalarLiteral.cpp | 2 +- query_optimizer/resolver/Resolver.cpp | 10 +- relational_operators/TableExportOperator.cpp| 2 +- storage/LinearOpenAddressingHashTable.hpp | 18 +- storage/SeparateChainingHashTable.hpp | 18 +- .../SimpleScalarSeparateChainingHashTable.hpp | 18 +- storage/TupleStorageSubBlock.cpp| 3 +- types/ArrayType.cpp | 46 +++ types/ArrayType.hpp | 78 + types/AsciiStringSuperType.hpp | 2 +- types/BoolType.cpp | 12 +- types/BoolType.hpp | 8 +- types/CMakeLists.txt| 4 + types/CharType.cpp | 12 +- types/CharType.hpp | 10 +- types/DateType.cpp | 6 +- types/DateType.hpp | 6 +- types/DatetimeIntervalType.cpp | 6 +- types/DatetimeIntervalType.hpp | 6 +- types/DatetimeType.cpp | 6 +- types/DatetimeType.hpp | 6 +- types/DoubleType.cpp| 12 +- types/DoubleType.hpp| 8 +- types/FloatType.cpp | 12 +- types/FloatType.hpp | 8 +- types/GenericValue.cpp | 0 types/GenericValue.hpp | 118 +++ types/IntType.cpp | 12 +- types/IntType.hpp | 8 +- types/LongType.cpp | 12 +- types/LongType.hpp | 8 +- types/MetaType.cpp | 36 +++ types/MetaType.hpp | 67 types/NullType.hpp | 14 +- types/NumericSuperType.hpp | 5 +- types/ParameterizedPodLit.hpp | 0 types/Type.cpp | 2 +- types/Type.hpp | 103 +++--- types/Type.proto| 5 + types/TypeFactory.cpp | 5 +- types/TypeID.cpp| 2 + types/TypeID.hpp| 32 +- types/TypeIDSelectors.hpp | 62 ++-- types/TypeRegistrar.hpp | 81 +++-- types/TypeSynthesizer.hpp | 314 --- types/TypeUtil.hpp | 4 +- types/TypedValue.hpp| 22 ++ types/VarCharType.cpp | 12 +- types/VarCharType.hpp | 10 +- types/YearMonthIntervalType.cpp | 6 +- types/YearMonthIntervalType.hpp | 6 +- types/containers/ColumnVector.hpp | 24 +- types/operations/OperationUtil.hpp | 12 +- .../BinaryOperationWrapper.hpp | 6 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../unary_operations/CastOperation.cpp | 10 +- .../unary_operations/UnaryOperationWrapper.hpp | 2 +- utility/CMakeLists.txt | 7 +- utility/CharStream.hpp | 106 +++ 73 files changed, 1154 insertions(+), 353 deletions(-) --
[03/41] incubator-quickstep git commit: Updates to implicit casts
Updates to implicit casts Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a3aec8e7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a3aec8e7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a3aec8e7 Branch: refs/heads/refactor-type Commit: a3aec8e789b66c2c1de64cbd2cdc3fac70b8121b Parents: 477c385 Author: Jianqiao Zhu Authored: Wed Oct 11 03:38:40 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 11 13:37:54 2017 -0500 -- query_optimizer/expressions/Cast.cpp | 16 ++ query_optimizer/expressions/Cast.hpp | 19 +- query_optimizer/expressions/Expression.hpp| 5 + query_optimizer/expressions/ScalarLiteral.hpp | 8 +- query_optimizer/resolver/Resolver.cpp | 27 ++- types/TextType.cpp| 9 + types/TextType.hpp| 2 + types/TypeUtil.hpp| 27 +++ types/operations/OperationFactory.cpp | 218 ++--- types/operations/OperationFactory.hpp | 56 -- 10 files changed, 285 insertions(+), 102 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3aec8e7/query_optimizer/expressions/Cast.cpp -- diff --git a/query_optimizer/expressions/Cast.cpp b/query_optimizer/expressions/Cast.cpp index 2315f92..7df4159 100644 --- a/query_optimizer/expressions/Cast.cpp +++ b/query_optimizer/expressions/Cast.cpp @@ -73,6 +73,22 @@ ExpressionPtr Cast::copyWithNewChildren( std::make_shared>(std::move(meta_type_value))); } +TypedValue Cast::getConstantValue() const { + DCHECK(isConstant()); + const Type &source_type = operand_->getValueType(); + const UnaryOperationPtr cast_operation = + OperationFactory::GetCastOperation(source_type.getTypeID()); + + std::vector meta_type_value = + { GenericValue::CreateWithLiteral( +MetaType::InstanceNonNullable(), &target_type_).toTypedValue() }; + DCHECK(cast_operation->canApplyTo(source_type, meta_type_value)); + + std::unique_ptr cast_op( + cast_operation->makeUncheckedUnaryOperator(source_type, meta_type_value)); + return cast_op->applyToTypedValue(operand_->getConstantValue()); +} + std::size_t Cast::computeHash() const { return CombineHashes( CombineHashes(static_cast(ExpressionType::kCast), http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3aec8e7/query_optimizer/expressions/Cast.hpp -- diff --git a/query_optimizer/expressions/Cast.hpp b/query_optimizer/expressions/Cast.hpp index 11be775..5da0e8c 100644 --- a/query_optimizer/expressions/Cast.hpp +++ b/query_optimizer/expressions/Cast.hpp @@ -55,13 +55,23 @@ typedef std::shared_ptr CastPtr; */ class Cast : public Scalar { public: - ExpressionType getExpressionType() const override { return ExpressionType::kCast; } + ExpressionType getExpressionType() const override { +return ExpressionType::kCast; + } + + std::string getName() const override { +return "Cast"; + } - std::string getName() const override { return "Cast"; } + const Type& getValueType() const override { +return target_type_; + } - const Type& getValueType() const override { return target_type_; } + bool isConstant() const override { +return operand_->isConstant(); + } - bool isConstant() const override { return operand_->isConstant(); } + TypedValue getConstantValue() const override; /** * @return The expression to be coerced. @@ -78,6 +88,7 @@ class Cast : public Scalar { ::quickstep::Scalar* concretize( const std::unordered_map &substitution_map) const override; + bool equals(const ScalarPtr &other) const override; /** http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3aec8e7/query_optimizer/expressions/Expression.hpp -- diff --git a/query_optimizer/expressions/Expression.hpp b/query_optimizer/expressions/Expression.hpp index 7127047..fc6fc53 100644 --- a/query_optimizer/expressions/Expression.hpp +++ b/query_optimizer/expressions/Expression.hpp @@ -80,6 +80,11 @@ class Expression : public OptimizerTree { */ virtual bool isConstant() const = 0; + virtual TypedValue getConstantValue() const { +LOG(FATAL) << "Not implemented"; + } + + protected: Expression() {} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3aec8e7/query_optimizer/expressions/ScalarLiteral.hpp -- diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/Scala
[38/41] incubator-quickstep git commit: Updates to casts
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/477c385d/types/operations/unary_operations/CMakeLists.txt -- diff --git a/types/operations/unary_operations/CMakeLists.txt b/types/operations/unary_operations/CMakeLists.txt index fbfd091..269d683 100644 --- a/types/operations/unary_operations/CMakeLists.txt +++ b/types/operations/unary_operations/CMakeLists.txt @@ -36,9 +36,9 @@ add_library(quickstep_types_operations_unaryoperations_SubstringOperation SubstringOperation.cpp SubstringOperation.hpp) add_library(quickstep_types_operations_unaryoperations_UnaryOperation UnaryOperation.cpp UnaryOperation.hpp) -add_library(quickstep_types_operations_unaryoperations_UnaryOperationWrapper +add_library(quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer ../../../empty_src.cpp -UnaryOperationWrapper.hpp) +UnaryOperationSynthesizer.hpp) # Link dependencies: target_link_libraries(quickstep_types_operations_unaryoperations_ArithmeticUnaryFunctors @@ -49,7 +49,7 @@ target_link_libraries(quickstep_types_operations_unaryoperations_ArithmeticUnary quickstep_types_IntType quickstep_types_LongType quickstep_types_YearMonthIntervalType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil) target_link_libraries(quickstep_types_operations_unaryoperations_AsciiStringUnaryFunctors quickstep_types_CharType @@ -58,7 +58,7 @@ target_link_libraries(quickstep_types_operations_unaryoperations_AsciiStringUnar quickstep_types_TypeFactory quickstep_types_TypeID quickstep_types_VarCharType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil quickstep_types_port_strnlen quickstep_utility_meta_Common) @@ -67,28 +67,37 @@ target_link_libraries(quickstep_types_operations_unaryoperations_CMathUnaryFunct quickstep_types_FloatType quickstep_types_IntType quickstep_types_LongType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil quickstep_utility_meta_Common) +target_link_libraries(quickstep_types_operations_unaryoperations_CastFunctorOverloads + quickstep_types_TypeRegistrar + quickstep_types_TypedValue + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer + quickstep_utility_meta_TypeList) target_link_libraries(quickstep_types_operations_unaryoperations_CastOperation glog quickstep_types_CharType quickstep_types_DoubleType quickstep_types_FloatType + quickstep_types_GenericValue quickstep_types_IntType quickstep_types_LongType + quickstep_types_MetaType quickstep_types_Type quickstep_types_TypeFactory quickstep_types_TypeID quickstep_types_TypeUtil quickstep_types_TypedValue quickstep_types_VarCharType + quickstep_types_operations_unaryoperations_CastFunctorOverloads quickstep_types_operations_unaryoperations_UnaryOperation - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_port_strnlen quickstep_utility_EqualsAnyConstant quickstep_utility_Macros - quickstep_utility_StringUtil) + quickstep_utility_StringUtil + quickstep_utility_meta_Common) target_link_libraries(quickstep_types_operations_unaryoperations_DateExtractOperation glog quickstep_types_DateType @@ -100,7 +109,7 @@ target_link_libraries(quickstep_types_operations_unaryoperations_DateExtractOper
[22/38] incubator-quickstep git commit: Updates for adding generic types
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d6a51acf/types/TypeRegistrar.hpp -- diff --git a/types/TypeRegistrar.hpp b/types/TypeRegistrar.hpp index ffe2b7e..9e6c50b 100644 --- a/types/TypeRegistrar.hpp +++ b/types/TypeRegistrar.hpp @@ -20,13 +20,14 @@ #ifndef QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ #define QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ +#include #include #include +#include #include "types/DatetimeLit.hpp" #include "types/IntervalLit.hpp" #include "types/NullLit.hpp" -#include "types/Type.hpp" #include "types/TypeID.hpp" #include "types/TypeIDSelectors.hpp" #include "utility/meta/Common.hpp" @@ -39,6 +40,14 @@ namespace quickstep { * @{ */ +class Type; +class TypedValue; + +using UntypedLiteral = void; + +using ArrayLiteral = std::vector; +using MetaTypeLiteral = const Type*; + template struct TypeIDTrait; @@ -48,36 +57,40 @@ struct TypeIDTrait; typedef type_class TypeClass; \ typedef cpp_type cpptype; \ static constexpr TypeID kStaticTypeID = type_id; \ -static constexpr Type::SuperTypeID kStaticSuperTypeID = super_type_id; \ +static constexpr SuperTypeID kStaticSuperTypeID = super_type_id; \ static constexpr MemoryLayout kMemoryLayout = memory_layout; \ -static constexpr bool kIsParameterizedPod = \ -(memory_layout == kParNativePod || memory_layout == kParIndirectPod); \ +static constexpr bool kIsParPod = \ +(memory_layout == kParInlinePod || memory_layout == kParOutOfLinePod); \ }; -REGISTER_TYPE(BoolType, kBool, \ - Type::kNumeric, kCxxNativePod, bool); -REGISTER_TYPE(IntType, kInt, \ - Type::kNumeric, kCxxNativePod, int); -REGISTER_TYPE(LongType, kLong, \ - Type::kNumeric, kCxxNativePod, std::int64_t); -REGISTER_TYPE(FloatType, kFloat, \ - Type::kNumeric, kCxxNativePod, float); -REGISTER_TYPE(DoubleType, kDouble, \ - Type::kNumeric, kCxxNativePod, double); -REGISTER_TYPE(DateType, kDate, \ - Type::kOther, kCxxNativePod, DateLit); -REGISTER_TYPE(DatetimeType, kDatetime, \ - Type::kOther, kCxxNativePod, DatetimeLit); -REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, \ - Type::kOther, kCxxNativePod, DatetimeIntervalLit); -REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, \ - Type::kOther, kCxxNativePod, YearMonthIntervalLit); -REGISTER_TYPE(CharType, kChar, \ - Type::kAsciiString, kParNativePod, void); -REGISTER_TYPE(VarCharType, kVarChar, \ - Type::kAsciiString, kParIndirectPod, void); -REGISTER_TYPE(NullType, kNullType, \ - Type::kOther, kCxxNativePod, NullLit); +REGISTER_TYPE(BoolType, kBool, + SuperTypeID::kNumeric, kCxxInlinePod, bool); +REGISTER_TYPE(IntType, kInt, + SuperTypeID::kNumeric, kCxxInlinePod, int); +REGISTER_TYPE(LongType, kLong, + SuperTypeID::kNumeric, kCxxInlinePod, std::int64_t); +REGISTER_TYPE(FloatType, kFloat, + SuperTypeID::kNumeric, kCxxInlinePod, float); +REGISTER_TYPE(DoubleType, kDouble, + SuperTypeID::kNumeric, kCxxInlinePod, double); +REGISTER_TYPE(DateType, kDate, + SuperTypeID::kOther, kCxxInlinePod, DateLit); +REGISTER_TYPE(DatetimeType, kDatetime, + SuperTypeID::kOther, kCxxInlinePod, DatetimeLit); +REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, + SuperTypeID::kOther, kCxxInlinePod, DatetimeIntervalLit); +REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, + SuperTypeID::kOther, kCxxInlinePod, YearMonthIntervalLit); +REGISTER_TYPE(CharType, kChar, + SuperTypeID::kAsciiString, kParInlinePod, TypedValue); +REGISTER_TYPE(VarCharType, kVarChar, + SuperTypeID::kAsciiString, kParOutOfLinePod, TypedValue); +REGISTER_TYPE(ArrayType, kArray, + SuperTypeID::kOther, kCxxGeneric, ArrayLiteral); +REGISTER_TYPE(MetaType, kMetaType, + SuperTypeID::kOther, kCxxGeneric, MetaTypeLiteral); +REGISTER_TYPE(NullType, kNullType, + SuperTypeID::kOther, kCxxInlinePod, NullLit); #undef REGISTER_TYPE @@ -91,8 +104,8 @@ auto InvokeOnTypeID(const TypeID type_id, const FunctorT &functor); namespace internal { template -inline auto InvokeOnTypeIDInner(const int value, -const FunctorT &functor) { +inline auto InvokeOnTypeIDInternal(const int value, + const FunctorT &functor) { DCHECK_LE(l, r); if (l == r) { constexpr TypeID type_id = static_cast(r); @@ -101,9 +114,9 @@ inline auto InvokeOnTypeIDInner(const int value, } constexpr int m = (l + r) >> 1; if (value <= m) { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, functor); } else { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, funct
[23/38] incubator-quickstep git commit: Updates for adding generic types
Updates for adding generic types Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/d6a51acf Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/d6a51acf Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/d6a51acf Branch: refs/heads/refactor-type Commit: d6a51acf8837201db70ad146146e6254e6dab2d5 Parents: 98a8e61 Author: Jianqiao Zhu Authored: Mon Oct 2 00:26:05 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 10 13:24:03 2017 -0500 -- cli/PrintToScreen.cpp | 2 +- compression/CompressionDictionaryBuilder.cpp| 3 +- compression/CompressionDictionaryBuilder.hpp| 6 +- .../aggregation/AggregationHandleAvg.hpp| 8 +- .../aggregation/AggregationHandleMax.hpp| 6 +- .../aggregation/AggregationHandleMin.hpp| 6 +- .../aggregation/AggregationHandleSum.hpp| 7 +- expressions/scalar/ScalarBinaryExpression.cpp | 2 +- expressions/scalar/ScalarCaseExpression.cpp | 2 +- expressions/scalar/ScalarLiteral.cpp| 2 +- expressions/scalar/ScalarUnaryExpression.cpp| 2 +- parser/ParseLiteralValue.cpp| 2 +- parser/SqlLexer.lpp | 2 + parser/SqlParser.ypp| 2 + query_optimizer/expressions/ScalarLiteral.cpp | 2 +- query_optimizer/resolver/Resolver.cpp | 10 +- relational_operators/TableExportOperator.cpp| 2 +- storage/LinearOpenAddressingHashTable.hpp | 18 +- storage/SeparateChainingHashTable.hpp | 18 +- .../SimpleScalarSeparateChainingHashTable.hpp | 18 +- storage/TupleStorageSubBlock.cpp| 3 +- types/ArrayType.cpp | 46 +++ types/ArrayType.hpp | 78 + types/AsciiStringSuperType.hpp | 2 +- types/BoolType.cpp | 12 +- types/BoolType.hpp | 8 +- types/CMakeLists.txt| 4 + types/CharType.cpp | 12 +- types/CharType.hpp | 10 +- types/DateType.cpp | 6 +- types/DateType.hpp | 6 +- types/DatetimeIntervalType.cpp | 6 +- types/DatetimeIntervalType.hpp | 6 +- types/DatetimeType.cpp | 6 +- types/DatetimeType.hpp | 6 +- types/DoubleType.cpp| 12 +- types/DoubleType.hpp| 8 +- types/FloatType.cpp | 12 +- types/FloatType.hpp | 8 +- types/GenericValue.cpp | 0 types/GenericValue.hpp | 118 +++ types/IntType.cpp | 12 +- types/IntType.hpp | 8 +- types/LongType.cpp | 12 +- types/LongType.hpp | 8 +- types/MetaType.cpp | 36 +++ types/MetaType.hpp | 67 types/NullType.hpp | 14 +- types/NumericSuperType.hpp | 5 +- types/ParameterizedPodLit.hpp | 0 types/Type.cpp | 2 +- types/Type.hpp | 103 +++--- types/Type.proto| 5 + types/TypeFactory.cpp | 5 +- types/TypeID.cpp| 2 + types/TypeID.hpp| 32 +- types/TypeIDSelectors.hpp | 62 ++-- types/TypeRegistrar.hpp | 81 +++-- types/TypeSynthesizer.hpp | 314 --- types/TypeUtil.hpp | 4 +- types/TypedValue.hpp| 22 ++ types/VarCharType.cpp | 12 +- types/VarCharType.hpp | 10 +- types/YearMonthIntervalType.cpp | 6 +- types/YearMonthIntervalType.hpp | 6 +- types/containers/ColumnVector.hpp | 24 +- types/operations/OperationUtil.hpp | 12 +- .../BinaryOperationWrapper.hpp | 6 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../unary_operations/CastOperation.cpp | 10 +- .../unary_operations/UnaryOperationWrapper.hpp | 2 +- utility/CMakeLists.txt | 7 +- utility/CharStream.hpp | 106 +++ 73 files changed, 1154 insertions(+), 353 deletions(-) --
[01/38] incubator-quickstep git commit: Updates to casts
Repository: incubator-quickstep Updated Branches: refs/heads/refactor-type [created] 4bf0857c5 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4bf0857c/types/operations/unary_operations/CMakeLists.txt -- diff --git a/types/operations/unary_operations/CMakeLists.txt b/types/operations/unary_operations/CMakeLists.txt index fbfd091..269d683 100644 --- a/types/operations/unary_operations/CMakeLists.txt +++ b/types/operations/unary_operations/CMakeLists.txt @@ -36,9 +36,9 @@ add_library(quickstep_types_operations_unaryoperations_SubstringOperation SubstringOperation.cpp SubstringOperation.hpp) add_library(quickstep_types_operations_unaryoperations_UnaryOperation UnaryOperation.cpp UnaryOperation.hpp) -add_library(quickstep_types_operations_unaryoperations_UnaryOperationWrapper +add_library(quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer ../../../empty_src.cpp -UnaryOperationWrapper.hpp) +UnaryOperationSynthesizer.hpp) # Link dependencies: target_link_libraries(quickstep_types_operations_unaryoperations_ArithmeticUnaryFunctors @@ -49,7 +49,7 @@ target_link_libraries(quickstep_types_operations_unaryoperations_ArithmeticUnary quickstep_types_IntType quickstep_types_LongType quickstep_types_YearMonthIntervalType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil) target_link_libraries(quickstep_types_operations_unaryoperations_AsciiStringUnaryFunctors quickstep_types_CharType @@ -58,7 +58,7 @@ target_link_libraries(quickstep_types_operations_unaryoperations_AsciiStringUnar quickstep_types_TypeFactory quickstep_types_TypeID quickstep_types_VarCharType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil quickstep_types_port_strnlen quickstep_utility_meta_Common) @@ -67,28 +67,37 @@ target_link_libraries(quickstep_types_operations_unaryoperations_CMathUnaryFunct quickstep_types_FloatType quickstep_types_IntType quickstep_types_LongType - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_operations_utility_OperationSynthesizeUtil quickstep_utility_meta_Common) +target_link_libraries(quickstep_types_operations_unaryoperations_CastFunctorOverloads + quickstep_types_TypeRegistrar + quickstep_types_TypedValue + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer + quickstep_utility_meta_TypeList) target_link_libraries(quickstep_types_operations_unaryoperations_CastOperation glog quickstep_types_CharType quickstep_types_DoubleType quickstep_types_FloatType + quickstep_types_GenericValue quickstep_types_IntType quickstep_types_LongType + quickstep_types_MetaType quickstep_types_Type quickstep_types_TypeFactory quickstep_types_TypeID quickstep_types_TypeUtil quickstep_types_TypedValue quickstep_types_VarCharType + quickstep_types_operations_unaryoperations_CastFunctorOverloads quickstep_types_operations_unaryoperations_UnaryOperation - quickstep_types_operations_unaryoperations_UnaryOperationWrapper + quickstep_types_operations_unaryoperations_UnaryOperationSynthesizer quickstep_types_port_strnlen quickstep_utility_EqualsAnyConstant quickstep_utility_Macros - quickstep_utility_StringUtil) + quickstep_utility_StringUtil + quickstep_utility_meta_Common) target_link_libraries(quickstep_types_operations_unaryoperations_DateExtractOperation glog quickstep_types_DateType @@ -100,7 +109,7 @@ ta
[03/38] incubator-quickstep git commit: Updates to casts
Updates to casts Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/4bf0857c Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/4bf0857c Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/4bf0857c Branch: refs/heads/refactor-type Commit: 4bf0857c57ef2f9fed8fad5a35255b471341918c Parents: f9e32e6 Author: Jianqiao Zhu Authored: Tue Oct 10 13:20:17 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 10 13:24:03 2017 -0500 -- expressions/ExpressionFactories.cpp | 4 +- .../aggregation/AggregateFunctionAvg.cpp| 13 +- .../aggregation/AggregateFunctionSum.cpp| 4 +- .../aggregation/AggregationHandleAvg.cpp| 16 +- .../aggregation/AggregationHandleSum.cpp| 8 +- expressions/scalar/ScalarCaseExpression.cpp | 8 +- .../WindowAggregateFunctionAvg.cpp | 3 +- .../WindowAggregateFunctionSum.cpp | 2 +- .../WindowAggregationHandle.cpp | 4 +- .../WindowAggregationHandleAvg.cpp | 4 +- query_optimizer/expressions/CMakeLists.txt | 11 +- query_optimizer/expressions/Cast.cpp| 2 +- query_optimizer/resolver/Resolver.cpp | 80 ++- query_optimizer/rules/Partition.cpp | 2 +- .../rules/ReuseAggregateExpressions.cpp | 2 +- storage/SMAIndexSubBlock.cpp| 7 +- storage/WindowAggregationOperationState.cpp | 4 +- types/ArrayLit.hpp | 112 types/ArrayType.cpp | 30 +- types/ArrayType.hpp | 10 +- types/AsciiStringSuperType.hpp | 8 - types/BoolType.hpp | 2 +- types/CMakeLists.txt| 7 +- types/CharType.hpp | 2 +- types/DateType.hpp | 2 +- types/DatetimeIntervalType.hpp | 2 +- types/DatetimeType.hpp | 3 +- types/DoubleType.hpp| 2 +- types/FloatType.hpp | 2 +- types/IntType.hpp | 2 +- types/LongType.hpp | 2 +- types/MetaType-decl.hpp | 2 +- types/MetaType.cpp | 2 +- types/NullType.hpp | 2 +- types/NumericSuperType.hpp | 5 - types/TextType.hpp | 2 +- types/Type.cpp | 22 +- types/Type.hpp | 9 +- types/Type.proto| 4 +- types/TypeRegistrar.hpp | 16 +- types/TypeSynthesizer.hpp | 34 +- types/VarCharType.hpp | 2 +- types/YearMonthIntervalType.hpp | 2 +- types/containers/CMakeLists.txt | 1 + types/containers/ColumnVector.cpp | 43 +- types/containers/ColumnVector.hpp | 124 +++- types/containers/ColumnVectorUtil.hpp | 6 +- types/containers/ColumnVectorsValueAccessor.hpp | 41 +- types/operations/CMakeLists.txt | 5 +- types/operations/OperationFactory.cpp | 160 - types/operations/OperationFactory.hpp | 138 ++-- .../ArithmeticBinaryFunctors.hpp| 2 +- .../AsciiStringBinaryFunctors.hpp | 24 +- .../BinaryOperationSynthesizer.hpp | 660 +++ .../BinaryOperationWrapper.hpp | 629 -- .../operations/binary_operations/CMakeLists.txt | 15 +- .../binary_operations/CMathBinaryFunctors.hpp | 2 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../comparisons/LiteralComparators-inl.hpp | 10 +- .../ArithmeticUnaryFunctors.hpp | 2 +- .../AsciiStringUnaryFunctors.hpp| 2 +- .../operations/unary_operations/CMakeLists.txt | 29 +- .../unary_operations/CMathUnaryFunctors.hpp | 2 +- .../unary_operations/CastFunctorOverloads.hpp | 195 +++--- .../unary_operations/CastOperation.cpp | 6 +- .../unary_operations/CastOperation.hpp | 4 +- .../unary_operations/DateExtractOperation.cpp | 20 +- .../UnaryOperationSynthesizer.hpp | 273 .../unary_operations/UnaryOperationWrapper.hpp | 250 --- types/operations/utility/CMakeLists.txt | 11 +- types/operations/utility/CastUtil.cpp | 66 ++ types/operations/utility/CastUtil.hpp | 50 ++ .../utility/OperationSynthesizeUtil.hpp | 184 +- utility/Cast.hpp| 7 +- utility/met
[02/38] incubator-quickstep git commit: Updates to casts
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4bf0857c/types/operations/OperationFactory.cpp -- diff --git a/types/operations/OperationFactory.cpp b/types/operations/OperationFactory.cpp index 74cc3c1..df536ed 100644 --- a/types/operations/OperationFactory.cpp +++ b/types/operations/OperationFactory.cpp @@ -33,7 +33,7 @@ #include "types/operations/OperationSignature.hpp" #include "types/operations/binary_operations/ArithmeticBinaryFunctors.hpp" #include "types/operations/binary_operations/AsciiStringBinaryFunctors.hpp" -#include "types/operations/binary_operations/BinaryOperationWrapper.hpp" +#include "types/operations/binary_operations/BinaryOperationSynthesizer.hpp" #include "types/operations/binary_operations/CMathBinaryFunctors.hpp" #include "types/operations/unary_operations/ArithmeticUnaryFunctors.hpp" #include "types/operations/unary_operations/AsciiStringUnaryFunctors.hpp" @@ -41,9 +41,11 @@ #include "types/operations/unary_operations/CastOperation.hpp" #include "types/operations/unary_operations/DateExtractOperation.hpp" #include "types/operations/unary_operations/SubstringOperation.hpp" -#include "types/operations/unary_operations/UnaryOperationWrapper.hpp" +#include "types/operations/unary_operations/UnaryOperationSynthesizer.hpp" #include "utility/StringUtil.hpp" +#include "glog/logging.h" + namespace quickstep { namespace { @@ -52,13 +54,13 @@ struct FunctorPackDispatcher { template inline static std::list Generate( std::enable_if_t* = 0) { -return { std::make_shared>() }; +return { std::make_shared>() }; } template inline static std::list Generate( std::enable_if_t* = 0) { -return { std::make_shared>() }; +return { std::make_shared>() }; } template @@ -94,6 +96,98 @@ OperationFactory::OperationFactory() { registerFunctorPack(); } +bool OperationFactory::HasOperation(const std::string &operation_name, +const std::size_t arity) { + const auto &primary_index = Instance().primary_index_; + const auto indices_it = + primary_index.find(std::make_pair(operation_name, arity)); + return indices_it != primary_index.end(); +} + +bool OperationFactory::HasOperation(const OperationSignaturePtr &op_signature) { + const auto &operations = Instance().operations_; + return operations.find(op_signature) != operations.end(); +} + +bool OperationFactory::CanApplyUnaryOperation( +const std::string &operation_name, +const Type &type, +const std::vector &static_arguments) { + std::vector argument_type_ids = {type.getTypeID()}; + std::vector static_tv_arguments; + for (const auto &value : static_arguments) { +argument_type_ids.emplace_back(value.getTypeID()); +// TODO(refactor-type): Remove this. +static_tv_arguments.emplace_back(value.toTypedValue()); + } + const OperationSignaturePtr op_signature = + OperationSignature::Create( + operation_name, argument_type_ids, static_arguments.size()); + if (!HasOperation(op_signature)) { +return false; + } + return GetUnaryOperation(op_signature)->canApplyTo(type, static_tv_arguments); +} + +bool OperationFactory::CanApplyBinaryOperation( +const std::string &operation_name, +const Type &left, const Type &right, +const std::vector &static_arguments) { + std::vector argument_type_ids = {left.getTypeID(), right.getTypeID()}; + std::vector static_tv_arguments; + for (const auto &value : static_arguments) { +argument_type_ids.emplace_back(value.getTypeID()); +// TODO(refactor-type): Remove this. +static_tv_arguments.emplace_back(value.toTypedValue()); + } + // TODO(refactor-type): Handle this. + DCHECK_EQ(0u, static_arguments.size()); + const OperationSignaturePtr op_signature = + OperationSignature::Create( + operation_name, argument_type_ids, static_arguments.size()); + if (!HasOperation(op_signature)) { +return false; + } + return GetBinaryOperation(op_signature)->canApplyTo(left, right, static_tv_arguments); +} + +OperationPtr OperationFactory::GetOperation( +const OperationSignaturePtr &op_signature) { + DCHECK(HasOperation(op_signature)); + return Instance().operations_.at(op_signature); +} + + +UnaryOperationPtr OperationFactory::GetUnaryOperation( +const OperationSignaturePtr &op_signature) { + const OperationPtr operation = GetOperation(op_signature); + DCHECK(operation->getOperationSuperTypeID() == Operation::kUnaryOperation); + return std::static_pointer_cast(operation); +} + +BinaryOperationPtr OperationFactory::GetBinaryOperation( +const OperationSignaturePtr &op_signature) { + const OperationPtr operation = GetOperation(op_signature); + DCHECK(operation->getOperationSuperTypeID() == Operation::kBinaryOperation); + return std::static_pointer_cast(operation); +} + +OperationSignaturePtr OperationFactory::ResolveOperation( +const std
[28/38] incubator-quickstep git commit: Updates to meta type
Updates to meta type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/eb156fdf Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/eb156fdf Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/eb156fdf Branch: refs/heads/refactor-type Commit: eb156fdfa286a6a40644421ddecb6101914fab4a Parents: 0780fa2 Author: Jianqiao Zhu Authored: Tue Oct 3 01:52:29 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 10 13:24:03 2017 -0500 -- types/ArrayType.cpp | 29 +++ types/ArrayType.hpp | 7 +++- types/CMakeLists.txt | 22 ++-- types/MetaType.cpp| 36 --- types/MetaType.hpp| 44 +-- types/MetaTypeLite.cpp| 52 +++ types/MetaTypeLite.hpp| 72 ++ types/ParameterizedPodLit.hpp | 0 types/Type.proto | 4 +++ types/TypeSynthesizer.hpp | 8 ++--- types/TypedValue.cpp | 15 ++-- 11 files changed, 200 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/eb156fdf/types/ArrayType.cpp -- diff --git a/types/ArrayType.cpp b/types/ArrayType.cpp index c0f3a87..df2b9de 100644 --- a/types/ArrayType.cpp +++ b/types/ArrayType.cpp @@ -19,14 +19,43 @@ #include "types/ArrayType.hpp" +#include #include +#include "types/Type.pb.h" #include "types/TypeID.hpp" #include "glog/logging.h" namespace quickstep { +TypedValue ArrayType::marshallValue(const UntypedLiteral *value) const { + const ArrayLiteral &array = *static_cast(value); + serialization::ArrayLiteral proto; + for (const auto &element : array) { +// TODO(refactor-type): Improve performance. +TypedValue value = element_type_.marshallValue(element); +proto.add_data(value.getDataPtr(), value.getDataSize()); + } + const std::size_t data_size = proto.ByteSize(); + void *data = std::malloc(data_size); + proto.SerializeToArray(data, data_size); + return TypedValue::CreateWithOwnedData(kArray, data, data_size); +} + +UntypedLiteral* ArrayType::unmarshallValue(const void *data, + const std::size_t data_size) const { + std::unique_ptr array = std::make_unique(); + serialization::ArrayLiteral proto; + proto.ParseFromArray(data, data_size); + for (int i = 0; i < proto.data_size(); ++i) { +const std::string &element_data = proto.data(i); +array->emplace_back( +element_type_.unmarshallValue(element_data.c_str(), element_data.size())); + } + return array.release(); +} + std::string ArrayType::printValueToString(const UntypedLiteral *value) const { DCHECK(value != nullptr); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/eb156fdf/types/ArrayType.hpp -- diff --git a/types/ArrayType.hpp b/types/ArrayType.hpp index fe81c3e..a48cfa3 100644 --- a/types/ArrayType.hpp +++ b/types/ArrayType.hpp @@ -44,6 +44,11 @@ class ArrayType : public TypeSynthesizer { return 16; } + TypedValue marshallValue(const UntypedLiteral *value) const override; + + UntypedLiteral* unmarshallValue(const void *data, + const std::size_t length) const override; + std::string printValueToString(const UntypedLiteral *value) const override; bool parseTypedValueFromString(const std::string &value_string, @@ -63,7 +68,7 @@ class ArrayType : public TypeSynthesizer { DCHECK_EQ(1u, parameters.size()); const GenericValue &value = parameters.front(); DCHECK(value.getType().getTypeID() == kMetaType); -return *static_cast(value.getValue()); +return **static_cast(value.getValue()); } const Type &element_type_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/eb156fdf/types/CMakeLists.txt -- diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index 07f9d97..69ac906 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -49,13 +49,13 @@ add_library(quickstep_types_IntervalLit ../empty_src.cpp IntervalLit.hpp) add_library(quickstep_types_IntervalParser IntervalParser.cpp IntervalParser.hpp) add_library(quickstep_types_LongType LongType.cpp LongType.hpp) add_library(quickstep_types_MetaType MetaType.cpp MetaType.hpp) +add_library(quickstep_types_MetaTypeLite MetaTypeLite.cpp MetaTypeLite.hpp) add_library(quickstep_types_NullCoercibilityCheckMacro ../empty_src.cpp NullCoercibilityCheckMacro.hpp) add_library(quickstep_types_NullLit ../empty_src.cpp NullLit.hpp) add_library(qu
[05/38] incubator-quickstep git commit: Updates for array type
Updates for array type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0780fa2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0780fa2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0780fa2e Branch: refs/heads/refactor-type Commit: 0780fa2e29fa70fb8ad8c8fc03f4ee3913bc5d7b Parents: a7ccb46 Author: Jianqiao Zhu Authored: Mon Oct 2 23:46:48 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 10 13:24:03 2017 -0500 -- query_optimizer/expressions/CMakeLists.txt| 1 + query_optimizer/expressions/ScalarLiteral.hpp | 3 +- query_optimizer/resolver/CMakeLists.txt | 4 + query_optimizer/resolver/Resolver.cpp | 70 ++- types/GenericValue.hpp| 18 +- types/Type.cpp| 18 + types/Type.hpp| 23 +- types/Type.proto | 2 +- types/TypeSynthesizer.hpp | 479 - utility/CharStream.hpp| 34 +- utility/meta/Common.hpp | 58 ++- validate_cmakelists.py| 8 +- 12 files changed, 450 insertions(+), 268 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0780fa2e/query_optimizer/expressions/CMakeLists.txt -- diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt index dc722e7..cf2727f 100644 --- a/query_optimizer/expressions/CMakeLists.txt +++ b/query_optimizer/expressions/CMakeLists.txt @@ -97,6 +97,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_BinaryExpression quickstep_queryoptimizer_expressions_PatternMatcher quickstep_queryoptimizer_expressions_Scalar quickstep_queryoptimizer_expressions_ScalarLiteral + quickstep_types_GenericValue quickstep_types_operations_OperationSignature quickstep_types_operations_binaryoperations_BinaryOperation quickstep_utility_HashPair http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0780fa2e/query_optimizer/expressions/ScalarLiteral.hpp -- diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/ScalarLiteral.hpp index 180ae39..f6a14f4 100644 --- a/query_optimizer/expressions/ScalarLiteral.hpp +++ b/query_optimizer/expressions/ScalarLiteral.hpp @@ -108,7 +108,8 @@ class ScalarLiteral : public Scalar { ScalarLiteral(const GenericValue &literal_value) : value_(literal_value) {} - const GenericValue &value_; + const GenericValue value_; + DISALLOW_COPY_AND_ASSIGN(ScalarLiteral); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0780fa2e/query_optimizer/resolver/CMakeLists.txt -- diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt index a759ce3..8a1116a 100644 --- a/query_optimizer/resolver/CMakeLists.txt +++ b/query_optimizer/resolver/CMakeLists.txt @@ -120,7 +120,11 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver quickstep_queryoptimizer_resolver_NameResolver quickstep_storage_StorageBlockLayout_proto quickstep_storage_StorageConstants + quickstep_types_ArrayType + quickstep_types_GenericValue quickstep_types_IntType + quickstep_types_MetaType + quickstep_types_NullType quickstep_types_Type quickstep_types_TypeUtil quickstep_types_TypedValue http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0780fa2e/query_optimizer/resolver/Resolver.cpp -- diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp index 1ed6b2e..d97bf63 100644 --- a/query_optimizer/resolver/Resolver.cpp +++ b/query_optimizer/resolver/Resolver.cpp @@ -115,8 +115,11 @@ #include "query_optimizer/resolver/NameResolver.hpp" #include "storage/StorageBlockLayout.pb.h" #include "storage/StorageConstants.hpp" +#include "types/ArrayType.hpp" #include "types/GenericValue.hpp" #include "types/IntType.hpp" +#include "types/MetaType.hpp" +#include "types/NullType.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeU
[39/40] incubator-quickstep git commit: Updates to meta type
Updates to meta type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/bae50bd9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/bae50bd9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/bae50bd9 Branch: refs/heads/new-op Commit: bae50bd9fe4cdf2200260059c44cfb6d103006f9 Parents: b85b5d5 Author: Jianqiao Zhu Authored: Tue Oct 3 01:52:29 2017 -0500 Committer: Jianqiao Zhu Committed: Thu Oct 5 17:03:11 2017 -0500 -- types/ArrayType.cpp | 29 +++ types/ArrayType.hpp | 7 +++- types/CMakeLists.txt | 22 ++-- types/MetaType.cpp| 36 --- types/MetaType.hpp| 44 +-- types/MetaTypeLite.cpp| 52 +++ types/MetaTypeLite.hpp| 72 ++ types/ParameterizedPodLit.hpp | 0 types/Type.proto | 4 +++ types/TypeSynthesizer.hpp | 8 ++--- types/TypedValue.cpp | 15 ++-- 11 files changed, 200 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bae50bd9/types/ArrayType.cpp -- diff --git a/types/ArrayType.cpp b/types/ArrayType.cpp index c0f3a87..df2b9de 100644 --- a/types/ArrayType.cpp +++ b/types/ArrayType.cpp @@ -19,14 +19,43 @@ #include "types/ArrayType.hpp" +#include #include +#include "types/Type.pb.h" #include "types/TypeID.hpp" #include "glog/logging.h" namespace quickstep { +TypedValue ArrayType::marshallValue(const UntypedLiteral *value) const { + const ArrayLiteral &array = *static_cast(value); + serialization::ArrayLiteral proto; + for (const auto &element : array) { +// TODO(refactor-type): Improve performance. +TypedValue value = element_type_.marshallValue(element); +proto.add_data(value.getDataPtr(), value.getDataSize()); + } + const std::size_t data_size = proto.ByteSize(); + void *data = std::malloc(data_size); + proto.SerializeToArray(data, data_size); + return TypedValue::CreateWithOwnedData(kArray, data, data_size); +} + +UntypedLiteral* ArrayType::unmarshallValue(const void *data, + const std::size_t data_size) const { + std::unique_ptr array = std::make_unique(); + serialization::ArrayLiteral proto; + proto.ParseFromArray(data, data_size); + for (int i = 0; i < proto.data_size(); ++i) { +const std::string &element_data = proto.data(i); +array->emplace_back( +element_type_.unmarshallValue(element_data.c_str(), element_data.size())); + } + return array.release(); +} + std::string ArrayType::printValueToString(const UntypedLiteral *value) const { DCHECK(value != nullptr); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bae50bd9/types/ArrayType.hpp -- diff --git a/types/ArrayType.hpp b/types/ArrayType.hpp index fe81c3e..a48cfa3 100644 --- a/types/ArrayType.hpp +++ b/types/ArrayType.hpp @@ -44,6 +44,11 @@ class ArrayType : public TypeSynthesizer { return 16; } + TypedValue marshallValue(const UntypedLiteral *value) const override; + + UntypedLiteral* unmarshallValue(const void *data, + const std::size_t length) const override; + std::string printValueToString(const UntypedLiteral *value) const override; bool parseTypedValueFromString(const std::string &value_string, @@ -63,7 +68,7 @@ class ArrayType : public TypeSynthesizer { DCHECK_EQ(1u, parameters.size()); const GenericValue &value = parameters.front(); DCHECK(value.getType().getTypeID() == kMetaType); -return *static_cast(value.getValue()); +return **static_cast(value.getValue()); } const Type &element_type_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bae50bd9/types/CMakeLists.txt -- diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index 07f9d97..69ac906 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -49,13 +49,13 @@ add_library(quickstep_types_IntervalLit ../empty_src.cpp IntervalLit.hpp) add_library(quickstep_types_IntervalParser IntervalParser.cpp IntervalParser.hpp) add_library(quickstep_types_LongType LongType.cpp LongType.hpp) add_library(quickstep_types_MetaType MetaType.cpp MetaType.hpp) +add_library(quickstep_types_MetaTypeLite MetaTypeLite.cpp MetaTypeLite.hpp) add_library(quickstep_types_NullCoercibilityCheckMacro ../empty_src.cpp NullCoercibilityCheckMacro.hpp) add_library(quickstep_types_NullLit ../empty_src.cpp NullLit.hpp) add_library(quickstep_
[21/40] incubator-quickstep git commit: Updates for adding generic types
Updates for adding generic types Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/fc8a44ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/fc8a44ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/fc8a44ce Branch: refs/heads/new-op Commit: fc8a44ce0491f6ed3ab1887e38e4582140afa67c Parents: b314128 Author: Jianqiao Zhu Authored: Mon Oct 2 00:26:05 2017 -0500 Committer: Jianqiao Zhu Committed: Thu Oct 5 17:03:11 2017 -0500 -- cli/PrintToScreen.cpp | 2 +- compression/CompressionDictionaryBuilder.cpp| 3 +- compression/CompressionDictionaryBuilder.hpp| 6 +- .../aggregation/AggregationHandleAvg.hpp| 8 +- .../aggregation/AggregationHandleMax.hpp| 6 +- .../aggregation/AggregationHandleMin.hpp| 6 +- .../aggregation/AggregationHandleSum.hpp| 7 +- expressions/scalar/ScalarBinaryExpression.cpp | 2 +- expressions/scalar/ScalarCaseExpression.cpp | 2 +- expressions/scalar/ScalarLiteral.cpp| 2 +- expressions/scalar/ScalarUnaryExpression.cpp| 2 +- parser/ParseLiteralValue.cpp| 2 +- parser/SqlLexer.lpp | 2 + parser/SqlParser.ypp| 2 + query_optimizer/expressions/ScalarLiteral.cpp | 2 +- query_optimizer/resolver/Resolver.cpp | 10 +- relational_operators/TableExportOperator.cpp| 2 +- storage/LinearOpenAddressingHashTable.hpp | 18 +- storage/SeparateChainingHashTable.hpp | 18 +- .../SimpleScalarSeparateChainingHashTable.hpp | 18 +- storage/TupleStorageSubBlock.cpp| 3 +- types/ArrayType.cpp | 46 +++ types/ArrayType.hpp | 78 + types/AsciiStringSuperType.hpp | 2 +- types/BoolType.cpp | 12 +- types/BoolType.hpp | 8 +- types/CMakeLists.txt| 4 + types/CharType.cpp | 12 +- types/CharType.hpp | 10 +- types/DateType.cpp | 6 +- types/DateType.hpp | 6 +- types/DatetimeIntervalType.cpp | 6 +- types/DatetimeIntervalType.hpp | 6 +- types/DatetimeType.cpp | 6 +- types/DatetimeType.hpp | 6 +- types/DoubleType.cpp| 12 +- types/DoubleType.hpp| 8 +- types/FloatType.cpp | 12 +- types/FloatType.hpp | 8 +- types/GenericValue.cpp | 0 types/GenericValue.hpp | 118 +++ types/IntType.cpp | 12 +- types/IntType.hpp | 8 +- types/LongType.cpp | 12 +- types/LongType.hpp | 8 +- types/MetaType.cpp | 36 +++ types/MetaType.hpp | 67 types/NullType.hpp | 14 +- types/NumericSuperType.hpp | 5 +- types/ParameterizedPodLit.hpp | 0 types/Type.cpp | 2 +- types/Type.hpp | 103 +++--- types/Type.proto| 5 + types/TypeFactory.cpp | 5 +- types/TypeID.cpp| 2 + types/TypeID.hpp| 32 +- types/TypeIDSelectors.hpp | 62 ++-- types/TypeRegistrar.hpp | 81 +++-- types/TypeSynthesizer.hpp | 314 --- types/TypeUtil.hpp | 4 +- types/TypedValue.hpp| 22 ++ types/VarCharType.cpp | 12 +- types/VarCharType.hpp | 10 +- types/YearMonthIntervalType.cpp | 6 +- types/YearMonthIntervalType.hpp | 6 +- types/containers/ColumnVector.hpp | 24 +- types/operations/OperationUtil.hpp | 12 +- .../BinaryOperationWrapper.hpp | 6 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../unary_operations/CastOperation.cpp | 10 +- .../unary_operations/UnaryOperationWrapper.hpp | 2 +- utility/CMakeLists.txt | 7 +- utility/CharStream.hpp | 106 +++ 73 files changed, 1154 insertions(+), 353 deletions(-) --
[12/40] incubator-quickstep git commit: Updates for array type
Updates for array type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/b85b5d5c Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b85b5d5c Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b85b5d5c Branch: refs/heads/new-op Commit: b85b5d5c61cb1ca3fed92c93c60cf0e553edf667 Parents: 05496b9 Author: Jianqiao Zhu Authored: Mon Oct 2 23:46:48 2017 -0500 Committer: Jianqiao Zhu Committed: Thu Oct 5 17:03:11 2017 -0500 -- query_optimizer/expressions/CMakeLists.txt| 1 + query_optimizer/expressions/ScalarLiteral.hpp | 3 +- query_optimizer/resolver/CMakeLists.txt | 4 + query_optimizer/resolver/Resolver.cpp | 70 ++- types/GenericValue.hpp| 18 +- types/Type.cpp| 18 + types/Type.hpp| 23 +- types/Type.proto | 2 +- types/TypeSynthesizer.hpp | 479 - utility/CharStream.hpp| 34 +- utility/meta/Common.hpp | 58 ++- validate_cmakelists.py| 8 +- 12 files changed, 450 insertions(+), 268 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b85b5d5c/query_optimizer/expressions/CMakeLists.txt -- diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt index dc722e7..cf2727f 100644 --- a/query_optimizer/expressions/CMakeLists.txt +++ b/query_optimizer/expressions/CMakeLists.txt @@ -97,6 +97,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_BinaryExpression quickstep_queryoptimizer_expressions_PatternMatcher quickstep_queryoptimizer_expressions_Scalar quickstep_queryoptimizer_expressions_ScalarLiteral + quickstep_types_GenericValue quickstep_types_operations_OperationSignature quickstep_types_operations_binaryoperations_BinaryOperation quickstep_utility_HashPair http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b85b5d5c/query_optimizer/expressions/ScalarLiteral.hpp -- diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/ScalarLiteral.hpp index 180ae39..f6a14f4 100644 --- a/query_optimizer/expressions/ScalarLiteral.hpp +++ b/query_optimizer/expressions/ScalarLiteral.hpp @@ -108,7 +108,8 @@ class ScalarLiteral : public Scalar { ScalarLiteral(const GenericValue &literal_value) : value_(literal_value) {} - const GenericValue &value_; + const GenericValue value_; + DISALLOW_COPY_AND_ASSIGN(ScalarLiteral); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b85b5d5c/query_optimizer/resolver/CMakeLists.txt -- diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt index a759ce3..8a1116a 100644 --- a/query_optimizer/resolver/CMakeLists.txt +++ b/query_optimizer/resolver/CMakeLists.txt @@ -120,7 +120,11 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver quickstep_queryoptimizer_resolver_NameResolver quickstep_storage_StorageBlockLayout_proto quickstep_storage_StorageConstants + quickstep_types_ArrayType + quickstep_types_GenericValue quickstep_types_IntType + quickstep_types_MetaType + quickstep_types_NullType quickstep_types_Type quickstep_types_TypeUtil quickstep_types_TypedValue http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b85b5d5c/query_optimizer/resolver/Resolver.cpp -- diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp index 1ed6b2e..d97bf63 100644 --- a/query_optimizer/resolver/Resolver.cpp +++ b/query_optimizer/resolver/Resolver.cpp @@ -115,8 +115,11 @@ #include "query_optimizer/resolver/NameResolver.hpp" #include "storage/StorageBlockLayout.pb.h" #include "storage/StorageConstants.hpp" +#include "types/ArrayType.hpp" #include "types/GenericValue.hpp" #include "types/IntType.hpp" +#include "types/MetaType.hpp" +#include "types/NullType.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeUtil.hpp"
[20/40] incubator-quickstep git commit: Updates for adding generic types
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fc8a44ce/types/TypeRegistrar.hpp -- diff --git a/types/TypeRegistrar.hpp b/types/TypeRegistrar.hpp index ffe2b7e..9e6c50b 100644 --- a/types/TypeRegistrar.hpp +++ b/types/TypeRegistrar.hpp @@ -20,13 +20,14 @@ #ifndef QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ #define QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ +#include #include #include +#include #include "types/DatetimeLit.hpp" #include "types/IntervalLit.hpp" #include "types/NullLit.hpp" -#include "types/Type.hpp" #include "types/TypeID.hpp" #include "types/TypeIDSelectors.hpp" #include "utility/meta/Common.hpp" @@ -39,6 +40,14 @@ namespace quickstep { * @{ */ +class Type; +class TypedValue; + +using UntypedLiteral = void; + +using ArrayLiteral = std::vector; +using MetaTypeLiteral = const Type*; + template struct TypeIDTrait; @@ -48,36 +57,40 @@ struct TypeIDTrait; typedef type_class TypeClass; \ typedef cpp_type cpptype; \ static constexpr TypeID kStaticTypeID = type_id; \ -static constexpr Type::SuperTypeID kStaticSuperTypeID = super_type_id; \ +static constexpr SuperTypeID kStaticSuperTypeID = super_type_id; \ static constexpr MemoryLayout kMemoryLayout = memory_layout; \ -static constexpr bool kIsParameterizedPod = \ -(memory_layout == kParNativePod || memory_layout == kParIndirectPod); \ +static constexpr bool kIsParPod = \ +(memory_layout == kParInlinePod || memory_layout == kParOutOfLinePod); \ }; -REGISTER_TYPE(BoolType, kBool, \ - Type::kNumeric, kCxxNativePod, bool); -REGISTER_TYPE(IntType, kInt, \ - Type::kNumeric, kCxxNativePod, int); -REGISTER_TYPE(LongType, kLong, \ - Type::kNumeric, kCxxNativePod, std::int64_t); -REGISTER_TYPE(FloatType, kFloat, \ - Type::kNumeric, kCxxNativePod, float); -REGISTER_TYPE(DoubleType, kDouble, \ - Type::kNumeric, kCxxNativePod, double); -REGISTER_TYPE(DateType, kDate, \ - Type::kOther, kCxxNativePod, DateLit); -REGISTER_TYPE(DatetimeType, kDatetime, \ - Type::kOther, kCxxNativePod, DatetimeLit); -REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, \ - Type::kOther, kCxxNativePod, DatetimeIntervalLit); -REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, \ - Type::kOther, kCxxNativePod, YearMonthIntervalLit); -REGISTER_TYPE(CharType, kChar, \ - Type::kAsciiString, kParNativePod, void); -REGISTER_TYPE(VarCharType, kVarChar, \ - Type::kAsciiString, kParIndirectPod, void); -REGISTER_TYPE(NullType, kNullType, \ - Type::kOther, kCxxNativePod, NullLit); +REGISTER_TYPE(BoolType, kBool, + SuperTypeID::kNumeric, kCxxInlinePod, bool); +REGISTER_TYPE(IntType, kInt, + SuperTypeID::kNumeric, kCxxInlinePod, int); +REGISTER_TYPE(LongType, kLong, + SuperTypeID::kNumeric, kCxxInlinePod, std::int64_t); +REGISTER_TYPE(FloatType, kFloat, + SuperTypeID::kNumeric, kCxxInlinePod, float); +REGISTER_TYPE(DoubleType, kDouble, + SuperTypeID::kNumeric, kCxxInlinePod, double); +REGISTER_TYPE(DateType, kDate, + SuperTypeID::kOther, kCxxInlinePod, DateLit); +REGISTER_TYPE(DatetimeType, kDatetime, + SuperTypeID::kOther, kCxxInlinePod, DatetimeLit); +REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, + SuperTypeID::kOther, kCxxInlinePod, DatetimeIntervalLit); +REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, + SuperTypeID::kOther, kCxxInlinePod, YearMonthIntervalLit); +REGISTER_TYPE(CharType, kChar, + SuperTypeID::kAsciiString, kParInlinePod, TypedValue); +REGISTER_TYPE(VarCharType, kVarChar, + SuperTypeID::kAsciiString, kParOutOfLinePod, TypedValue); +REGISTER_TYPE(ArrayType, kArray, + SuperTypeID::kOther, kCxxGeneric, ArrayLiteral); +REGISTER_TYPE(MetaType, kMetaType, + SuperTypeID::kOther, kCxxGeneric, MetaTypeLiteral); +REGISTER_TYPE(NullType, kNullType, + SuperTypeID::kOther, kCxxInlinePod, NullLit); #undef REGISTER_TYPE @@ -91,8 +104,8 @@ auto InvokeOnTypeID(const TypeID type_id, const FunctorT &functor); namespace internal { template -inline auto InvokeOnTypeIDInner(const int value, -const FunctorT &functor) { +inline auto InvokeOnTypeIDInternal(const int value, + const FunctorT &functor) { DCHECK_LE(l, r); if (l == r) { constexpr TypeID type_id = static_cast(r); @@ -101,9 +114,9 @@ inline auto InvokeOnTypeIDInner(const int value, } constexpr int m = (l + r) >> 1; if (value <= m) { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, functor); } else { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, funct
[42/51] [abbrv] incubator-quickstep git commit: Updates to meta type
Updates to meta type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9c0d636f Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9c0d636f Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9c0d636f Branch: refs/heads/new-op Commit: 9c0d636f2396a8c514bfc01bb870a5eb5122bdcc Parents: c4fab58 Author: Jianqiao Zhu Authored: Tue Oct 3 01:52:29 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 3 01:52:29 2017 -0500 -- types/ArrayType.cpp | 29 +++ types/ArrayType.hpp | 7 +++- types/CMakeLists.txt | 22 ++-- types/MetaType.cpp| 36 --- types/MetaType.hpp| 44 +-- types/MetaTypeLite.cpp| 52 +++ types/MetaTypeLite.hpp| 72 ++ types/ParameterizedPodLit.hpp | 0 types/Type.proto | 4 +++ types/TypeSynthesizer.hpp | 8 ++--- types/TypedValue.cpp | 15 ++-- 11 files changed, 200 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c0d636f/types/ArrayType.cpp -- diff --git a/types/ArrayType.cpp b/types/ArrayType.cpp index c0f3a87..df2b9de 100644 --- a/types/ArrayType.cpp +++ b/types/ArrayType.cpp @@ -19,14 +19,43 @@ #include "types/ArrayType.hpp" +#include #include +#include "types/Type.pb.h" #include "types/TypeID.hpp" #include "glog/logging.h" namespace quickstep { +TypedValue ArrayType::marshallValue(const UntypedLiteral *value) const { + const ArrayLiteral &array = *static_cast(value); + serialization::ArrayLiteral proto; + for (const auto &element : array) { +// TODO(refactor-type): Improve performance. +TypedValue value = element_type_.marshallValue(element); +proto.add_data(value.getDataPtr(), value.getDataSize()); + } + const std::size_t data_size = proto.ByteSize(); + void *data = std::malloc(data_size); + proto.SerializeToArray(data, data_size); + return TypedValue::CreateWithOwnedData(kArray, data, data_size); +} + +UntypedLiteral* ArrayType::unmarshallValue(const void *data, + const std::size_t data_size) const { + std::unique_ptr array = std::make_unique(); + serialization::ArrayLiteral proto; + proto.ParseFromArray(data, data_size); + for (int i = 0; i < proto.data_size(); ++i) { +const std::string &element_data = proto.data(i); +array->emplace_back( +element_type_.unmarshallValue(element_data.c_str(), element_data.size())); + } + return array.release(); +} + std::string ArrayType::printValueToString(const UntypedLiteral *value) const { DCHECK(value != nullptr); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c0d636f/types/ArrayType.hpp -- diff --git a/types/ArrayType.hpp b/types/ArrayType.hpp index fe81c3e..a48cfa3 100644 --- a/types/ArrayType.hpp +++ b/types/ArrayType.hpp @@ -44,6 +44,11 @@ class ArrayType : public TypeSynthesizer { return 16; } + TypedValue marshallValue(const UntypedLiteral *value) const override; + + UntypedLiteral* unmarshallValue(const void *data, + const std::size_t length) const override; + std::string printValueToString(const UntypedLiteral *value) const override; bool parseTypedValueFromString(const std::string &value_string, @@ -63,7 +68,7 @@ class ArrayType : public TypeSynthesizer { DCHECK_EQ(1u, parameters.size()); const GenericValue &value = parameters.front(); DCHECK(value.getType().getTypeID() == kMetaType); -return *static_cast(value.getValue()); +return **static_cast(value.getValue()); } const Type &element_type_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c0d636f/types/CMakeLists.txt -- diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index 07f9d97..69ac906 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -49,13 +49,13 @@ add_library(quickstep_types_IntervalLit ../empty_src.cpp IntervalLit.hpp) add_library(quickstep_types_IntervalParser IntervalParser.cpp IntervalParser.hpp) add_library(quickstep_types_LongType LongType.cpp LongType.hpp) add_library(quickstep_types_MetaType MetaType.cpp MetaType.hpp) +add_library(quickstep_types_MetaTypeLite MetaTypeLite.cpp MetaTypeLite.hpp) add_library(quickstep_types_NullCoercibilityCheckMacro ../empty_src.cpp NullCoercibilityCheckMacro.hpp) add_library(quickstep_types_NullLit ../empty_src.cpp NullLit.hpp) add_library(quickstep_
[41/51] [abbrv] incubator-quickstep git commit: Updates for array type
Updates for array type Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/c4fab58b Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/c4fab58b Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/c4fab58b Branch: refs/heads/new-op Commit: c4fab58bd92b65ff1f977b348f6584f373ff8e82 Parents: d75334b Author: Jianqiao Zhu Authored: Mon Oct 2 23:46:48 2017 -0500 Committer: Jianqiao Zhu Committed: Mon Oct 2 23:46:48 2017 -0500 -- query_optimizer/expressions/CMakeLists.txt| 1 + query_optimizer/expressions/ScalarLiteral.hpp | 3 +- query_optimizer/resolver/CMakeLists.txt | 4 + query_optimizer/resolver/Resolver.cpp | 70 ++- types/GenericValue.hpp| 18 +- types/Type.cpp| 18 + types/Type.hpp| 23 +- types/Type.proto | 2 +- types/TypeSynthesizer.hpp | 479 - utility/CharStream.hpp| 34 +- utility/meta/Common.hpp | 58 ++- validate_cmakelists.py| 8 +- 12 files changed, 450 insertions(+), 268 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4fab58b/query_optimizer/expressions/CMakeLists.txt -- diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt index dc722e7..cf2727f 100644 --- a/query_optimizer/expressions/CMakeLists.txt +++ b/query_optimizer/expressions/CMakeLists.txt @@ -97,6 +97,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_BinaryExpression quickstep_queryoptimizer_expressions_PatternMatcher quickstep_queryoptimizer_expressions_Scalar quickstep_queryoptimizer_expressions_ScalarLiteral + quickstep_types_GenericValue quickstep_types_operations_OperationSignature quickstep_types_operations_binaryoperations_BinaryOperation quickstep_utility_HashPair http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4fab58b/query_optimizer/expressions/ScalarLiteral.hpp -- diff --git a/query_optimizer/expressions/ScalarLiteral.hpp b/query_optimizer/expressions/ScalarLiteral.hpp index 180ae39..f6a14f4 100644 --- a/query_optimizer/expressions/ScalarLiteral.hpp +++ b/query_optimizer/expressions/ScalarLiteral.hpp @@ -108,7 +108,8 @@ class ScalarLiteral : public Scalar { ScalarLiteral(const GenericValue &literal_value) : value_(literal_value) {} - const GenericValue &value_; + const GenericValue value_; + DISALLOW_COPY_AND_ASSIGN(ScalarLiteral); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4fab58b/query_optimizer/resolver/CMakeLists.txt -- diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt index a759ce3..8a1116a 100644 --- a/query_optimizer/resolver/CMakeLists.txt +++ b/query_optimizer/resolver/CMakeLists.txt @@ -120,7 +120,11 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver quickstep_queryoptimizer_resolver_NameResolver quickstep_storage_StorageBlockLayout_proto quickstep_storage_StorageConstants + quickstep_types_ArrayType + quickstep_types_GenericValue quickstep_types_IntType + quickstep_types_MetaType + quickstep_types_NullType quickstep_types_Type quickstep_types_TypeUtil quickstep_types_TypedValue http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4fab58b/query_optimizer/resolver/Resolver.cpp -- diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp index 1ed6b2e..d97bf63 100644 --- a/query_optimizer/resolver/Resolver.cpp +++ b/query_optimizer/resolver/Resolver.cpp @@ -115,8 +115,11 @@ #include "query_optimizer/resolver/NameResolver.hpp" #include "storage/StorageBlockLayout.pb.h" #include "storage/StorageConstants.hpp" +#include "types/ArrayType.hpp" #include "types/GenericValue.hpp" #include "types/IntType.hpp" +#include "types/MetaType.hpp" +#include "types/NullType.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeUtil.hpp"
[33/51] [abbrv] incubator-quickstep git commit: Updates for adding generic types
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a3b2cf1/types/TypeRegistrar.hpp -- diff --git a/types/TypeRegistrar.hpp b/types/TypeRegistrar.hpp index ffe2b7e..9e6c50b 100644 --- a/types/TypeRegistrar.hpp +++ b/types/TypeRegistrar.hpp @@ -20,13 +20,14 @@ #ifndef QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ #define QUICKSTEP_TYPES_TYPE_REGISTRAR_HPP_ +#include #include #include +#include #include "types/DatetimeLit.hpp" #include "types/IntervalLit.hpp" #include "types/NullLit.hpp" -#include "types/Type.hpp" #include "types/TypeID.hpp" #include "types/TypeIDSelectors.hpp" #include "utility/meta/Common.hpp" @@ -39,6 +40,14 @@ namespace quickstep { * @{ */ +class Type; +class TypedValue; + +using UntypedLiteral = void; + +using ArrayLiteral = std::vector; +using MetaTypeLiteral = const Type*; + template struct TypeIDTrait; @@ -48,36 +57,40 @@ struct TypeIDTrait; typedef type_class TypeClass; \ typedef cpp_type cpptype; \ static constexpr TypeID kStaticTypeID = type_id; \ -static constexpr Type::SuperTypeID kStaticSuperTypeID = super_type_id; \ +static constexpr SuperTypeID kStaticSuperTypeID = super_type_id; \ static constexpr MemoryLayout kMemoryLayout = memory_layout; \ -static constexpr bool kIsParameterizedPod = \ -(memory_layout == kParNativePod || memory_layout == kParIndirectPod); \ +static constexpr bool kIsParPod = \ +(memory_layout == kParInlinePod || memory_layout == kParOutOfLinePod); \ }; -REGISTER_TYPE(BoolType, kBool, \ - Type::kNumeric, kCxxNativePod, bool); -REGISTER_TYPE(IntType, kInt, \ - Type::kNumeric, kCxxNativePod, int); -REGISTER_TYPE(LongType, kLong, \ - Type::kNumeric, kCxxNativePod, std::int64_t); -REGISTER_TYPE(FloatType, kFloat, \ - Type::kNumeric, kCxxNativePod, float); -REGISTER_TYPE(DoubleType, kDouble, \ - Type::kNumeric, kCxxNativePod, double); -REGISTER_TYPE(DateType, kDate, \ - Type::kOther, kCxxNativePod, DateLit); -REGISTER_TYPE(DatetimeType, kDatetime, \ - Type::kOther, kCxxNativePod, DatetimeLit); -REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, \ - Type::kOther, kCxxNativePod, DatetimeIntervalLit); -REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, \ - Type::kOther, kCxxNativePod, YearMonthIntervalLit); -REGISTER_TYPE(CharType, kChar, \ - Type::kAsciiString, kParNativePod, void); -REGISTER_TYPE(VarCharType, kVarChar, \ - Type::kAsciiString, kParIndirectPod, void); -REGISTER_TYPE(NullType, kNullType, \ - Type::kOther, kCxxNativePod, NullLit); +REGISTER_TYPE(BoolType, kBool, + SuperTypeID::kNumeric, kCxxInlinePod, bool); +REGISTER_TYPE(IntType, kInt, + SuperTypeID::kNumeric, kCxxInlinePod, int); +REGISTER_TYPE(LongType, kLong, + SuperTypeID::kNumeric, kCxxInlinePod, std::int64_t); +REGISTER_TYPE(FloatType, kFloat, + SuperTypeID::kNumeric, kCxxInlinePod, float); +REGISTER_TYPE(DoubleType, kDouble, + SuperTypeID::kNumeric, kCxxInlinePod, double); +REGISTER_TYPE(DateType, kDate, + SuperTypeID::kOther, kCxxInlinePod, DateLit); +REGISTER_TYPE(DatetimeType, kDatetime, + SuperTypeID::kOther, kCxxInlinePod, DatetimeLit); +REGISTER_TYPE(DatetimeIntervalType, kDatetimeInterval, + SuperTypeID::kOther, kCxxInlinePod, DatetimeIntervalLit); +REGISTER_TYPE(YearMonthIntervalType, kYearMonthInterval, + SuperTypeID::kOther, kCxxInlinePod, YearMonthIntervalLit); +REGISTER_TYPE(CharType, kChar, + SuperTypeID::kAsciiString, kParInlinePod, TypedValue); +REGISTER_TYPE(VarCharType, kVarChar, + SuperTypeID::kAsciiString, kParOutOfLinePod, TypedValue); +REGISTER_TYPE(ArrayType, kArray, + SuperTypeID::kOther, kCxxGeneric, ArrayLiteral); +REGISTER_TYPE(MetaType, kMetaType, + SuperTypeID::kOther, kCxxGeneric, MetaTypeLiteral); +REGISTER_TYPE(NullType, kNullType, + SuperTypeID::kOther, kCxxInlinePod, NullLit); #undef REGISTER_TYPE @@ -91,8 +104,8 @@ auto InvokeOnTypeID(const TypeID type_id, const FunctorT &functor); namespace internal { template -inline auto InvokeOnTypeIDInner(const int value, -const FunctorT &functor) { +inline auto InvokeOnTypeIDInternal(const int value, + const FunctorT &functor) { DCHECK_LE(l, r); if (l == r) { constexpr TypeID type_id = static_cast(r); @@ -101,9 +114,9 @@ inline auto InvokeOnTypeIDInner(const int value, } constexpr int m = (l + r) >> 1; if (value <= m) { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, functor); } else { -return InvokeOnTypeIDInner(value, functor); +return InvokeOnTypeIDInternal(value, funct
[34/51] [abbrv] incubator-quickstep git commit: Updates for adding generic types
Updates for adding generic types Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8a3b2cf1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8a3b2cf1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8a3b2cf1 Branch: refs/heads/new-op Commit: 8a3b2cf1a39976ed8f951bd2f8eaab755510d9eb Parents: 4ea8483 Author: Jianqiao Zhu Authored: Mon Oct 2 00:26:05 2017 -0500 Committer: Jianqiao Zhu Committed: Mon Oct 2 00:26:05 2017 -0500 -- cli/PrintToScreen.cpp | 2 +- compression/CompressionDictionaryBuilder.cpp| 3 +- compression/CompressionDictionaryBuilder.hpp| 6 +- .../aggregation/AggregationHandleAvg.hpp| 8 +- .../aggregation/AggregationHandleMax.hpp| 6 +- .../aggregation/AggregationHandleMin.hpp| 6 +- .../aggregation/AggregationHandleSum.hpp| 7 +- expressions/scalar/ScalarBinaryExpression.cpp | 2 +- expressions/scalar/ScalarCaseExpression.cpp | 2 +- expressions/scalar/ScalarLiteral.cpp| 2 +- expressions/scalar/ScalarUnaryExpression.cpp| 2 +- parser/ParseLiteralValue.cpp| 2 +- parser/SqlLexer.lpp | 2 + parser/SqlParser.ypp| 2 + query_optimizer/expressions/ScalarLiteral.cpp | 2 +- query_optimizer/resolver/Resolver.cpp | 10 +- relational_operators/TableExportOperator.cpp| 2 +- storage/LinearOpenAddressingHashTable.hpp | 18 +- storage/SeparateChainingHashTable.hpp | 18 +- .../SimpleScalarSeparateChainingHashTable.hpp | 18 +- storage/TupleStorageSubBlock.cpp| 3 +- types/ArrayType.cpp | 46 +++ types/ArrayType.hpp | 78 + types/AsciiStringSuperType.hpp | 2 +- types/BoolType.cpp | 12 +- types/BoolType.hpp | 8 +- types/CMakeLists.txt| 4 + types/CharType.cpp | 12 +- types/CharType.hpp | 10 +- types/DateType.cpp | 6 +- types/DateType.hpp | 6 +- types/DatetimeIntervalType.cpp | 6 +- types/DatetimeIntervalType.hpp | 6 +- types/DatetimeType.cpp | 6 +- types/DatetimeType.hpp | 6 +- types/DoubleType.cpp| 12 +- types/DoubleType.hpp| 8 +- types/FloatType.cpp | 12 +- types/FloatType.hpp | 8 +- types/GenericValue.cpp | 0 types/GenericValue.hpp | 118 +++ types/IntType.cpp | 12 +- types/IntType.hpp | 8 +- types/LongType.cpp | 12 +- types/LongType.hpp | 8 +- types/MetaType.cpp | 36 +++ types/MetaType.hpp | 67 types/NullType.hpp | 14 +- types/NumericSuperType.hpp | 5 +- types/ParameterizedPodLit.hpp | 0 types/Type.cpp | 2 +- types/Type.hpp | 103 +++--- types/Type.proto| 5 + types/TypeFactory.cpp | 5 +- types/TypeID.cpp| 2 + types/TypeID.hpp| 32 +- types/TypeIDSelectors.hpp | 62 ++-- types/TypeRegistrar.hpp | 81 +++-- types/TypeSynthesizer.hpp | 314 --- types/TypeUtil.hpp | 4 +- types/TypedValue.hpp| 22 ++ types/VarCharType.cpp | 12 +- types/VarCharType.hpp | 10 +- types/YearMonthIntervalType.cpp | 6 +- types/YearMonthIntervalType.hpp | 6 +- types/containers/ColumnVector.hpp | 24 +- types/operations/OperationUtil.hpp | 12 +- .../BinaryOperationWrapper.hpp | 6 +- .../operations/comparisons/BasicComparison.hpp | 23 +- .../unary_operations/CastOperation.cpp | 10 +- .../unary_operations/UnaryOperationWrapper.hpp | 2 +- utility/CMakeLists.txt | 7 +- utility/CharStream.hpp | 106 +++ 73 files changed, 1154 insertions(+), 353 deletions(-) --
[2/6] incubator-quickstep git commit: Updates to API
Updates to API Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/718bb689 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/718bb689 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/718bb689 Branch: refs/heads/trace Commit: 718bb689bdb548c431c7e104b5f5eeda145f13d4 Parents: c29587a Author: Jianqiao Zhu Authored: Sat Sep 2 23:06:37 2017 -0500 Committer: jianqiao Committed: Mon Sep 18 14:30:30 2017 -0500 -- api/python/lineage.py | 16 1 file changed, 16 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/718bb689/api/python/lineage.py -- diff --git a/api/python/lineage.py b/api/python/lineage.py new file mode 100644 index 000..bd6db00 --- /dev/null +++ b/api/python/lineage.py @@ -0,0 +1,16 @@ +from quickstep import Quickstep + +qs = Quickstep('/Users/jianqiao/Desktop/incubator-quickstep/build/Debug/quickstep_client') + +vertices = [1299454, 31623412, 31739916, 31593563] + +# Truncate old tables. +qs.execute('DROP TABLE cur; DROP TABLE next; DROP TABLE answer;') +qs.execute('CREATE TABLE cur(id INT); CREATE TABLE next(id INT); CREATE TABLE answer(id INT);') + +stmts = '' +for v in vertices: + stmts += 'INSERT INTO cur VALUES(' + str(v) + '); ' +qs.execute(stmts) +qs.execute('INSERT INTO answer SELECT id FROM cur;') +
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/copy-to c7bd8c6d1 -> 9eae02253 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9eae0225 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9eae0225 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9eae0225 Branch: refs/heads/copy-to Commit: 9eae022534bbb52f784a084c27c9aee360b046d6 Parents: c7bd8c6 Author: Jianqiao Zhu Authored: Fri Aug 4 19:59:07 2017 -0500 Committer: Jianqiao Zhu Committed: Fri Aug 4 19:59:07 2017 -0500 -- parser/ParseKeyValue.hpp | 4 +-- parser/ParseStatement.hpp| 23 +- query_execution/QueryContext.hpp | 37 --- relational_operators/TableExportOperator.cpp | 4 +-- 4 files changed, 45 insertions(+), 23 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9eae0225/parser/ParseKeyValue.hpp -- diff --git a/parser/ParseKeyValue.hpp b/parser/ParseKeyValue.hpp index f2564b5..62cba7f 100644 --- a/parser/ParseKeyValue.hpp +++ b/parser/ParseKeyValue.hpp @@ -198,7 +198,7 @@ class ParseKeyStringList : public ParseKeyValue { }; /** - * @brief The parsed representation of a key-value pair. Value if of int type. + * @brief The parsed representation of a key-value pair. Value is of int type. **/ class ParseKeyIntegerValue : public ParseKeyValue { public: @@ -254,7 +254,7 @@ class ParseKeyIntegerValue : public ParseKeyValue { }; /** - * @brief The parsed representation of a key-value pair. Value if of bool type. + * @brief The parsed representation of a key-value pair. Value is of bool type. **/ class ParseKeyBoolValue : public ParseKeyValue { public: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9eae0225/parser/ParseStatement.hpp -- diff --git a/parser/ParseStatement.hpp b/parser/ParseStatement.hpp index 60b2a08..c984b92 100644 --- a/parser/ParseStatement.hpp +++ b/parser/ParseStatement.hpp @@ -783,7 +783,7 @@ class ParseStatementInsertSelection : public ParseStatementInsert { class ParseStatementCopy : public ParseStatement { public: /** - * @brief Copy direction (FROM/TO). + * @brief Copy direction (FROM text file/TO text file). */ enum CopyDirection { kFrom, @@ -797,7 +797,7 @@ class ParseStatementCopy : public ParseStatement { * @param column_number Column number of the first token of this node in the SQL statement. * @param direction The copy direction (FROM/TO). * @param relation_name The name of the relation. - * @param file_name The name of the text file. + * @param file_name The name of the file. * @param params The optional parameters of the COPY statement. **/ ParseStatementCopy(const int line_number, @@ -818,9 +818,9 @@ class ParseStatementCopy : public ParseStatement { * * @param line_number Line number of the first token of this node in the SQL statement. * @param column_number Column number of the first token of this node in the SQL statement. - * @param set_operation_query The set operation query + * @param set_operation_query The set operation query. * @param with_clause The WITH clause of common table query expressions. - * @param file_name The name of the text file. + * @param file_name The name of the file. * @param params The optional parameters of the COPY statement. **/ ParseStatementCopy(const int line_number, @@ -852,9 +852,9 @@ class ParseStatementCopy : public ParseStatement { } /** - * @brief Get the direction (FROM/TO) of the COPY statement. + * @brief Get the direction (FROM text file/TO text file) of the COPY statement. * - * return The direction (FROM/TO) of the COPY statement. + * return The direction of the COPY statement. */ const CopyDirection getCopyDirection() const { return direction_; @@ -899,8 +899,7 @@ class ParseStatementCopy : public ParseStatement { /** * @brief Get the additional COPY parameters. * - * @return The string which terminates individual attribute values in the - * input file. + * @return The additional COPY parameters. **/ const PtrList* params() const { return params_.get(); @@ -957,7 +956,15 @@ class ParseStatementCopy : public ParseStatement { std::unique_ptr set_operation_query_; std::unique_ptr> with_clause_; + + // NOTE(jianqiao): For convenience of represenation, the file_name_ string + // contains a prefix character of '$' or '@' before its actual value, where + // (1) '$' indicates that the name is a standard I/O stream, + // e.g. $
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression bd78194e6 -> e0d9f2fd3 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/e0d9f2fd Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/e0d9f2fd Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/e0d9f2fd Branch: refs/heads/common-subexpression Commit: e0d9f2fd358c2c65de19cb94d5699775b92a38be Parents: bd78194 Author: Jianqiao Zhu Authored: Fri Apr 21 16:44:37 2017 -0500 Committer: Jianqiao Zhu Committed: Fri Apr 21 16:44:37 2017 -0500 -- .../physical_generator/CommonSubexpression.test | 4 ++-- .../tests/physical_generator/Select.test| 16 2 files changed, 10 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e0d9f2fd/query_optimizer/tests/physical_generator/CommonSubexpression.test -- diff --git a/query_optimizer/tests/physical_generator/CommonSubexpression.test b/query_optimizer/tests/physical_generator/CommonSubexpression.test index 0d7ed3f..b23a97d 100644 --- a/query_optimizer/tests/physical_generator/CommonSubexpression.test +++ b/query_optimizer/tests/physical_generator/CommonSubexpression.test @@ -127,13 +127,13 @@ TopLevelPlan | | +-grouping_expressions= | | | +-[] | | +-aggregate_expressions= -| | +-Alias[id=6,name=,alias=$aggregate0,relation=,type=Double NULL] +| | +-Alias[id=6,name=,alias=$aggregate0,relation=$aggregate,type=Double NULL] | | | +-AggregateFunction[function=SUM] | | | +-CommonSubexpression[common_subexpression_id=8] | | | +-Operand=Add | | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL] | | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float] -| | +-Alias[id=7,name=,alias=$aggregate1,relation=,type=Float NULL] +| | +-Alias[id=7,name=,alias=$aggregate1,relation=$aggregate,type=Float NULL] | | +-AggregateFunction[function=MIN] | | +-Multiply | | +-CommonSubexpression[common_subexpression_id=8] http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e0d9f2fd/query_optimizer/tests/physical_generator/Select.test -- diff --git a/query_optimizer/tests/physical_generator/Select.test b/query_optimizer/tests/physical_generator/Select.test index de640f6..614347b 100644 --- a/query_optimizer/tests/physical_generator/Select.test +++ b/query_optimizer/tests/physical_generator/Select.test @@ -1044,7 +1044,7 @@ TopLevelPlan | | | +-Alias[id=8,name=,alias=$aggregate2,relation=$aggregate,type=Long NULL] | | | | +-AggregateFunction[function=SUM] | | | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long] -| | | +-Alias[id=12,name=,alias=$aggregate3,relation=,type=Long NULL] +| | | +-Alias[id=12,name=,alias=$aggregate3,relation=$aggregate,type=Long NULL] | | | | +-AggregateFunction[function=SUM] | | | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL] | | | +-Alias[id=11,name=,alias=$aggregate4,relation=$aggregate, @@ -1059,10 +1059,10 @@ TopLevelPlan | | | type=Long] | | +-AttributeReference[id=8,name=,alias=$aggregate2,relation=$aggregate, | | | type=Long NULL] -| | +-Alias[id=9,name=,alias=$aggregate3,relation=,type=Long NULL] +| | +-Alias[id=9,name=,alias=$aggregate3,relation=$aggregate,type=Long NULL] | | | +-Divide -| | | +-AttributeReference[id=12,name=,alias=$aggregate3,relation=, -| | | | type=Long NULL] +| | | +-AttributeReference[id=12,name=,alias=$aggregate3, +| | | | relation=$aggregate,type=Long NULL] | | | +-AttributeReference[id=7,name=,alias=$aggregate1,relation=$aggregate, | | | type=Long] | | +-AttributeReference[id=11,name=,alias=$aggregate4,relation=$aggregate, @@ -1325,7 +1325,7 @@ TopLevelPlan | | | +-Alias[id=4,name=subquery_col3,relation=subquery,type=Char(20)] | | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)] | | +-aggregate_expressions= -| | +-Alias[id=8,name=,alias=$aggregate0,relation=,type=Long] +| | +-Alias[id=8,name=,alias=$aggregate0,relation=$aggregate,type=Long] | | | +-AggregateFunction[function=COUNT] | | | +-Add | | | +-CommonSubexpression[common_subexpression_id=13] @@ -1338,7 +1338,7 @@ TopLevelPlan | | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long] | | | +-AttributeReference[id=2,name=float_col,relation=test, | | | type=Float] -| | +-Alias[id=9,name=,alias=$aggregate1,relation=,type=Long NULL] +| | +-Alias[id=9,name=,alias=$aggregate1,relation=$aggregate,
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression 9f48a4a70 -> bd78194e6 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/bd78194e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/bd78194e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/bd78194e Branch: refs/heads/common-subexpression Commit: bd78194e642fed44307d9fb90f0df036d9dadff5 Parents: 9f48a4a Author: Jianqiao Zhu Authored: Fri Apr 21 16:36:44 2017 -0500 Committer: Jianqiao Zhu Committed: Fri Apr 21 16:36:44 2017 -0500 -- query_optimizer/rules/ExtractCommonSubexpression.cpp | 3 ++- query_optimizer/rules/ReuseAggregateExpressions.cpp | 9 ++--- utility/HashError.hpp| 1 + 3 files changed, 9 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bd78194e/query_optimizer/rules/ExtractCommonSubexpression.cpp -- diff --git a/query_optimizer/rules/ExtractCommonSubexpression.cpp b/query_optimizer/rules/ExtractCommonSubexpression.cpp index 6bbd902..25bab89 100644 --- a/query_optimizer/rules/ExtractCommonSubexpression.cpp +++ b/query_optimizer/rules/ExtractCommonSubexpression.cpp @@ -145,7 +145,8 @@ P::PhysicalPtr ExtractCommonSubexpression::applyInternal( E::Alias::Create(expr->id(), new_func, expr->attribute_name(), - expr->attribute_alias())); + expr->attribute_alias(), + expr->relation_name())); } } return P::Aggregate::Create(aggregate->input(), http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bd78194e/query_optimizer/rules/ReuseAggregateExpressions.cpp -- diff --git a/query_optimizer/rules/ReuseAggregateExpressions.cpp b/query_optimizer/rules/ReuseAggregateExpressions.cpp index 7903605..dd54889 100644 --- a/query_optimizer/rules/ReuseAggregateExpressions.cpp +++ b/query_optimizer/rules/ReuseAggregateExpressions.cpp @@ -282,7 +282,8 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( E::Alias::Create(agg_expr->id(), agg_attrs[agg_ref->first_ref], agg_expr->attribute_name(), - agg_expr->attribute_alias())); + agg_expr->attribute_alias(), + agg_expr->relation_name())); break; } // Case 2.2: this aggregate expression is an AVG. @@ -305,7 +306,8 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( E::Alias::Create(optimizer_context_->nextExprId(), sum_expr, agg_expr->attribute_name(), - agg_expr->attribute_alias())); + agg_expr->attribute_alias(), + agg_expr->relation_name())); sum_attr = E::ToRef(new_agg_exprs.back()); } else { @@ -325,7 +327,8 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( E::Alias::Create(agg_expr->id(), avg_expr, agg_expr->attribute_name(), - agg_expr->attribute_alias())); + agg_expr->attribute_alias(), + agg_expr->relation_name())); } } } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bd78194e/utility/HashError.hpp -- diff --git a/utility/HashError.hpp b/utility/HashError.hpp index fda54d7..0472345 100644 --- a/utility/HashError.hpp +++ b/utility/HashError.hpp @@ -21,6 +21,7 @@ #define QUICKSTEP_UTILITY_HASH_ERROR_HPP_ #include +#include namespace quickstep {
[1/2] incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression f3d695347 -> 6dc3a3b47 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3294cf28 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3294cf28 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3294cf28 Branch: refs/heads/common-subexpression Commit: 3294cf287975e782c8670b276deea4e691b86f60 Parents: f3d6953 Author: Jianqiao Zhu Authored: Fri Apr 21 13:44:10 2017 -0500 Committer: Jianqiao Zhu Committed: Fri Apr 21 13:44:10 2017 -0500 -- query_optimizer/PhysicalGenerator.cpp | 3 +- .../expressions/BinaryExpression.cpp| 2 +- query_optimizer/expressions/UnaryExpression.cpp | 3 +- query_optimizer/rules/CMakeLists.txt| 1 + query_optimizer/rules/CollapseSelection.cpp | 2 + .../rules/ExtractCommonSubexpression.cpp| 68 +- .../rules/ReuseAggregateExpressions.cpp | 4 +- .../tests/execution_generator/CMakeLists.txt| 12 + .../CommonSubexpression.test| 52 ++ .../tests/physical_generator/CMakeLists.txt | 4 + .../physical_generator/CommonSubexpression.test | 772 +++ .../tests/physical_generator/Select.test| 112 +-- 12 files changed, 970 insertions(+), 65 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3294cf28/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index e002ba7..d1ad58b 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -187,8 +187,7 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { << physical_plan_->toString(); } -// DVLOG(4) << "Optimized physical plan:\n" << physical_plan_->toString(); - std::cerr << "Optimized physical plan:\n" << physical_plan_->toString(); + DVLOG(4) << "Optimized physical plan:\n" << physical_plan_->toString(); if (FLAGS_visualize_plan) { quickstep::PlanVisualizer plan_visualizer; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3294cf28/query_optimizer/expressions/BinaryExpression.cpp -- diff --git a/query_optimizer/expressions/BinaryExpression.cpp b/query_optimizer/expressions/BinaryExpression.cpp index 52e7b19..f49c6a2 100644 --- a/query_optimizer/expressions/BinaryExpression.cpp +++ b/query_optimizer/expressions/BinaryExpression.cpp @@ -124,7 +124,7 @@ std::size_t BinaryExpression::computeHash() const { bool BinaryExpression::equals(const ScalarPtr &other) const { BinaryExpressionPtr expr; if (SomeBinaryExpression::MatchesWithConditionalCast(other, &expr) && - operation_.getBinaryOperationID() == expr->operation_.getBinaryOperationID()) { + &operation_ == &expr->operation_) { ScalarPtr left = left_; ScalarPtr right = right_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3294cf28/query_optimizer/expressions/UnaryExpression.cpp -- diff --git a/query_optimizer/expressions/UnaryExpression.cpp b/query_optimizer/expressions/UnaryExpression.cpp index b8d3c63..b448553 100644 --- a/query_optimizer/expressions/UnaryExpression.cpp +++ b/query_optimizer/expressions/UnaryExpression.cpp @@ -68,8 +68,7 @@ std::size_t UnaryExpression::computeHash() const { bool UnaryExpression::equals(const ScalarPtr &other) const { UnaryExpressionPtr expr; if (SomeUnaryExpression::MatchesWithConditionalCast(other, &expr)) { -return operation_.getUnaryOperationID() == expr->operation_.getUnaryOperationID() - && operand_->equals(expr->operand_); +return &operation_ == &expr->operation_ && operand_->equals(expr->operand_); } return false; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3294cf28/query_optimizer/rules/CMakeLists.txt -- diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt index fa73612..0acd869 100644 --- a/query_optimizer/rules/CMakeLists.txt +++ b/query_optimizer/rules/CMakeLists.txt @@ -233,6 +233,7 @@ target_link_libraries(quickstep_queryoptimizer_rules_ReorderColumns quickstep_queryoptimizer_rules_Rule quickstep_utility_Macros) target_link_libraries(quickstep_queryoptimizer_rules_ReuseAggregateExpressions + ${GFLAGS_LIB_NAME} glog quickstep_expressions_aggregation_Aggreg
[2/2] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/6dc3a3b4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/6dc3a3b4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/6dc3a3b4 Branch: refs/heads/common-subexpression Commit: 6dc3a3b47f60f60370af649bb40004dda248dde5 Parents: 3294cf2 Author: Jianqiao Zhu Authored: Fri Apr 21 16:03:34 2017 -0500 Committer: Jianqiao Zhu Committed: Fri Apr 21 16:03:34 2017 -0500 -- query_optimizer/PhysicalGenerator.cpp | 13 +-- query_optimizer/rules/CMakeLists.txt| 3 + .../rules/ExtractCommonSubexpression.cpp| 115 +++ .../rules/ExtractCommonSubexpression.hpp| 46 +++- .../physical_generator/CommonSubexpression.test | 4 +- 5 files changed, 146 insertions(+), 35 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dc3a3b4/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index d1ad58b..5f3b1b7 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -124,12 +124,6 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { std::vector>> rules; rules.emplace_back(new PruneColumns()); - // TODO(jianqiao): It is possible for PushDownLowCostDisjunctivePredicate to - // generate two chaining Selection nodes that can actually be fused into one. - // Note that currently it is okay to have the two Selections because they are - // applied to a small cardinality stored relation, which is very light-weight. - // However it is better to have a FuseSelection optimization (or even a more - // general FusePhysical optimization) in the future. rules.emplace_back(new PushDownLowCostDisjunctivePredicate()); rules.emplace_back(new ReduceGroupByAttributes(optimizer_context_)); @@ -156,9 +150,10 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.emplace_back(new FuseAggregateJoin()); - // Some of the optimization passes (e.g. ReuseAggregateExpressions) might add - // extra Selection nodes and extra projection columns for convenience. So we - // collapse Selection nodes and prune unnecessary columns here. + // Some of the optimization passes (e.g. PushDownLowCostDisjunctivePredicate + // and ReuseAggregateExpressions) might add extra Selection nodes and extra + // projection columns for their convenience. So we collapse Selection nodes + // and prune unnecessary columns here. rules.emplace_back(new CollapseSelection()); rules.emplace_back(new PruneColumns()); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dc3a3b4/query_optimizer/rules/CMakeLists.txt -- diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt index 0acd869..f21d668 100644 --- a/query_optimizer/rules/CMakeLists.txt +++ b/query_optimizer/rules/CMakeLists.txt @@ -95,6 +95,7 @@ target_link_libraries(quickstep_queryoptimizer_rules_CollapseSelection target_link_libraries(quickstep_queryoptimizer_rules_ExtractCommonSubexpression glog quickstep_queryoptimizer_OptimizerContext + quickstep_queryoptimizer_expressions_AggregateFunction quickstep_queryoptimizer_expressions_Alias quickstep_queryoptimizer_expressions_CommonSubexpression quickstep_queryoptimizer_expressions_Expression @@ -103,6 +104,8 @@ target_link_libraries(quickstep_queryoptimizer_rules_ExtractCommonSubexpression quickstep_queryoptimizer_expressions_PatternMatcher quickstep_queryoptimizer_expressions_Scalar quickstep_queryoptimizer_physical_Aggregate + quickstep_queryoptimizer_physical_HashJoin + quickstep_queryoptimizer_physical_NestedLoopsJoin quickstep_queryoptimizer_physical_Physical quickstep_queryoptimizer_physical_PhysicalType quickstep_queryoptimizer_physical_Selection http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dc3a3b4/query_optimizer/rules/ExtractCommonSubexpression.cpp -- diff --git a/query_optimizer/rules/ExtractCommonSubexpression.cpp b/query_optimizer/rules/ExtractCommonSubexpression.cpp index 6b51744..6bbd902 100644 --- a/query_optimizer/rules/ExtractCommonSubexpression.cpp +++ b/query_optimizer/rules/ExtractCommonSubexpression.cpp
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression 675dcf8de -> a3a4ec7bf Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a3a4ec7b Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a3a4ec7b Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a3a4ec7b Branch: refs/heads/common-subexpression Commit: a3a4ec7bf2f99634c9e50c6b5f1a43b9e455f133 Parents: 675dcf8 Author: Jianqiao Zhu Authored: Wed Apr 19 22:37:29 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Apr 19 22:37:29 2017 -0500 -- query_optimizer/ExecutionGenerator.cpp | 6 +++--- query_optimizer/PhysicalGenerator.cpp | 2 ++ query_optimizer/rules/ReuseAggregateExpressions.cpp | 11 ++- 3 files changed, 15 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3a4ec7b/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 8f44cc1..e01e34d 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -1580,7 +1580,7 @@ void ExecutionGenerator::convertAggregate( ->canUseCollisionFreeAggregation(physical_plan, estimated_num_groups, &max_num_groups)) { - std::cout << "Use collision free\n"; +// std::cout << "Use collision free\n"; aggr_state_proto->set_hash_table_impl_type( serialization::HashTableImplType::COLLISION_FREE_VECTOR); aggr_state_proto->set_estimated_num_entries(max_num_groups); @@ -1588,12 +1588,12 @@ void ExecutionGenerator::convertAggregate( } else { if (cost_model_for_aggregation_->canUseTwoPhaseNumericAggregation( physical_plan, estimated_num_groups)) { -std::cout << "Use two phase numeric\n"; +//std::cout << "Use two phase numeric\n"; aggr_state_proto->set_hash_table_impl_type( serialization::HashTableImplType::THREAD_PRIVATE_COMPACT_KEY); } else { // Otherwise, use SeparateChaining. -std::cout << "Use normal\n"; +//std::cout << "Use normal\n"; aggr_state_proto->set_hash_table_impl_type( serialization::HashTableImplType::SEPARATE_CHAINING); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3a4ec7b/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index 07bd024..4405761 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -155,6 +155,8 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.emplace_back(new CollapseSelection()); + rules.emplace_back(new PruneColumns()); + rules.emplace_back(new ExtractCommonSubexpression(optimizer_context_)); // NOTE(jianqiao): Adding rules after InjectJoinFilters (or AttachLIPFilters) requires http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a3a4ec7b/query_optimizer/rules/ReuseAggregateExpressions.cpp -- diff --git a/query_optimizer/rules/ReuseAggregateExpressions.cpp b/query_optimizer/rules/ReuseAggregateExpressions.cpp index 3036833..7151fdf 100644 --- a/query_optimizer/rules/ReuseAggregateExpressions.cpp +++ b/query_optimizer/rules/ReuseAggregateExpressions.cpp @@ -47,6 +47,7 @@ #include "types/operations/binary_operations/BinaryOperationFactory.hpp" #include "types/operations/binary_operations/BinaryOperationID.hpp" #include "utility/EqualsAnyConstant.hpp" +#include "utility/HashError.hpp" #include "glog/logging.h" @@ -106,7 +107,11 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( } } if (arguments.size() == 1) { - agg_expr_info[arguments.front()][agg_id].emplace_back(i); + try { +agg_expr_info[arguments.front()][agg_id].emplace_back(i); + } catch (const HashNotSupported &e) { +continue; + } } } @@ -190,6 +195,10 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( std::vector new_agg_exprs; std::vector new_select_exprs; + for (const auto &grouping_expr : aggregate->grouping_expressions()) { +new_select_exprs.emplace_back(E::ToRef(grouping_expr)); + } + for (std::size_t i = 0; i < agg_refs.size(); ++i) { const auto &agg_ref = agg_refs[i]; const E::AliasPtr &agg_expr = agg_exprs[i];
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression c27f5beb8 -> 675dcf8de Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/675dcf8d Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/675dcf8d Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/675dcf8d Branch: refs/heads/common-subexpression Commit: 675dcf8de09a341f6b1a9a0cc0622d27bc8a1ff3 Parents: c27f5be Author: Jianqiao Zhu Authored: Wed Apr 19 15:11:24 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Apr 19 15:11:24 2017 -0500 -- query_optimizer/ExecutionGenerator.cpp | 2 +- query_optimizer/PhysicalGenerator.cpp | 2 +- .../rules/ReuseAggregateExpressions.cpp | 50 +- .../rules/ReuseAggregateExpressions.hpp | 5 +- storage/AggregationOperationState.cpp | 16 +- storage/AggregationOperationState.hpp | 2 +- storage/CMakeLists.txt | 14 +- storage/HashTable.proto | 2 +- storage/HashTableBase.hpp | 2 +- storage/HashTableFactory.hpp| 10 +- storage/ThreadPrivateCompactKeyHashTable.cpp| 35 ++ storage/ThreadPrivateCompactKeyHashTable.hpp| 483 +++ storage/ThreadPrivateNumericHashTable.cpp | 0 storage/ThreadPrivateNumericHashTable.hpp | 483 --- 14 files changed, 588 insertions(+), 518 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/675dcf8d/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 0304e2e..8f44cc1 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -1590,7 +1590,7 @@ void ExecutionGenerator::convertAggregate( physical_plan, estimated_num_groups)) { std::cout << "Use two phase numeric\n"; aggr_state_proto->set_hash_table_impl_type( -serialization::HashTableImplType::THREAD_PRIVATE_NUMERIC); +serialization::HashTableImplType::THREAD_PRIVATE_COMPACT_KEY); } else { // Otherwise, use SeparateChaining. std::cout << "Use normal\n"; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/675dcf8d/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index 427c365..07bd024 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -149,7 +149,7 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.emplace_back(new ReorderColumns()); } - rules.emplace_back(new ReuseAggregateExpressions()); + rules.emplace_back(new ReuseAggregateExpressions(optimizer_context_)); rules.emplace_back(new FuseAggregateJoin()); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/675dcf8d/query_optimizer/rules/ReuseAggregateExpressions.cpp -- diff --git a/query_optimizer/rules/ReuseAggregateExpressions.cpp b/query_optimizer/rules/ReuseAggregateExpressions.cpp index 77dfd1e..3036833 100644 --- a/query_optimizer/rules/ReuseAggregateExpressions.cpp +++ b/query_optimizer/rules/ReuseAggregateExpressions.cpp @@ -26,7 +26,9 @@ #include #include "expressions/aggregation/AggregateFunction.hpp" +#include "expressions/aggregation/AggregateFunctionFactory.hpp" #include "expressions/aggregation/AggregationID.hpp" +#include "query_optimizer/OptimizerContext.hpp" #include "query_optimizer/expressions/AggregateFunction.hpp" #include "query_optimizer/expressions/Alias.hpp" #include "query_optimizer/expressions/AttributeReference.hpp" @@ -81,13 +83,19 @@ P::PhysicalPtr ReuseAggregateExpressions::applyToNode( for (std::size_t i = 0; i < agg_exprs.size(); ++i) { DCHECK(agg_exprs[i]->expression()->getExpressionType() == E::ExpressionType::kAggregateFunction); -const E::AggregateFunctionPtr agg_func = +const E::AggregateFunctionPtr agg_expr = std::static_pointer_cast( agg_exprs[i]->expression()); -const AggregationID agg_id = agg_func->getAggregate().getAggregationID(); + +// Skip DISTINCT aggregations. +if (agg_expr->is_distinct()) { + continue; +} + +const AggregationID agg_id = agg_expr->getAggregate().getAggregationID(); +const std::vector &arguments = agg_expr->getArguments(); // Currently we only consider aggregate functions with 0 or 1 argument. -c
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression b0acc9ce9 -> c27f5beb8 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/c27f5beb Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/c27f5beb Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/c27f5beb Branch: refs/heads/common-subexpression Commit: c27f5beb8d473895dfa637c699590f4d4a2408cc Parents: b0acc9c Author: Jianqiao Zhu Authored: Wed Apr 19 13:45:01 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Apr 19 13:45:01 2017 -0500 -- query_optimizer/CMakeLists.txt | 4 +- query_optimizer/PhysicalGenerator.cpp | 10 +- query_optimizer/rules/CMakeLists.txt| 49 +++- query_optimizer/rules/CollapseSelection.cpp | 57 query_optimizer/rules/CollapseSelection.hpp | 59 + .../rules/CommonSubexpressionExtraction.cpp | 264 --- .../rules/CommonSubexpressionExtraction.hpp | 135 -- .../rules/ExtractCommonSubexpression.cpp| 264 +++ .../rules/ExtractCommonSubexpression.hpp| 135 ++ .../rules/ReuseAggregateExpressions.cpp | 235 + .../rules/ReuseAggregateExpressions.hpp | 95 +++ 11 files changed, 900 insertions(+), 407 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c27f5beb/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 9e5a2c8..c969f16 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -214,13 +214,15 @@ target_link_libraries(quickstep_queryoptimizer_PhysicalGenerator quickstep_queryoptimizer_logical_Logical quickstep_queryoptimizer_physical_Physical quickstep_queryoptimizer_rules_AttachLIPFilters - quickstep_queryoptimizer_rules_CommonSubexpressionExtraction + quickstep_queryoptimizer_rules_CollapseSelection + quickstep_queryoptimizer_rules_ExtractCommonSubexpression quickstep_queryoptimizer_rules_FuseAggregateJoin quickstep_queryoptimizer_rules_InjectJoinFilters quickstep_queryoptimizer_rules_PruneColumns quickstep_queryoptimizer_rules_PushDownLowCostDisjunctivePredicate quickstep_queryoptimizer_rules_ReduceGroupByAttributes quickstep_queryoptimizer_rules_ReorderColumns + quickstep_queryoptimizer_rules_ReuseAggregateExpressions quickstep_queryoptimizer_rules_StarSchemaHashJoinOrderOptimization quickstep_queryoptimizer_rules_SwapProbeBuild quickstep_queryoptimizer_strategy_Aggregate http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c27f5beb/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index 34deb76..427c365 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -27,13 +27,15 @@ #include "query_optimizer/logical/Logical.hpp" #include "query_optimizer/physical/Physical.hpp" #include "query_optimizer/rules/AttachLIPFilters.hpp" -#include "query_optimizer/rules/CommonSubexpressionExtraction.hpp" +#include "query_optimizer/rules/CollapseSelection.hpp" +#include "query_optimizer/rules/ExtractCommonSubexpression.hpp" #include "query_optimizer/rules/FuseAggregateJoin.hpp" #include "query_optimizer/rules/InjectJoinFilters.hpp" #include "query_optimizer/rules/PruneColumns.hpp" #include "query_optimizer/rules/PushDownLowCostDisjunctivePredicate.hpp" #include "query_optimizer/rules/ReduceGroupByAttributes.hpp" #include "query_optimizer/rules/ReorderColumns.hpp" +#include "query_optimizer/rules/ReuseAggregateExpressions.hpp" #include "query_optimizer/rules/StarSchemaHashJoinOrderOptimization.hpp" #include "query_optimizer/rules/SwapProbeBuild.hpp" #include "query_optimizer/strategy/Aggregate.hpp" @@ -147,9 +149,13 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.emplace_back(new ReorderColumns()); } + rules.emplace_back(new ReuseAggregateExpressions()); + rules.emplace_back(new FuseAggregateJoin()); - rules.emplace_back(new CommonSubexpressionExtraction(optimizer_context_)); + rules.emplace_back(new CollapseSelection()); + + rules.emplace_back(new ExtractCommonSubexpression(optimizer_
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression 449b5e81c -> ecf55e0cd Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/ecf55e0c Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/ecf55e0c Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/ecf55e0c Branch: refs/heads/common-subexpression Commit: ecf55e0cd3d54ec3e5a7f5e9fa18668a35f21102 Parents: 449b5e8 Author: Jianqiao Zhu Authored: Thu Apr 6 00:54:25 2017 -0500 Committer: Jianqiao Zhu Committed: Thu Apr 6 00:54:25 2017 -0500 -- .../rules/CommonSubexpressionExtraction.cpp | 124 +++ .../rules/CommonSubexpressionExtraction.hpp | 25 ++-- 2 files changed, 113 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ecf55e0c/query_optimizer/rules/CommonSubexpressionExtraction.cpp -- diff --git a/query_optimizer/rules/CommonSubexpressionExtraction.cpp b/query_optimizer/rules/CommonSubexpressionExtraction.cpp index cc767c2..b6370fa 100644 --- a/query_optimizer/rules/CommonSubexpressionExtraction.cpp +++ b/query_optimizer/rules/CommonSubexpressionExtraction.cpp @@ -20,14 +20,17 @@ #include "query_optimizer/rules/CommonSubexpressionExtraction.hpp" #include +#include #include #include "query_optimizer/OptimizerContext.hpp" +#include "query_optimizer/expressions/Alias.hpp" #include "query_optimizer/expressions/CommonSubexpression.hpp" #include "query_optimizer/expressions/ExpressionType.hpp" #include "query_optimizer/expressions/NamedExpression.hpp" #include "query_optimizer/expressions/PatternMatcher.hpp" #include "query_optimizer/expressions/Scalar.hpp" +#include "query_optimizer/physical/Aggregate.hpp" #include "query_optimizer/physical/Physical.hpp" #include "query_optimizer/physical/PhysicalType.hpp" #include "query_optimizer/physical/Selection.hpp" @@ -41,6 +44,21 @@ namespace optimizer { namespace E = ::quickstep::optimizer::expressions; namespace P = ::quickstep::optimizer::physical; +CommonSubexpressionExtraction::CommonSubexpressionExtraction( +OptimizerContext *optimizer_context) +: optimizer_context_(optimizer_context) { + homogeneous_whitelist_.reset(new std::unordered_set({ + E::ExpressionType::kAlias, + E::ExpressionType::kAttributeReference, + E::ExpressionType::kAggregateFunction, + E::ExpressionType::kBinaryExpression, + E::ExpressionType::kCast, + E::ExpressionType::kCommonSubexpression, + E::ExpressionType::kScalarLiteral, + E::ExpressionType::kUnaryExpression + })); +} + P::PhysicalPtr CommonSubexpressionExtraction::apply(const P::PhysicalPtr &input) { DCHECK(input->getPhysicalType() == P::PhysicalType::kTopLevelPlan); @@ -63,9 +81,11 @@ P::PhysicalPtr CommonSubexpressionExtraction::applyInternal( case P::PhysicalType::kSelection: { const P::SelectionPtr selection = std::static_pointer_cast(node); + const std::vector new_expressions = DownCast( transformExpressions(UpCast(selection->project_expressions(; + if (new_expressions != selection->project_expressions()) { return P::Selection::Create(selection->input(), new_expressions, @@ -73,6 +93,40 @@ P::PhysicalPtr CommonSubexpressionExtraction::applyInternal( } break; } +case P::PhysicalType::kAggregate: { + const P::AggregatePtr aggregate = + std::static_pointer_cast(node); + std::vector expressions = + UpCast(aggregate->aggregate_expressions()); + for (const auto &expr : aggregate->grouping_expressions()) { +expressions.emplace_back(expr); + } + + const std::vector new_expressions = + transformExpressions(expressions); + + if (new_expressions != expressions) { +std::vector new_aggregate_expressions; +std::vector new_grouping_expressions; +const std::size_t num_aggrs = aggregate->aggregate_expressions().size(); + +for (std::size_t i = 0; i < num_aggrs; ++i) { + DCHECK(E::SomeAlias::Matches(new_expressions[i])); + new_aggregate_expressions.emplace_back( + std::static_pointer_cast(new_expressions[i])); +} +for (std::size_t i = num_aggrs; i < new_expressions.size(); ++i) { + DCHECK(E::SomeNamedExpression::Matches(new_expressions[i])); + new_grouping_expressions.emplace_back( + std::static_pointer_cast(new_expressions[i])); +} +return P::Aggregate::Create(aggregate->input(), +new_grouping_expressions, +
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/common-subexpression 4f8e15273 -> 449b5e81c Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/449b5e81 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/449b5e81 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/449b5e81 Branch: refs/heads/common-subexpression Commit: 449b5e81cb08cbc04100d31cc1d83a63ae66e710 Parents: 4f8e152 Author: Jianqiao Zhu Authored: Wed Apr 5 21:42:20 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Apr 5 21:42:20 2017 -0500 -- expressions/predicate/ComparisonPredicate.cpp | 36 +++ expressions/scalar/CMakeLists.txt | 3 + expressions/scalar/Scalar.hpp | 7 ++- expressions/scalar/ScalarAttribute.cpp | 6 +- expressions/scalar/ScalarAttribute.hpp | 7 ++- expressions/scalar/ScalarBinaryExpression.cpp | 30 + expressions/scalar/ScalarBinaryExpression.hpp | 7 ++- expressions/scalar/ScalarCache.hpp | 64 expressions/scalar/ScalarCaseExpression.cpp | 21 --- expressions/scalar/ScalarCaseExpression.hpp | 6 +- expressions/scalar/ScalarLiteral.cpp| 6 +- expressions/scalar/ScalarLiteral.hpp| 7 ++- expressions/scalar/ScalarSharedExpression.cpp | 47 +++--- expressions/scalar/ScalarSharedExpression.hpp | 7 ++- expressions/scalar/ScalarUnaryExpression.cpp| 12 ++-- expressions/scalar/ScalarUnaryExpression.hpp| 7 ++- relational_operators/HashJoinOperator.cpp | 51 .../NestedLoopsJoinOperator.cpp | 6 +- storage/AggregationOperationState.cpp | 4 +- storage/StorageBlock.cpp| 10 ++- storage/WindowAggregationOperationState.cpp | 8 ++- 21 files changed, 272 insertions(+), 80 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/449b5e81/expressions/predicate/ComparisonPredicate.cpp -- diff --git a/expressions/predicate/ComparisonPredicate.cpp b/expressions/predicate/ComparisonPredicate.cpp index 7e454d6..84bc51a 100644 --- a/expressions/predicate/ComparisonPredicate.cpp +++ b/expressions/predicate/ComparisonPredicate.cpp @@ -193,7 +193,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( if (short_circuit_adapter) { ColumnVectorPtr right_values(right_operand_->getAllValues( short_circuit_adapter.get(), - sub_blocks_ref)); + sub_blocks_ref, + nullptr /* scalar_cache */)); return fast_comparator_->compareStaticValueAndColumnVector( left_operand_->getStaticValue(), *right_values, @@ -202,7 +203,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( } else { ColumnVectorPtr right_values(right_operand_->getAllValues( accessor, - sub_blocks_ref)); + sub_blocks_ref, + nullptr /* scalar_cache */)); return fast_comparator_->compareStaticValueAndColumnVector( left_operand_->getStaticValue(), *right_values, @@ -225,7 +227,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( if (short_circuit_adapter) { ColumnVectorPtr left_values(left_operand_->getAllValues( short_circuit_adapter.get(), - sub_blocks_ref)); + sub_blocks_ref, + nullptr /* scalar_cache */)); return fast_comparator_->compareColumnVectorAndStaticValue( *left_values, right_operand_->getStaticValue(), @@ -234,7 +237,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( } else { ColumnVectorPtr left_values(left_operand_->getAllValues( accessor, - sub_blocks_ref)); + sub_blocks_ref, + nullptr /* scalar_cache */)); return fast_comparator_->compareColumnVectorAndStaticValue( *left_values, right_operand_->getStaticValue(), @@ -258,7 +262,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( if (short_circuit_adapter) { ColumnVectorPtr right_values(right_operand_->getAllValues( short_circuit_adapter.get(), - sub_blocks_ref)); + sub_blocks_ref, + nullptr /* scalar_cache */)); return fast_comparator_->compareValueAccessorAndColumnVector( short_circuit_adapter.get(), left_operand_attr_id, @@ -268,7 +273,8 @@ TupleIdSequence* ComparisonPredicate::getAllMatches( } else { ColumnVectorPtr right_values(right_operand_->getAllValues( accessor, - sub_blocks_ref)); +
[1/3] incubator-quickstep git commit: Updates to types
Repository: incubator-quickstep Updated Branches: refs/heads/new-op 959cd0d40 -> db611137e Updates to types Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9db9fc86 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9db9fc86 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9db9fc86 Branch: refs/heads/new-op Commit: 9db9fc869d808fba49274a3729113c6dcc80d147 Parents: 959cd0d Author: Jianqiao Zhu Authored: Wed Mar 29 20:13:48 2017 -0500 Committer: Jianqiao Zhu Committed: Wed Mar 29 20:13:48 2017 -0500 -- query_optimizer/LogicalGenerator.cpp| 7 +- types/AsciiStringSuperType.hpp | 77 +++ types/CMakeLists.txt| 12 +- types/CharType.cpp | 13 -- types/CharType.hpp | 33 + types/DateType.cpp | 19 --- types/DateType.hpp | 20 +-- types/DatetimeIntervalType.cpp | 19 --- types/DatetimeIntervalType.hpp | 22 +--- types/DatetimeType.cpp | 19 --- types/DatetimeType.hpp | 21 +-- types/DoubleType.hpp| 12 +- types/FloatType.hpp | 12 +- types/IntType.hpp | 12 +- types/LongType.hpp | 12 +- types/NullType.hpp | 17 +-- types/NumericSuperType.hpp | 7 +- types/Type.cpp | 22 +++- types/Type.hpp | 128 --- types/Type.proto| 18 +-- types/TypeFactory.cpp | 116 ++--- types/TypeFactory.hpp | 20 +-- types/TypeID.hpp| 2 +- types/TypeUtil.hpp | 24 ++-- types/VarCharType.cpp | 13 -- types/VarCharType.hpp | 33 + types/YearMonthIntervalType.cpp | 19 --- types/YearMonthIntervalType.hpp | 22 +--- types/operations/OperationFactory.cpp | 2 +- .../unary_operations/CMathUnaryOperations.hpp | 11 +- .../unary_operations/CastOperation.cpp | 12 +- 31 files changed, 273 insertions(+), 503 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9db9fc86/query_optimizer/LogicalGenerator.cpp -- diff --git a/query_optimizer/LogicalGenerator.cpp b/query_optimizer/LogicalGenerator.cpp index 940b728..01af806 100644 --- a/query_optimizer/LogicalGenerator.cpp +++ b/query_optimizer/LogicalGenerator.cpp @@ -51,10 +51,11 @@ L::LogicalPtr LogicalGenerator::generatePlan( const CatalogDatabase &catalog_database, const ParseStatement &parse_statement) { resolver::Resolver resolver(catalog_database, optimizer_context_); -// DVLOG(4) << "Parse tree:\n" << parse_statement.toString(); - std::cerr << "Parse tree:\n" << parse_statement.toString(); + DVLOG(4) << "Parse tree:\n" << parse_statement.toString(); +// std::cerr << "Parse tree:\n" << parse_statement.toString(); logical_plan_ = resolver.resolve(parse_statement); - std::cerr << "Initial logical plan:\n" << logical_plan_->toString(); + DVLOG(4) << "Initial logical plan:\n" << logical_plan_->toString(); +// std::cerr << "Initial logical plan:\n" << logical_plan_->toString(); // exit(0); optimizePlan(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9db9fc86/types/AsciiStringSuperType.hpp -- diff --git a/types/AsciiStringSuperType.hpp b/types/AsciiStringSuperType.hpp new file mode 100644 index 000..82396b2 --- /dev/null +++ b/types/AsciiStringSuperType.hpp @@ -0,0 +1,77 @@ +/** + * 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 + * sp
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/LIP-time-decomposition 261b545e2 -> b19bb53ea Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/b19bb53e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b19bb53e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b19bb53e Branch: refs/heads/LIP-time-decomposition Commit: b19bb53ea7b247f19ba3cda5cd413883ed73e687 Parents: 261b545 Author: Jianqiao Zhu Authored: Thu Mar 16 14:13:07 2017 -0500 Committer: Jianqiao Zhu Committed: Thu Mar 16 14:13:07 2017 -0500 -- relational_operators/HashJoinOperator.cpp | 25 ++- storage/CountedReference.hpp | 4 +- storage/InsertDestination.cpp | 27 +++ storage/InsertDestination.hpp | 5 + storage/SplitRowStoreTupleStorageSubBlock.cpp | 197 - storage/StorageManager.cpp| 194 +--- utility/ShardedLockManager.hpp| 59 -- 7 files changed, 323 insertions(+), 188 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b19bb53e/relational_operators/HashJoinOperator.cpp -- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index 3f6eaab..643602e 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -471,20 +471,19 @@ void HashInnerJoinWorkOrder::execute() { base_accessor->createSharedTupleIdSequenceAdapterVirtual(*existence_map)); } - auto *container = simple_profiler.getContainer(); - auto *event_hash = container->getEventLine("ProbeHash"); - event_hash->emplace_back(); - if (probe_accessor->getImplementationType() == ValueAccessor::Implementation::kSplitRowStore) { -executeWithCopyElision(probe_accessor.get()); - } else { +// if (probe_accessor->getImplementationType() == ValueAccessor::Implementation::kSplitRowStore) { +//executeWithCopyElision(probe_accessor.get()); +// } else { executeWithoutCopyElision(probe_accessor.get()); - } +// } - event_hash->back().endEvent(); } void HashInnerJoinWorkOrder::executeWithoutCopyElision(ValueAccessor *probe_accessor) { + auto *container = simple_profiler.getContainer(); + auto *event_hash = container->getEventLine("ProbeHash"); + event_hash->emplace_back(); VectorsOfPairsJoinedTuplesCollector collector; if (join_key_attributes_.size() == 1) { hash_table_.getAllFromValueAccessor( @@ -499,10 +498,14 @@ void HashInnerJoinWorkOrder::executeWithoutCopyElision(ValueAccessor *probe_acce any_join_key_attributes_nullable_, &collector); } + event_hash->back().endEvent(); const relation_id build_relation_id = build_relation_.getID(); const relation_id probe_relation_id = probe_relation_.getID(); + auto *materialize_line = container->getEventLine("materialize"); + materialize_line->emplace_back(); + MutableBlockReference output_block; for (std::pair &build_block_entry : *collector.getJoinedTuples()) { BlockReference build_block = @@ -549,8 +552,12 @@ void HashInnerJoinWorkOrder::executeWithoutCopyElision(ValueAccessor *probe_acce build_block_entry.second)); } -output_destination_->bulkInsertTuples(&temp_result); +//output_destination_->bulkInsertTuples(&temp_result); +output_destination_->bulkInsertTuples(&temp_result, &output_block); } + + output_destination_->returnBlock(&output_block); + materialize_line->back().endEvent(); } void HashInnerJoinWorkOrder::executeWithCopyElision(ValueAccessor *probe_accessor) { http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b19bb53e/storage/CountedReference.hpp -- diff --git a/storage/CountedReference.hpp b/storage/CountedReference.hpp index 2d9cec3..49d0f73 100644 --- a/storage/CountedReference.hpp +++ b/storage/CountedReference.hpp @@ -66,7 +66,7 @@ class CountedReference { **/ CountedReference(T *block, EvictionPolicy *eviction_policy) : block_(block), eviction_policy_(eviction_policy) { -eviction_policy_->blockReferenced(block_->getID()); +//eviction_policy_->blockReferenced(block_->getID()); #ifdef QUICKSTEP_DEBUG block_->ref(); #endif @@ -111,7 +111,7 @@ class CountedReference { #ifdef QUICKSTEP_DEBUG block_->unref(); #endif -eviction_policy_->blockUnreferenced(block_->getID()); +//eviction_policy_->blockUnreferenced(block_->getID()); } } http://git-wip-us.apache.org/repos/as
[6/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/parser/preprocessed/SqlParser_gen.hpp -- diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp index 18a3aa0..02f090e 100644 --- a/parser/preprocessed/SqlParser_gen.hpp +++ b/parser/preprocessed/SqlParser_gen.hpp @@ -185,7 +185,7 @@ extern int quickstep_yydebug; union YYSTYPE { -#line 117 "../SqlParser.ypp" /* yacc.c:1915 */ +#line 114 "../SqlParser.ypp" /* yacc.c:1915 */ quickstep::ParseString *string_value_; @@ -257,7 +257,7 @@ union YYSTYPE const quickstep::Comparison *comparison_; quickstep::ParseString *unary_operation_; - const quickstep::BinaryOperation *binary_operation_; + quickstep::ParseString *binary_operation_; quickstep::ParseFunctionCall *function_call_; quickstep::PtrList *expression_list_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/query_optimizer/LogicalGenerator.cpp -- diff --git a/query_optimizer/LogicalGenerator.cpp b/query_optimizer/LogicalGenerator.cpp index 49481d3..940b728 100644 --- a/query_optimizer/LogicalGenerator.cpp +++ b/query_optimizer/LogicalGenerator.cpp @@ -51,7 +51,8 @@ L::LogicalPtr LogicalGenerator::generatePlan( const CatalogDatabase &catalog_database, const ParseStatement &parse_statement) { resolver::Resolver resolver(catalog_database, optimizer_context_); - DVLOG(4) << "Parse tree:\n" << parse_statement.toString(); +// DVLOG(4) << "Parse tree:\n" << parse_statement.toString(); + std::cerr << "Parse tree:\n" << parse_statement.toString(); logical_plan_ = resolver.resolve(parse_statement); std::cerr << "Initial logical plan:\n" << logical_plan_->toString(); // exit(0); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/query_optimizer/expressions/BinaryExpression.cpp -- diff --git a/query_optimizer/expressions/BinaryExpression.cpp b/query_optimizer/expressions/BinaryExpression.cpp index 446dd55..2178e2e 100644 --- a/query_optimizer/expressions/BinaryExpression.cpp +++ b/query_optimizer/expressions/BinaryExpression.cpp @@ -29,8 +29,8 @@ #include "query_optimizer/expressions/ExprId.hpp" #include "query_optimizer/expressions/Expression.hpp" #include "query_optimizer/expressions/PatternMatcher.hpp" +#include "query_optimizer/expressions/ScalarLiteral.hpp" #include "types/operations/binary_operations/BinaryOperation.hpp" -#include "types/operations/binary_operations/BinaryOperationID.hpp" #include "glog/logging.h" @@ -41,37 +41,8 @@ class Type; namespace optimizer { namespace expressions { -BinaryExpression::BinaryExpression(const BinaryOperation &operation, - const ScalarPtr &left, - const ScalarPtr &right) -: operation_(operation), left_(left), right_(right) { - DCHECK(operation_.canApplyToTypes(left_->getValueType(), -right_->getValueType())) - << toString(); - addChild(left_); - addChild(right_); -} - std::string BinaryExpression::getName() const { - switch (operation_.getBinaryOperationID()) { -case BinaryOperationID::kAdd: - return "Add"; -case BinaryOperationID::kSubtract: - return "Subtract"; -case BinaryOperationID::kMultiply: - return "Multiply"; -case BinaryOperationID::kDivide: - return "Divide"; -case BinaryOperationID::kModulo: - return "Modulo"; -default: - LOG(FATAL) << "Unknown binary operation"; - } -} - -const Type &BinaryExpression::getValueType() const { - return *operation_.resultTypeForArgumentTypes(left_->getValueType(), -right_->getValueType()); + return op_signature_->getName(); } ExpressionPtr BinaryExpression::copyWithNewChildren( @@ -80,9 +51,12 @@ ExpressionPtr BinaryExpression::copyWithNewChildren( DCHECK(SomeScalar::Matches(new_children[0])); DCHECK(SomeScalar::Matches(new_children[1])); return BinaryExpression::Create( + op_signature_, operation_, std::static_pointer_cast(new_children[0]), - std::static_pointer_cast(new_children[1])); + std::static_pointer_cast(new_children[1]), + static_arguments_, + static_argument_types_); } std::vector BinaryExpression::getReferencedAttributes() const { @@ -99,9 +73,11 @@ std::vector BinaryExpression::getReferencedAttributes() c ::quickstep::Scalar *BinaryExpression::concretize( const std::unordered_map &substitution_map) const { return new ::quickstep::ScalarBinaryExpression( + op_signature_, operation_, left_->concretize(substitution_map), - right_->concretize(substitution_map)); + right_->concretize(substitution_map), + static_arguments_); } voi
[8/8] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/4005df6e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/4005df6e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/4005df6e Branch: refs/heads/new-op Commit: 4005df6e31953458c4cb6e09f6c603cae90ef369 Parents: 6941f90 Author: Jianqiao Zhu Authored: Tue Mar 14 09:55:05 2017 -0500 Committer: Jianqiao Zhu Committed: Tue Mar 14 09:55:05 2017 -0500 -- expressions/CMakeLists.txt |3 +- expressions/ExpressionFactories.cpp | 39 +- expressions/Expressions.proto |7 +- .../aggregation/AggregateFunctionAvg.cpp|7 +- .../aggregation/AggregateFunctionSum.cpp|3 +- .../aggregation/AggregationHandleAvg.cpp| 11 +- .../aggregation/AggregationHandleSum.cpp|5 +- expressions/aggregation/CMakeLists.txt |4 - expressions/predicate/CMakeLists.txt|1 - expressions/scalar/CMakeLists.txt |9 +- expressions/scalar/ScalarBinaryExpression.cpp | 88 +- expressions/scalar/ScalarBinaryExpression.hpp | 31 +- expressions/scalar/ScalarUnaryExpression.cpp| 26 +- expressions/scalar/ScalarUnaryExpression.hpp|2 - expressions/window_aggregation/CMakeLists.txt |4 - .../WindowAggregateFunctionAvg.cpp |7 +- .../WindowAggregateFunctionSum.cpp |3 +- .../WindowAggregationHandle.cpp |3 +- .../WindowAggregationHandle.hpp |1 - .../WindowAggregationHandleAvg.cpp |9 +- parser/CMakeLists.txt |3 - parser/ParseBasicExpressions.cpp| 27 - parser/ParseBasicExpressions.hpp| 86 +- parser/SqlParser.ypp| 40 +- parser/preprocessed/SqlParser_gen.cpp | 2596 +- parser/preprocessed/SqlParser_gen.hpp |4 +- query_optimizer/LogicalGenerator.cpp|3 +- .../expressions/BinaryExpression.cpp| 64 +- .../expressions/BinaryExpression.hpp| 56 +- query_optimizer/expressions/CMakeLists.txt |3 +- query_optimizer/expressions/UnaryExpression.cpp |5 +- query_optimizer/expressions/UnaryExpression.hpp |1 - query_optimizer/resolver/CMakeLists.txt |2 +- query_optimizer/resolver/Resolver.cpp | 263 +- query_optimizer/rules/tests/CMakeLists.txt |1 - query_optimizer/strategy/tests/CMakeLists.txt |1 - query_optimizer/tests/CMakeLists.txt|1 - query_optimizer/tests/OptimizerTest.cpp |1 - relational_operators/CMakeLists.txt |1 - storage/CMakeLists.txt |1 - storage/SMAIndexSubBlock.cpp|5 +- types/CMakeLists.txt|6 +- types/NumericSuperType.hpp |2 +- types/Type.hpp |2 +- types/TypeUtil.hpp |2 - types/containers/ColumnVector.cpp |4 + types/containers/ColumnVector.hpp | 10 +- types/operations/CMakeLists.txt | 31 + types/operations/Operation.hpp | 10 +- types/operations/Operation.proto| 12 - types/operations/OperationFactory.cpp | 358 +++ types/operations/OperationFactory.hpp | 205 ++ types/operations/OperationSignature.hpp |2 +- types/operations/OperationUtil.hpp | 334 +++ .../binary_operations/AddBinaryOperation.cpp| 418 --- .../binary_operations/AddBinaryOperation.hpp| 90 - .../ArithmeticBinaryFunctorOverloads.hpp| 176 ++ .../ArithmeticBinaryOperation.hpp | 404 --- .../ArithmeticBinaryOperations.hpp | 185 ++ .../ArithmeticBinaryOperators.hpp | 851 -- .../AsciiStringBinaryOperations.hpp | 131 + .../binary_operations/BinaryOperation.cpp | 29 - .../binary_operations/BinaryOperation.hpp | 286 +- .../BinaryOperationFactory.cpp | 59 +- .../BinaryOperationFactory.hpp | 38 +- .../binary_operations/BinaryOperationID.cpp | 40 - .../binary_operations/BinaryOperationID.hpp | 62 - .../BinaryOperationWrapper.hpp | 627 + .../operations/binary_operations/CMakeLists.txt | 177 +- .../binary_operations/DivideBinaryOperation.cpp | 391 --- .../binary_operations/DivideBinaryOperation.hpp | 93 - .../binary_operations/ModuloBinaryOperation.cpp | 259 -- .../binary_operations/ModuloBinaryOperation.hpp | 93 - .../MultiplyBinaryOperation.cpp | 410 --- .../Mult
[7/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/parser/preprocessed/SqlParser_gen.cpp -- diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp index 085decb..f79d0e7 100644 --- a/parser/preprocessed/SqlParser_gen.cpp +++ b/parser/preprocessed/SqlParser_gen.cpp @@ -137,9 +137,6 @@ typedef struct YYLTYPE { #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeID.hpp" -#include "types/operations/binary_operations/BinaryOperation.hpp" -#include "types/operations/binary_operations/BinaryOperationFactory.hpp" -#include "types/operations/binary_operations/BinaryOperationID.hpp" #include "types/operations/comparisons/Comparison.hpp" #include "types/operations/comparisons/ComparisonFactory.hpp" #include "types/operations/comparisons/ComparisonID.hpp" @@ -149,7 +146,7 @@ typedef struct YYLTYPE { // Needed for Bison 2.6 and higher, which do not automatically provide this typedef. typedef void* yyscan_t; -#line 153 "SqlParser_gen.cpp" /* yacc.c:339 */ +#line 150 "SqlParser_gen.cpp" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -324,7 +321,7 @@ extern int quickstep_yydebug; union YYSTYPE { -#line 117 "../SqlParser.ypp" /* yacc.c:355 */ +#line 114 "../SqlParser.ypp" /* yacc.c:355 */ quickstep::ParseString *string_value_; @@ -396,7 +393,7 @@ union YYSTYPE const quickstep::Comparison *comparison_; quickstep::ParseString *unary_operation_; - const quickstep::BinaryOperation *binary_operation_; + quickstep::ParseString *binary_operation_; quickstep::ParseFunctionCall *function_call_; quickstep::PtrList *expression_list_; @@ -424,7 +421,7 @@ union YYSTYPE quickstep::ParsePriority *opt_priority_clause_; -#line 428 "SqlParser_gen.cpp" /* yacc.c:355 */ +#line 425 "SqlParser_gen.cpp" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -453,13 +450,13 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta #endif /* !YY_QUICKSTEP_YY_SQLPARSER_GEN_HPP_INCLUDED */ /* Copy the second part of user declarations. */ -#line 217 "../SqlParser.ypp" /* yacc.c:358 */ +#line 214 "../SqlParser.ypp" /* yacc.c:358 */ /* This header needs YYSTYPE, which is defined by the %union directive above */ #include "SqlLexer_gen.hpp" void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature); -#line 463 "SqlParser_gen.cpp" /* yacc.c:358 */ +#line 460 "SqlParser_gen.cpp" /* yacc.c:358 */ #ifdef short # undef short @@ -703,16 +700,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 47 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1446 +#define YYLAST 1447 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 146 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 108 /* YYNRULES -- Number of rules. */ -#define YYNRULES 291 +#define YYNRULES 292 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 543 +#define YYNSTATES 545 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ @@ -771,36 +768,36 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 627, 627, 631, 635, 639, 643, 646, 653, 656, - 659, 662, 665, 668, 671, 674, 677, 680, 686, 692, - 699, 705, 712, 721, 726, 735, 740, 745, 749, 755, - 760, 763, 766, 771, 774, 777, 780, 783, 786, 789, - 792, 795, 798, 810, 813, 816, 834, 854, 857, 860, - 865, 870, 876, 882, 891, 895, 901, 904, 909, 914, - 919, 926, 933, 937, 943, 946, 951, 954, 959, 962, - 967, 970, 989, 992, 997, 1001, 1007, 1010, 1013, 1018, -1021, 1028, 1033, 1044, 1049, 1053, 1057, 1063, 1066, 1072, -1080, 1083, 1086, 1092, 1097, 1100, 1105, 1109, 1113, 1117, -1123, 1128, 1133, 1137, 1143, 1149, 1152, 1157, 1160, 1179, -1184, 1188, 1194, 1200, 1206, 1209, 1213, 1219, 1222, 1227, -1231, 1237, 1240, 1243, 1248, 1253, 1258, 1261, 1264, 1269, -1272, 1275, 1278, 1281, 1284, 1287, 1290, 1295, 1298, 1303, -1307, 1311, 1314, 1318, 1321, 1326, 1329, 1334, 1337, 1342, -1346, 1352, 1355, 1360, 1363, 1368, 1371, 1376, 1379, 1398, -1401, 1406, 1410, 1416, 1422, 1427, 1430, 1435, 1438, 1443, -1446, 1451, 1454, 1459, 1460, 1463, 1468, 1469, 1472, 1477, -1481, 1487, 1494, 1497, 1500, 1505, 1508, 1511, 1517, 1520, -1525, 1530, 1539, 1544, 1553, 1558, 1561, 1566, 1569, 1574, -1580, 1586, 1589, 1592, 1595, 1598, 1601, 1607, 16
[4/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/types/operations/binary_operations/ArithmeticBinaryOperators.hpp -- diff --git a/types/operations/binary_operations/ArithmeticBinaryOperators.hpp b/types/operations/binary_operations/ArithmeticBinaryOperators.hpp deleted file mode 100644 index a9ccd61..000 --- a/types/operations/binary_operations/ArithmeticBinaryOperators.hpp +++ /dev/null @@ -1,851 +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_TYPES_OPERATIONS_BINARY_OPERATIONS_ARITHMETIC_BINARY_OPERATORS_HPP_ -#define QUICKSTEP_TYPES_OPERATIONS_BINARY_OPERATIONS_ARITHMETIC_BINARY_OPERATORS_HPP_ - -#include -#include -#include -#include -#include -#include - -#include "catalog/CatalogTypedefs.hpp" -#include "storage/StorageBlockInfo.hpp" - -#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION -#include "storage/ValueAccessor.hpp" -#include "storage/ValueAccessorUtil.hpp" -#endif // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION - -#include "types/TypedValue.hpp" -#include "types/containers/ColumnVector.hpp" -#include "types/operations/binary_operations/BinaryOperation.hpp" -#include "utility/Macros.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -/** \addtogroup Types - * @{ - */ - -// We use these functors instead of the standard-library ones, because the -// standard-library functors in have to be instantiated for the -// most specific argument type, which would unnecessisarily introduce -// multiple copies of distinct template instantiations of operators. -template struct AddFunctor { - inline auto operator() (const LeftArgument &left, const RightArgument &right) const -> decltype(left + right) { -return left + right; - } -}; - -// NOTE(zuyu): The C++ compiler in general converts all integers to floats -// when doing the following operations, -// but we could like to return double instead. -template <> -struct AddFunctor { - inline double operator() (const std::int64_t &left, const float &right) const { -return static_cast(left) + static_cast(right); - } -}; - -template <> -struct AddFunctor { - inline double operator() (const float &left, const std::int64_t &right) const { -return static_cast(left) + static_cast(right); - } -}; - -template struct SubtractFunctor { - inline auto operator() (const LeftArgument &left, const RightArgument &right) const -> decltype(left - right) { -return left - right; - } -}; - -// NOTE(zuyu): The C++ compiler in general converts all integers to floats -// when doing the following operations, -// but we could like to return double instead. -template <> -struct SubtractFunctor { - inline double operator() (const std::int64_t &left, const float &right) const { -return static_cast(left) - static_cast(right); - } -}; - -template <> -struct SubtractFunctor { - inline double operator() (const float &left, const std::int64_t &right) const { -return static_cast(left) - static_cast(right); - } -}; - -template struct MultiplyFunctor { - inline auto operator() (const LeftArgument &left, const RightArgument &right) const -> decltype(left * right) { -return left * right; - } -}; - -// NOTE(zuyu): The C++ compiler in general converts all integers to floats -// when doing the following operations, -// but we could like to return double instead. -template <> -struct MultiplyFunctor { - inline double operator() (const std::int64_t &left, const float &right) const { -return static_cast(left) * static_cast(right); - } -}; - -template <> -struct MultiplyFunctor { - inline double operator() (const float &left, const std::int64_t &right) const { -return static_cast(left) * static_cast(right); - } -}; - -template struct DivideFunctor { - inline auto operator() (const LeftArgument &left, const RightArgument &right) const -> decltype(left / right) { -return left / right; - } -}; - -// NOTE(zuyu): The C++ compiler in general converts all integers to floats -// when doing the following operations, -// but we could li
[1/8] incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/new-op 6941f903b -> 4005df6e3 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/types/operations/unary_operations/UnaryOperationWrapper.hpp -- diff --git a/types/operations/unary_operations/UnaryOperationWrapper.hpp b/types/operations/unary_operations/UnaryOperationWrapper.hpp index 417c752..c7e4ad5 100644 --- a/types/operations/unary_operations/UnaryOperationWrapper.hpp +++ b/types/operations/unary_operations/UnaryOperationWrapper.hpp @@ -27,26 +27,18 @@ #include "catalog/CatalogTypedefs.hpp" #include "storage/ValueAccessor.hpp" #include "storage/ValueAccessorUtil.hpp" -#include "types/CharType.hpp" -#include "types/IntType.hpp" -#include "types/LongType.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeID.hpp" #include "types/TypedValue.hpp" -#include "types/VarCharType.hpp" #include "types/containers/ColumnVector.hpp" -#include "types/operations/Operation.hpp" #include "types/operations/OperationSignature.hpp" -#include "types/operations/Operation.pb.h" +#include "types/operations/OperationUtil.hpp" +#include "types/operations/unary_operations/UnaryOperation.hpp" #include "utility/Macros.hpp" namespace quickstep { -class ColumnVector; -class Type; -class ValueAccessor; - /** \addtogroup Types * @{ */ @@ -55,6 +47,9 @@ template struct UnaryFunctor { typedef ArgumentT ArgumentType; typedef ResultT ResultType; + + static constexpr Operation + ::OperationSuperTypeID kOperationSuperTypeID = Operation::kUnaryOperation; }; template @@ -65,42 +60,94 @@ class UncheckedUnaryOperatorWrapperCodegen : public UncheckedUnaryOperator { const Type &result_type, ConstructorArgs &&...args) : functor_(std::forward(args)...), -impl_(argument_type, result_type) {} +impl_(functor_, argument_type, result_type) {} TypedValue applyToTypedValue(const TypedValue &argument) const override { -return impl_.applyToTypedValue(argument, functor_); +return impl_.applyToTypedValue(argument); } ColumnVector* applyToColumnVector(const ColumnVector &argument) const override { -return impl_.applyToColumnVector(argument, functor_); +using ArgumentCVT = typename ArgumentGen::ColumnVectorType; +DCHECK_EQ(argument.isNative(), ArgumentCVT::kNative); + +using ArgumentAccessorT = ColumnVectorValueAccessor; +ArgumentAccessorT accessor(static_cast(argument)); +return impl_.applyToValueAccessor(&accessor, 0); } ColumnVector* applyToValueAccessor(ValueAccessor *accessor, - const attribute_id argument_attr_id) const override { -return impl_.applyToValueAccessor(accessor, argument_attr_id, functor_); + const attribute_id attr_id) const override { +return InvokeOnValueAccessorMaybeTupleIdSequenceAdapter( +accessor, +[&](auto *accessor) -> ColumnVector* { // NOLINT(build/c++11) + return impl_.applyToValueAccessor(accessor, attr_id); +}); } private: using ArgumentType = typename FunctorT::ArgumentType; using ResultType = typename FunctorT::ResultType; - template - struct FunctorSpecializer; + using FuncSpec = typename FunctorSpecializer::type; + using ArgumentGen = Codegen; + using ResultGen = Codegen; - template - struct Codegen; - - template + template struct Implementation; - using FuncSpec = FunctorSpecializer; - using Impl = Implementation, - Codegen>; - const FunctorT functor_; - const Impl impl_; + const Implementation impl_; + + DISALLOW_COPY_AND_ASSIGN(UncheckedUnaryOperatorWrapperCodegen); +}; + +template +template +struct UncheckedUnaryOperatorWrapperCodegen +::Implementation { + Implementation(const FunctorT &functor_in, + const Type &argument_type_in, + const Type &result_type_in) + : functor(functor_in), +argument_type(argument_type_in), +result_type(result_type_in) {} + + inline TypedValue applyToTypedValue(const TypedValue &argument) const { +if (argument_nullable && argument.isNull()) { + return TypedValue(ResultType::kStaticTypeID); +} + +return ResultGen::template ApplyUnaryTypedValue( +ArgumentGen::ToNativeValueConst(argument), +result_type, +functor); + } + + template + inline ColumnVector* applyToValueAccessor(AccessorT *accessor, +const attribute_id attr_id) const { +using ResultCVT = typename ResultGen::ColumnVectorType; +ResultCVT *result_cv = new ResultCVT(result_type, accessor->getNumTuples()); + +accessor->beginIteration(); +while (accessor->next()) { + typename ArgumentGen::NativeTypeConstPtr arg_value
[5/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/types/operations/binary_operations/AddBinaryOperation.cpp -- diff --git a/types/operations/binary_operations/AddBinaryOperation.cpp b/types/operations/binary_operations/AddBinaryOperation.cpp deleted file mode 100644 index 8f56a61..000 --- a/types/operations/binary_operations/AddBinaryOperation.cpp +++ /dev/null @@ -1,418 +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 "types/operations/binary_operations/AddBinaryOperation.hpp" - -#include -#include - -#include "types/DateOperatorOverloads.hpp" -#include "types/DateType.hpp" -#include "types/DatetimeIntervalType.hpp" -#include "types/DatetimeLit.hpp" -#include "types/DatetimeType.hpp" -#include "types/IntervalLit.hpp" -#include "types/Type.hpp" -#include "types/TypeErrors.hpp" -#include "types/TypeFactory.hpp" -#include "types/TypeID.hpp" -#include "types/YearMonthIntervalType.hpp" -#include "types/operations/binary_operations/ArithmeticBinaryOperators.hpp" -#include "utility/EqualsAnyConstant.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -bool AddBinaryOperation::canApplyToTypes(const Type &left, const Type &right) const { - switch (left.getTypeID()) { -case kInt: // Fall through. -case kLong: -case kFloat: -case kDouble: { - return (right.getSuperTypeID() == Type::kNumeric); -} -case kDate: { - return (right.getTypeID() == kYearMonthInterval); -} -case kDatetime: { - return (right.getTypeID() == kDatetimeInterval || - right.getTypeID() == kYearMonthInterval); -} -case kDatetimeInterval: { - return (right.getTypeID() == kDatetime || - right.getTypeID() == kDatetimeInterval); -} -case kYearMonthInterval: { - return (right.getTypeID() == kDate || - right.getTypeID() == kDatetime || - right.getTypeID() == kYearMonthInterval); -} -default: - return false; - } -} - -const Type* AddBinaryOperation::resultTypeForArgumentTypes(const Type &left, const Type &right) const { - if (left.getSuperTypeID() == Type::kNumeric && right.getSuperTypeID() == Type::kNumeric) { -return TypeFactory::GetUnifyingType(left, right); - } else if ((left.getTypeID() == kDatetime && right.getTypeID() == kDatetimeInterval) || - (left.getTypeID() == kDatetimeInterval && right.getTypeID() == kDatetime) || - (left.getTypeID() == kDatetime && right.getTypeID() == kYearMonthInterval) || - (left.getTypeID() == kYearMonthInterval && right.getTypeID() == kDatetime)) { -return &(DatetimeType::Instance(left.isNullable() || right.isNullable())); - } else if ((left.getTypeID() == kDate && right.getTypeID() == kYearMonthInterval) || - (left.getTypeID() == kYearMonthInterval && right.getTypeID() == kDate)) { -return &(DateType::Instance(left.isNullable() || right.isNullable())); - } else if (left.getTypeID() == kDatetimeInterval && right.getTypeID() == kDatetimeInterval) { -return &(DatetimeIntervalType::Instance(left.isNullable() || right.isNullable())); - } else if (left.getTypeID() == kYearMonthInterval && right.getTypeID() == kYearMonthInterval) { -return &(YearMonthIntervalType::Instance(left.isNullable() || right.isNullable())); - } else { -return nullptr; - } -} - -const Type* AddBinaryOperation::resultTypeForPartialArgumentTypes(const Type *left, - const Type *right) const { - if ((left == nullptr) && (right == nullptr)) { -return nullptr; - } - - if ((left != nullptr) && (right != nullptr)) { -return resultTypeForArgumentTypes(*left, *right); - } - - // Addition is commutative, so we just determine based on the known type, - // left or right. - const Type *known_type = (left != nullptr) ? left : right; - switch (known_type->getTypeID()) { -case kDouble: - // Double has highest precedence of the numeric types. - return &TypeFactory::GetType(kDouble, true); -case kDatetime: - // Datetime can be added with either inte
[3/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/types/operations/binary_operations/BinaryOperationWrapper.hpp -- diff --git a/types/operations/binary_operations/BinaryOperationWrapper.hpp b/types/operations/binary_operations/BinaryOperationWrapper.hpp new file mode 100644 index 000..d6f856b --- /dev/null +++ b/types/operations/binary_operations/BinaryOperationWrapper.hpp @@ -0,0 +1,627 @@ +/** + * 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_TYPES_OPERATIONS_BINARY_OPERATIONS_BINARY_OPERATION_WRAPPER_HPP_ +#define QUICKSTEP_TYPES_OPERATIONS_BINARY_OPERATIONS_BINARY_OPERATION_WRAPPER_HPP_ + +#include +#include +#include +#include +#include + +#include "catalog/CatalogTypedefs.hpp" +#include "storage/ValueAccessor.hpp" +#include "storage/ValueAccessorUtil.hpp" +#include "types/Type.hpp" +#include "types/TypeFactory.hpp" +#include "types/TypeID.hpp" +#include "types/TypedValue.hpp" +#include "types/containers/ColumnVector.hpp" +#include "types/operations/OperationSignature.hpp" +#include "types/operations/OperationUtil.hpp" +#include "types/operations/binary_operations/BinaryOperation.hpp" +#include "utility/Macros.hpp" +#include "utility/TemplateUtil.hpp" + +namespace quickstep { + +/** \addtogroup Types + * @{ + */ + +template +struct BinaryFunctor { + typedef LeftArgumentT LeftArgumentType; + typedef RightArgumentT RightArgumentType; + typedef ResultT ResultType; + + static constexpr Operation + ::OperationSuperTypeID kOperationSuperTypeID = Operation::kBinaryOperation; +}; + +template +class UncheckedBinaryOperatorWrapperCodegen : public UncheckedBinaryOperator { + public: + template + UncheckedBinaryOperatorWrapperCodegen(const Type &left_type, +const Type &right_type, +const Type &result_type, +ConstructorArgs &&...args) + : functor_(std::forward(args)...), +impl_(functor_, left_type, right_type, result_type) {} + + TypedValue applyToTypedValues(const TypedValue &left, +const TypedValue &right) const override { +return impl_.applyToTypedValues(left, right); + } + + ColumnVector* applyToColumnVectors(const ColumnVector &left, + const ColumnVector &right) const override { +using LeftCVT = typename LeftGen::ColumnVectorType; +DCHECK_EQ(left.isNative(), LeftCVT::kNative); +using LeftAccessorT = ColumnVectorValueAccessor; +LeftAccessorT left_accessor(static_cast(left)); + +using RightCVT = typename RightGen::ColumnVectorType; +DCHECK_EQ(right.isNative(), RightCVT::kNative); +using RightAccessorT = ColumnVectorValueAccessor; +RightAccessorT right_accessor(static_cast(right)); + +const std::size_t num_tuples = left_accessor.getNumTuples(); +DCHECK_EQ(num_tuples, right_accessor.getNumTuples()); + +return impl_.applyToValueAccessors(num_tuples, + &left_accessor, kInvalidAttributeID, + &right_accessor, kInvalidAttributeID); + } + + ColumnVector* applyToColumnVectorAndStaticValue( + const ColumnVector &left, + const TypedValue &right) const override { +using LeftCVT = typename LeftGen::ColumnVectorType; +DCHECK_EQ(left.isNative(), LeftCVT::kNative); + +using LeftAccessorT = ColumnVectorValueAccessor; +LeftAccessorT accessor(static_cast(left)); +return impl_.applyToValueAccessorAndStaticValue(&accessor, 0, right); + } + + ColumnVector* applyToStaticValueAndColumnVector( + const TypedValue &left, + const ColumnVector &right) const override { +using RightCVT = typename RightGen::ColumnVectorType; +DCHECK_EQ(right.isNative(), RightCVT::kNative); + +using RightAccessorT = ColumnVectorValueAccessor; +RightAccessorT accessor(static_cast(right)); +return impl_.applyToStaticValueAndValueAccessor(left, &accessor, 0); + } + + ColumnVector* applyToSingleValueAccessor( + ValueAccessor *accessor, + const attribute_id left_id, +
[2/8] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4005df6e/types/operations/binary_operations/MultiplyBinaryOperation.cpp -- diff --git a/types/operations/binary_operations/MultiplyBinaryOperation.cpp b/types/operations/binary_operations/MultiplyBinaryOperation.cpp deleted file mode 100644 index a206364..000 --- a/types/operations/binary_operations/MultiplyBinaryOperation.cpp +++ /dev/null @@ -1,410 +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 "types/operations/binary_operations/MultiplyBinaryOperation.hpp" - -#include -#include - -#include "types/DateOperatorOverloads.hpp" -#include "types/DatetimeIntervalType.hpp" -#include "types/DoubleType.hpp" -#include "types/FloatType.hpp" -#include "types/IntType.hpp" -#include "types/IntervalLit.hpp" -#include "types/LongType.hpp" -#include "types/Type.hpp" -#include "types/TypeErrors.hpp" -#include "types/TypeFactory.hpp" -#include "types/TypeID.hpp" -#include "types/YearMonthIntervalType.hpp" -#include "types/operations/binary_operations/ArithmeticBinaryOperators.hpp" -#include "utility/EqualsAnyConstant.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -bool MultiplyBinaryOperation::canApplyToTypes(const Type &left, const Type &right) const { - switch (left.getTypeID()) { -case kInt: -case kLong: -case kFloat: -case kDouble: { - return (right.getSuperTypeID() == Type::kNumeric || - right.getTypeID() == kDatetimeInterval || - right.getTypeID() == kYearMonthInterval); -} -case kDatetimeInterval: -case kYearMonthInterval: { - return (right.getSuperTypeID() == Type::kNumeric); -} -default: - return false; - } -} - -const Type* MultiplyBinaryOperation::resultTypeForArgumentTypes(const Type &left, const Type &right) const { - if (left.getSuperTypeID() == Type::kNumeric && right.getSuperTypeID() == Type::kNumeric) { -return TypeFactory::GetUnifyingType(left, right); - } else if ((left.getSuperTypeID() == Type::kNumeric && right.getTypeID() == kDatetimeInterval) || - (left.getTypeID() == kDatetimeInterval && right.getSuperTypeID() == Type::kNumeric)) { -return &(DatetimeIntervalType::Instance(left.isNullable() || right.isNullable())); - } else if ((left.getSuperTypeID() == Type::kNumeric && right.getTypeID() == kYearMonthInterval) || - (left.getTypeID() == kYearMonthInterval && right.getSuperTypeID() == Type::kNumeric)) { -return &(YearMonthIntervalType::Instance(left.isNullable() || right.isNullable())); - } else { -return nullptr; - } -} - -const Type* MultiplyBinaryOperation::resultTypeForPartialArgumentTypes( -const Type *left, -const Type *right) const { - if ((left == nullptr) && (right == nullptr)) { -return nullptr; - } - - if ((left != nullptr) && (right != nullptr)) { -return resultTypeForArgumentTypes(*left, *right); - } - - // Multiplication is commutative, so we just determine based on the known - // type, left or right. - const Type *known_type = (left != nullptr) ? left : right; - switch (known_type->getTypeID()) { -case kDatetimeInterval: - // DatetimeInterval can be multiplied against any numeric type, yielding - // DatetimeInterval. - return &TypeFactory::GetType(kDatetimeInterval, true); -case kYearMonthInterval: - // Same deal for YearMonthInterval. - return &TypeFactory::GetType(kYearMonthInterval, true); -default: - // Ambiguous or inapplicable. Note that we can't apply numeric precedence - // order for a Double argument, because the other argument could be a - // numeric type OR an interval type. - return nullptr; - } -} - -bool MultiplyBinaryOperation::partialTypeSignatureIsPlausible( -const Type *result_type, -const Type *left_argument_type, -const Type *right_argument_type) const { - if ((left_argument_type == nullptr) && (right_argument_type == nullptr)) { -if (result_type == nullptr) { - return true; -} else if (!result_type->isNullable()) { - // Unknown arguments are assumed to be nullable, since they arise from
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/agg-expr bc81c5b3f -> 1a6435f11 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/1a6435f1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/1a6435f1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/1a6435f1 Branch: refs/heads/agg-expr Commit: 1a6435f11c35a2d7e73a97ef21528d5ac3c27320 Parents: bc81c5b Author: Jianqiao Zhu Authored: Sun Feb 26 19:21:21 2017 -0600 Committer: Jianqiao Zhu Committed: Sun Feb 26 19:21:21 2017 -0600 -- expressions/aggregation/AggFunc.hpp | 10 + storage/AggregationOperationState.cpp | 68 +--- storage/AggregationUtil.hpp | 197 storage/CMakeLists.txt| 16 +- storage/CollisionFreeVectorTable.cpp | 160 +- storage/PackedPayloadHashTable.cpp| 177 --- storage/PackedPayloadHashTable.hpp| 488 ++--- 7 files changed, 673 insertions(+), 443 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1a6435f1/expressions/aggregation/AggFunc.hpp -- diff --git a/expressions/aggregation/AggFunc.hpp b/expressions/aggregation/AggFunc.hpp index 31f385e..98b19ba 100644 --- a/expressions/aggregation/AggFunc.hpp +++ b/expressions/aggregation/AggFunc.hpp @@ -69,6 +69,11 @@ class Sum { typename AggState::AtomicT> {}; template + inline static void InitAtomic(typename AggState::AtomicT *state) { +state->store(0, std::memory_order_relaxed); + } + + template inline static void MergeArgAtomic(const typename ArgType::cpptype &value, typename AggState::AtomicT *state) { LOG(FATAL) << "Not implemented"; @@ -81,6 +86,11 @@ class Sum { } template + inline static void InitUnsafe(typename AggState::T *state) { +*state = 0; + } + + template inline static void MergeArgUnsafe(const typename ArgType::cpptype &value, typename AggState::T *state) { *state += value; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1a6435f1/storage/AggregationOperationState.cpp -- diff --git a/storage/AggregationOperationState.cpp b/storage/AggregationOperationState.cpp index 00bb433..392e0f6 100644 --- a/storage/AggregationOperationState.cpp +++ b/storage/AggregationOperationState.cpp @@ -212,7 +212,7 @@ AggregationOperationState::AggregationOperationState( AggregationStateHashTableFactory::CreateResizable( hash_table_impl_type, group_by_types_, - estimated_num_entries, + estimated_num_entries * 2, group_by_handles, storage_manager_)); } else { @@ -384,12 +384,12 @@ bool AggregationOperationState::checkAggregatePartitioned( } } - // There are GROUP BYs without DISTINCT. Check if the estimated number of - // groups is large enough to warrant a partitioned aggregation. - return estimated_num_groups > - static_cast( - FLAGS_partition_aggregation_num_groups_threshold); - return false; +// // There are GROUP BYs without DISTINCT. Check if the estimated number of +// // groups is large enough to warrant a partitioned aggregation. +// return estimated_num_groups > +// static_cast( +// FLAGS_partition_aggregation_num_groups_threshold); + return true; } std::size_t AggregationOperationState::getNumInitializationPartitions() const { @@ -663,60 +663,10 @@ void AggregationOperationState::finalizeHashTableImplPartitioned( InsertDestination *output_destination) { PackedPayloadHashTable *hash_table = static_cast(partitioned_hashtable_.get()); +// std::cout << hash_table->numEntries() << "\n"; - // Each element of 'group_by_keys' is a vector of values for a particular - // group (which is also the prefix of the finalized Tuple for that group). - std::vector> group_by_keys; - - if (handles_.empty()) { -hash_table->forEachCompositeKeyInPartition( -partition_id, -[&](std::vector &group_by_key) -> void { - group_by_keys.emplace_back(std::move(group_by_key)); -}); - } - - // Collect per-aggregate finalized values. - std::vector> final_values; - for (std::size_t agg_idx = 0; agg_idx < handles_.size(); ++agg_idx) { -ColumnVector *agg_result_col = handles_[agg_idx]->finalizeHashTable( -*hash_table, agg_idx, &group_by_keys); -if (agg_result_col != nullptr) { - final_values.emplace_back(agg_result_col); -} - } -// hash_table->destroyPayload(); - - std::vector> grou
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/agg-expr [created] 38987a5cf Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/38987a5c Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/38987a5c Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/38987a5c Branch: refs/heads/agg-expr Commit: 38987a5cf56fce23dcb31c3f0a83d050035eae12 Parents: 1572762 Author: Jianqiao Zhu Authored: Wed Feb 22 13:58:08 2017 -0600 Committer: Jianqiao Zhu Committed: Wed Feb 22 13:58:08 2017 -0600 -- expressions/aggregation/AggFunc.hpp| 149 + expressions/aggregation/CMakeLists.txt | 10 + storage/CMakeLists.txt | 3 +- storage/CollisionFreeVectorTable.cpp | 276 +++- storage/CollisionFreeVectorTable.hpp | 495 ++-- utility/BoolVector.hpp | 148 + utility/CMakeLists.txt | 4 + 7 files changed, 451 insertions(+), 634 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/38987a5c/expressions/aggregation/AggFunc.hpp -- diff --git a/expressions/aggregation/AggFunc.hpp b/expressions/aggregation/AggFunc.hpp new file mode 100644 index 000..ef6179d --- /dev/null +++ b/expressions/aggregation/AggFunc.hpp @@ -0,0 +1,149 @@ +/** + * 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_EXPRESSIONS_AGGREGATION_AGG_FUNC_HPP_ +#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGG_FUNC_HPP_ + +#include +#include +#include +#include + +#include "expressions/aggregation/AggregationID.hpp" +#include "utility/Macros.hpp" +#include "types/IntType.hpp" +#include "types/LongType.hpp" +#include "types/FloatType.hpp" +#include "types/DoubleType.hpp" + +#include "glog/logging.h" + +namespace quickstep { + +class ColumnVector; +class StorageManager; +class Type; + +/** \addtogroup Expressions + * @{ + */ + +struct InvalidType {}; + +template +struct is_different : std::true_type {}; + +template +struct is_different : std::false_type {}; + +class Sum { + public: + Sum() {} + + template + struct AggState { +typedef InvalidType T; +typedef InvalidType AtomicT; +typedef InvalidType ResultT; + }; + + template + struct HasAtomicImpl : + is_different::AtomicT> {}; + + template + inline static void MergeArgAtomic(const typename ArgType::cpptype &value, +typename AggState::AtomicT *state); + + template + inline static void FinalizeAtomic(const typename AggState::AtomicT &state, +typename AggState::ResultT *result) { +*result = state.load(std::memory_order_relaxed); + } + + private: + DISALLOW_COPY_AND_ASSIGN(Sum); +}; + +//-- +// Implementation of Sum for IntType +template <> +struct Sum::AggState { + typedef std::int64_t T; + typedef std::atomic AtomicT; + typedef std::int64_t ResultT; +}; + +template <> +inline void Sum::MergeArgAtomic(const IntType::cpptype &value, + AggState::AtomicT *state) { + state->fetch_add(value, std::memory_order_relaxed); +} + +//-- +// Implementation of Sum for LongType +template <> +struct Sum::AggState { + typedef std::int64_t T; + typedef std::atomic AtomicT; + typedef std::int64_t ResultT; +}; + +template <> +inline void Sum::MergeArgAtomic(const LongType::cpptype &value, + AggState::AtomicT *state) { + state->fetch_add(value, std::memory_order_relaxed); +} + +//-- +// Implementation of Sum for FloatType +template <> +struct Sum::AggState { + typedef double T; + typedef std::atomic AtomicT; + typedef double ResultT; +}; + +templat
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 60519429e -> dee650f64 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/dee650f6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/dee650f6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/dee650f6 Branch: refs/heads/collision-free-agg Commit: dee650f64d7209aff329b4e79dce8737ff229727 Parents: 6051942 Author: Jianqiao Zhu Authored: Sat Feb 4 15:33:25 2017 -0600 Committer: Jianqiao Zhu Committed: Sat Feb 4 15:33:25 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 2 +- query_optimizer/ExecutionGenerator.cpp | 24 +- query_optimizer/ExecutionGenerator.hpp | 14 +- .../FinalizeAggregationOperator.cpp | 2 +- .../InitializeAggregationOperator.cpp | 2 +- storage/AggregationOperationState.cpp | 98 storage/AggregationOperationState.hpp | 34 ++- storage/CollisionFreeVectorTable.cpp| 28 ++- storage/CollisionFreeVectorTable.hpp| 231 ++- storage/HashTableBase.hpp | 10 +- storage/HashTableFactory.hpp| 27 ++- storage/PackedPayloadHashTable.cpp | 2 +- storage/PackedPayloadHashTable.hpp | 213 - storage/ValueAccessorMultiplexer.hpp| 42 14 files changed, 570 insertions(+), 159 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/dee650f6/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index ca2e35d..73b826f 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -58,7 +58,7 @@ void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( } static_cast(distinctify_hash_table) - ->upsertValueAccessor({}, concatenated_ids, accessor_mux); + ->upsertValueAccessorCompositeKey({}, concatenated_ids, accessor_mux); } } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/dee650f6/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index c047b67..a512e6f 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -377,7 +377,7 @@ void ExecutionGenerator::dropAllTemporaryRelations() { bool ExecutionGenerator::canUseCollisionFreeAggregation( const P::AggregatePtr &aggregate, const std::size_t estimated_num_groups, -std::size_t *exact_num_groups) const { +std::size_t *max_num_groups) const { // Supports only single group-by key. if (aggregate->grouping_expressions().size() != 1) { return false; @@ -421,9 +421,13 @@ bool ExecutionGenerator::canUseCollisionFreeAggregation( return false; } - // TODO + // TODO(jianqiao): + // 1. Handle the case where min_cpp_value is below 0 or far greater than 0. + // 2. Reason about the upbound (e.g. by checking memory size) instead of + //hardcoding it here. + const std::int64_t kGroupSizeUpbound = 10; if (min_cpp_value < 0 || - max_cpp_value > 10 || + max_cpp_value > kGroupSizeUpbound || max_cpp_value / static_cast(estimated_num_groups) > 256.0) { return false; } @@ -436,6 +440,7 @@ bool ExecutionGenerator::canUseCollisionFreeAggregation( return false; } +// TODO(jianqiao): Support AggregationID::AVG. switch (agg_func->getAggregate().getAggregationID()) { case AggregationID::kCount: // Fall through case AggregationID::kSum: @@ -450,7 +455,16 @@ bool ExecutionGenerator::canUseCollisionFreeAggregation( } if (arguments.size() == 1) { - switch (arguments.front()->getValueType().getTypeID()) { + const Type &arg_type = arguments.front()->getValueType(); + + // TODO(jianqiao): we need a bit more work in CollisionFreeVectorTable to + // support nullable argument types. That is, we need a bit vector there + // for each aggregation handle to indicate whether the state is NULL. + if (arg_type.isNullable()) { +return false; + } + + switch (arg_type.getTypeID()) { case TypeID::kInt: // Fall through case TypeID::kLong: case TypeID::kFloat: @@ -462,7 +476,7 @@ bool ExecutionGenerator::canUseCollisionFreeAggregation( } }
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 1e7a92a94 -> 60519429e Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/60519429 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/60519429 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/60519429 Branch: refs/heads/collision-free-agg Commit: 60519429e4301ecd21755d3b79bee64a79dcc86c Parents: 1e7a92a Author: Jianqiao Zhu Authored: Sat Feb 4 00:03:22 2017 -0600 Committer: Jianqiao Zhu Committed: Sat Feb 4 00:03:22 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 4 +- .../aggregation/AggregationConcreteHandle.hpp | 13 + expressions/aggregation/AggregationHandle.hpp | 61 +--- .../aggregation/AggregationHandleAvg.cpp| 4 +- .../aggregation/AggregationHandleAvg.hpp| 5 +- .../aggregation/AggregationHandleCount.cpp | 4 +- .../aggregation/AggregationHandleCount.hpp | 12 ++-- .../aggregation/AggregationHandleMax.cpp| 4 +- .../aggregation/AggregationHandleMax.hpp| 5 +- .../aggregation/AggregationHandleMin.cpp| 4 +- .../aggregation/AggregationHandleMin.hpp| 2 +- .../aggregation/AggregationHandleSum.cpp| 4 +- .../aggregation/AggregationHandleSum.hpp| 2 +- storage/AggregationOperationState.cpp | 43 -- storage/AggregationOperationState.hpp | 20 +-- storage/CollisionFreeVectorTable.cpp| 10 ++-- storage/CollisionFreeVectorTable.hpp| 2 +- storage/HashTableBase.hpp | 2 +- storage/PackedPayloadHashTable.cpp | 8 +-- storage/PackedPayloadHashTable.hpp | 2 +- 20 files changed, 117 insertions(+), 94 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/60519429/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index bbce29f..ca2e35d 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -50,8 +50,8 @@ AggregationStateHashTableBase* AggregationConcreteHandle::createDistinctifyHashT void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( const std::vector &argument_ids, const std::vector &key_ids, -AggregationStateHashTableBase *distinctify_hash_table, -ValueAccessorMultiplexer *accessor_mux) const { +const ValueAccessorMultiplexer &accessor_mux, +AggregationStateHashTableBase *distinctify_hash_table) const { std::vector concatenated_ids(key_ids); for (const MultiSourceAttributeId &arg_id : argument_ids) { concatenated_ids.emplace_back(arg_id); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/60519429/expressions/aggregation/AggregationConcreteHandle.hpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.hpp b/expressions/aggregation/AggregationConcreteHandle.hpp index c8d61ff..c6859e5 100644 --- a/expressions/aggregation/AggregationConcreteHandle.hpp +++ b/expressions/aggregation/AggregationConcreteHandle.hpp @@ -95,15 +95,6 @@ class HashTableStateUpserter { **/ class AggregationConcreteHandle : public AggregationHandle { public: - /** - * @brief Default implementaion for AggregationHandle::accumulateNullary(). - */ - AggregationState* accumulateNullary( - const std::size_t num_tuples) const override { -LOG(FATAL) << "Called accumulateNullary on an AggregationHandle that " - << "takes at least one argument."; - } - AggregationStateHashTableBase* createDistinctifyHashTable( const HashTableImplType hash_table_impl, const std::vector &key_types, @@ -113,8 +104,8 @@ class AggregationConcreteHandle : public AggregationHandle { void insertValueAccessorIntoDistinctifyHashTable( const std::vector &argument_ids, const std::vector &key_ids, - AggregationStateHashTableBase *distinctify_hash_table, - ValueAccessorMultiplexer *accessor_mux) const override; + const ValueAccessorMultiplexer &accessor_mux, + AggregationStateHashTableBase *distinctify_hash_table) const override; void blockUpdate() override { block_update_ = true; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/60519429/expressions/aggregation/AggregationHandle.hpp -- diff --git a/expressions/aggregation/AggregationHandle.hpp b/e
[3/3] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/1e7a92a9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/1e7a92a9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/1e7a92a9 Branch: refs/heads/collision-free-agg Commit: 1e7a92a94e0076d89151ea4a2ab4f68caa0572c0 Parents: 3bcb5c8 Author: Jianqiao Zhu Authored: Fri Feb 3 22:44:37 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Feb 3 22:44:37 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 4 +- .../aggregation/AggregationConcreteHandle.hpp | 21 +- expressions/aggregation/CMakeLists.txt | 2 +- storage/AggregationOperationState.cpp | 31 +- storage/CMakeLists.txt | 24 +- .../CollisionFreeAggregationStateHashTable.cpp | 285 --- .../CollisionFreeAggregationStateHashTable.hpp | 621 -- storage/CollisionFreeVectorTable.cpp| 283 +++ storage/CollisionFreeVectorTable.hpp| 621 ++ storage/HashTableFactory.hpp| 8 +- .../PackedPayloadAggregationStateHashTable.cpp | 439 -- .../PackedPayloadAggregationStateHashTable.hpp | 805 --- storage/PackedPayloadHashTable.cpp | 436 ++ storage/PackedPayloadHashTable.hpp | 798 ++ 14 files changed, 2180 insertions(+), 2198 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e7a92a9/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index 5fd7e0f..bbce29f 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -24,7 +24,7 @@ #include "catalog/CatalogTypedefs.hpp" #include "storage/HashTableFactory.hpp" -#include "storage/PackedPayloadAggregationStateHashTable.hpp" +#include "storage/PackedPayloadHashTable.hpp" #include "storage/ValueAccessorMultiplexer.hpp" namespace quickstep { @@ -57,7 +57,7 @@ void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( concatenated_ids.emplace_back(arg_id); } - static_cast(distinctify_hash_table) + static_cast(distinctify_hash_table) ->upsertValueAccessor({}, concatenated_ids, accessor_mux); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e7a92a9/expressions/aggregation/AggregationConcreteHandle.hpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.hpp b/expressions/aggregation/AggregationConcreteHandle.hpp index 5b49d0d..c8d61ff 100644 --- a/expressions/aggregation/AggregationConcreteHandle.hpp +++ b/expressions/aggregation/AggregationConcreteHandle.hpp @@ -29,7 +29,7 @@ #include "expressions/aggregation/AggregationHandle.hpp" #include "expressions/aggregation/AggregationID.hpp" #include "storage/HashTableBase.hpp" -#include "storage/PackedPayloadAggregationStateHashTable.hpp" +#include "storage/PackedPayloadHashTable.hpp" #include "storage/ValueAccessorMultiplexer.hpp" #include "threading/SpinMutex.hpp" #include "types/TypedValue.hpp" @@ -151,7 +151,7 @@ class AggregationConcreteHandle : public AggregationHandle { const std::size_t index, const std::vector &group_key) const { const std::uint8_t *group_state = -static_cast(hash_table) +static_cast(hash_table) .getSingleCompositeKey(group_key, index); DCHECK(group_state != nullptr) << "Could not find entry for specified group_key in HashTable"; @@ -217,8 +217,7 @@ StateT* AggregationConcreteHandle:: }; const auto &hash_table = - static_cast( - distinctify_hash_table); + static_cast(distinctify_hash_table); // Invoke the lambda function "aggregate_functor" on each key from the // distinctify hash table. hash_table.forEach(&aggregate_functor); @@ -233,9 +232,8 @@ void AggregationConcreteHandle:: const std::size_t index, AggregationStateHashTableBase *aggregation_hash_table) const { const HandleT &handle = static_cast(*this); - PackedPayloadSeparateChainingAggregationStateHashTable *target_hash_table = - static_cast( - aggregation_hash_table); + PackedPayloadHashTable *target_hash_table = + static_cast(aggregation_hash_table); // A lambda function which will be called on each key-value pair from the // distinctify hash table. @@ -256,9 +254,8 @@ void AggregationConcreteHandle:: target_hash_table->upsertCompositeKey(key, &upserter, ind
[1/3] incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 3bcb5c892 -> 1e7a92a94 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e7a92a9/storage/PackedPayloadHashTable.cpp -- diff --git a/storage/PackedPayloadHashTable.cpp b/storage/PackedPayloadHashTable.cpp new file mode 100644 index 000..adf4b5c --- /dev/null +++ b/storage/PackedPayloadHashTable.cpp @@ -0,0 +1,436 @@ +/** + * 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 "storage/PackedPayloadHashTable.hpp" + +namespace quickstep { + +PackedPayloadHashTable::PackedPayloadHashTable( +const std::vector &key_types, +const std::size_t num_entries, +const std::vector &handles, +StorageManager *storage_manager) +: key_types_(key_types), + num_handles_(handles.size()), + handles_(handles), + total_payload_size_(ComputeTotalPayloadSize(handles)), + storage_manager_(storage_manager), + kBucketAlignment(alignof(std::atomic)), + kValueOffset(sizeof(std::atomic) + sizeof(std::size_t)), + key_manager_(key_types_, kValueOffset + total_payload_size_), + bucket_size_(ComputeBucketSize(key_manager_.getFixedKeySize())) { + std::size_t payload_offset_running_sum = sizeof(SpinMutex); + for (const auto *handle : handles) { +payload_offsets_.emplace_back(payload_offset_running_sum); +payload_offset_running_sum += handle->getPayloadSize(); + } + + // NOTE(jianqiao): Potential memory leak / double freeing by copying from + // init_payload to buckets if payload contains out of line data. + init_payload_ = + static_cast(calloc(this->total_payload_size_, 1)); + DCHECK(init_payload_ != nullptr); + + for (std::size_t i = 0; i < num_handles_; ++i) { +handles_[i]->initPayload(init_payload_ + payload_offsets_[i]); + } + + // Bucket size always rounds up to the alignment requirement of the atomic + // size_t "next" pointer at the front or a ValueT, whichever is larger. + // + // Give base HashTable information about what key components are stored + // inline from 'key_manager_'. + setKeyInline(key_manager_.getKeyInline()); + + // Pick out a prime number of slots and calculate storage requirements. + std::size_t num_slots_tmp = + get_next_prime_number(num_entries * kHashTableLoadFactor); + std::size_t required_memory = + sizeof(Header) + num_slots_tmp * sizeof(std::atomic) + + (num_slots_tmp / kHashTableLoadFactor) * + (bucket_size_ + key_manager_.getEstimatedVariableKeySize()); + std::size_t num_storage_slots = + this->storage_manager_->SlotsNeededForBytes(required_memory); + if (num_storage_slots == 0) { +FATAL_ERROR( +"Storage requirement for SeparateChainingHashTable " +"exceeds maximum allocation size."); + } + + // Get a StorageBlob to hold the hash table. + const block_id blob_id = + this->storage_manager_->createBlob(num_storage_slots); + this->blob_ = this->storage_manager_->getBlobMutable(blob_id); + + void *aligned_memory_start = this->blob_->getMemoryMutable(); + std::size_t available_memory = num_storage_slots * kSlotSizeBytes; + if (align(alignof(Header), +sizeof(Header), +aligned_memory_start, +available_memory) == nullptr) { +// With current values from StorageConstants.hpp, this should be +// impossible. A blob is at least 1 MB, while a Header has alignment +// requirement of just kCacheLineBytes (64 bytes). +FATAL_ERROR( +"StorageBlob used to hold resizable " +"SeparateChainingHashTable is too small to meet alignment " +"requirements of SeparateChainingHashTable::Header."); + } else if (aligned_memory_start != this->blob_->getMemoryMutable()) { +// This should also be impossible, since the StorageManager allocates slots +// aligned to kCacheLineBytes. +DEV_WARNING("StorageBlob memory adjusted by " +<< (num_storage_slots * kSlotSizeBytes - available_memory) +<< " bytes to meet alignment requirement for " +<< "SeparateChainingHashTable::Header."); + } + + // Locate the header. + header_ = static
[2/3] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1e7a92a9/storage/CollisionFreeVectorTable.hpp -- diff --git a/storage/CollisionFreeVectorTable.hpp b/storage/CollisionFreeVectorTable.hpp new file mode 100644 index 000..25f7786 --- /dev/null +++ b/storage/CollisionFreeVectorTable.hpp @@ -0,0 +1,621 @@ +/** + * 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_STORAGE_COLLISION_FREE_AGGREGATION_STATE_HASH_TABLE_HPP_ +#define QUICKSTEP_STORAGE_COLLISION_FREE_AGGREGATION_STATE_HASH_TABLE_HPP_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "catalog/CatalogTypedefs.hpp" +#include "expressions/aggregation/AggregationHandle.hpp" +#include "expressions/aggregation/AggregationID.hpp" +#include "storage/HashTableBase.hpp" +#include "storage/StorageBlob.hpp" +#include "storage/StorageConstants.hpp" +#include "storage/ValueAccessor.hpp" +#include "storage/ValueAccessorMultiplexer.hpp" +#include "types/Type.hpp" +#include "types/TypeID.hpp" +#include "types/TypedValue.hpp" +#include "types/containers/ColumnVector.hpp" +#include "utility/BarrieredReadWriteConcurrentBitVector.hpp" +#include "utility/Macros.hpp" + +#include "glog/logging.h" + +namespace quickstep { + +class ColumnVectorsValueAccessor; +class StorageMnager; + +/** \addtogroup Storage + * @{ + */ + +class CollisionFreeVectorTable : public AggregationStateHashTableBase { + public: + CollisionFreeVectorTable( + const std::vector &key_types, + const std::size_t num_entries, + const std::vector &handles, + StorageManager *storage_manager); + + ~CollisionFreeVectorTable() override; + + void destroyPayload() override; + + inline std::size_t getNumInitializationPartitions() const { +return num_init_partitions_; + } + + inline std::size_t getNumFinalizationPartitions() const { +return num_finalize_partitions_; + } + + inline std::size_t getNumTuplesInPartition( + const std::size_t partition_id) const { +const std::size_t start_position = +calculatePartitionStartPosition(partition_id); +const std::size_t end_position = +calculatePartitionEndPosition(partition_id); +return existence_map_->onesCountInRange(start_position, end_position); + } + + inline void initialize(const std::size_t partition_id) { +const std::size_t memory_segment_size = +(memory_size_ + num_init_partitions_ - 1) / num_init_partitions_; +const std::size_t memory_start = memory_segment_size * partition_id; +std::memset(reinterpret_cast(blob_->getMemoryMutable()) + memory_start, +0, +std::min(memory_segment_size, memory_size_ - memory_start)); + } + + bool upsertValueAccessor( + const std::vector> &argument_ids, + const std::vector &key_ids, + ValueAccessorMultiplexer *accessor_mux) override; + + void finalizeKey(const std::size_t partition_id, + NativeColumnVector *output_cv) const; + + void finalizeState(const std::size_t partition_id, + std::size_t handle_id, + NativeColumnVector *output_cv) const; + + private: + inline static std::size_t CacheLineAlignedBytes(const std::size_t actual_bytes) { +return (actual_bytes + kCacheLineBytes - 1) / kCacheLineBytes * kCacheLineBytes; + } + + inline std::size_t calculatePartitionLength() const { +const std::size_t partition_length = +(num_entries_ + num_finalize_partitions_ - 1) / num_finalize_partitions_; +DCHECK_GE(partition_length, 0u); +return partition_length; + } + + inline std::size_t calculatePartitionStartPosition( + const std::size_t partition_id) const { +return calculatePartitionLength() * partition_id; + } + + inline std::size_t calculatePartitionEndPosition( + const std::size_t partition_id) const { +return std::min(calculatePartitionLength() * (partition_id + 1), +num_entries_); + } + + template + inline void upsertValueAccessorDispatchHelper( + const bool is_key_nullable, + const bool is_argument_nullable, + ArgTypes &&...args); + + templat
[09/10] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3bcb5c89/storage/PackedPayloadAggregationStateHashTable.hpp -- diff --git a/storage/PackedPayloadAggregationStateHashTable.hpp b/storage/PackedPayloadAggregationStateHashTable.hpp index 8364bb4..85d4f8a 100644 --- a/storage/PackedPayloadAggregationStateHashTable.hpp +++ b/storage/PackedPayloadAggregationStateHashTable.hpp @@ -40,6 +40,7 @@ #include "storage/StorageManager.hpp" #include "storage/TupleReference.hpp" #include "storage/ValueAccessor.hpp" +#include "storage/ValueAccessorMultiplexer.hpp" #include "storage/ValueAccessorUtil.hpp" #include "threading/SpinMutex.hpp" #include "threading/SpinSharedMutex.hpp" @@ -73,10 +74,9 @@ class PackedPayloadSeparateChainingAggregationStateHashTable void destroyPayload() override; bool upsertValueAccessor( - const std::vector> &argument_ids, - const std::vector &key_attr_ids, - ValueAccessor *accessor, - ColumnVectorsValueAccessor *aux_accessor = nullptr) override; + const std::vector> &argument_ids, + const std::vector &key_ids, + ValueAccessorMultiplexer *accessor_mux) override; inline block_id getBlobId() const { return blob_->getID(); @@ -142,12 +142,12 @@ class PackedPayloadSeparateChainingAggregationStateHashTable const std::vector &key, const std::size_t variable_key_size); - template + template inline bool upsertValueAccessorCompositeKeyInternal( - const std::vector> &argument_ids, - const std::vector &key_attr_ids, - ValueAccessor *accessor, - ColumnVectorsValueAccessor *aux_accessor); + const std::vector> &argument_ids, + const std::vector &key_ids, + ValueAccessor *base_accessor, + ColumnVectorsValueAccessor *derived_accessor); // Generate a hash for a composite key by hashing each component of 'key' and // mixing their bits with CombineHashes(). @@ -170,20 +170,24 @@ class PackedPayloadSeparateChainingAggregationStateHashTable return total_payload_size; } - // Assign '*key_vector' with the attribute values specified by 'key_attr_ids' - // at the current position of 'accessor'. If 'check_for_null_keys' is true, - // stops and returns true if any of the values is null, otherwise returns - // false. - template + // Assign '*key_vector' with the attribute values specified by 'key_ids' at + // the current position of 'accessor'. If 'check_for_null_keys' is true, stops + // and returns true if any of the values is null, otherwise returns false. + template inline static bool GetCompositeKeyFromValueAccessor( - const ValueAccessorT &accessor, - const std::vector &key_attr_ids, - const bool check_for_null_keys, + const std::vector &key_ids, + const ValueAccessorT *accessor, + const ColumnVectorsValueAccessor *derived_accessor, std::vector *key_vector) { -for (std::vector::size_type key_idx = 0; - key_idx < key_attr_ids.size(); - ++key_idx) { - (*key_vector)[key_idx] = accessor.getTypedValue(key_attr_ids[key_idx]); +for (std::size_t key_idx = 0; key_idx < key_ids.size(); ++key_idx) { + const MultiSourceAttributeId &key_id = key_ids[key_idx]; + if (use_two_accessors && key_id.source == ValueAccessorSource::kDerived) { +(*key_vector)[key_idx] = derived_accessor->getTypedValue(key_id.attr_id); + } else { +(*key_vector)[key_idx] = accessor->getTypedValue(key_id.attr_id); + } if (check_for_null_keys && (*key_vector)[key_idx].isNull()) { return true; } @@ -623,22 +627,19 @@ inline std::uint8_t* PackedPayloadSeparateChainingAggregationStateHashTable return value; } -template +template inline bool PackedPayloadSeparateChainingAggregationStateHashTable ::upsertValueAccessorCompositeKeyInternal( -const std::vector> &argument_ids, -const std::vector &key_attr_ids, -ValueAccessor *accessor, -ColumnVectorsValueAccessor *aux_accessor) { +const std::vector> &argument_ids, +const std::vector &key_ids, +ValueAccessor *base_accessor, +ColumnVectorsValueAccessor *derived_accessor) { std::size_t variable_size; std::vector key_vector; - key_vector.resize(key_attr_ids.size()); - - // TODO(jianqiao): determine this bool value - const bool check_for_null_keys = true; + key_vector.resize(key_ids.size()); return InvokeOnAnyValueAccessor( - accessor, + base_accessor, [&](auto *accessor) -> bool { // NOLINT(build/c++11) bool continuing = true; while (continuing) { @@ -646,14 +647,14 @@ inline bool PackedPayloadSeparateChainingAggregationStateHashTable continuing = false; SpinSharedMutexSharedLock lock(resize_shared_mutex_); while (accessor->next()) { - if (has_aux_accessor) { -aux_accessor->next(); + if
[10/10] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3bcb5c89 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3bcb5c89 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3bcb5c89 Branch: refs/heads/collision-free-agg Commit: 3bcb5c89229329cbab07297b2130c08d69647fb1 Parents: 61f6903 Author: Jianqiao Zhu Authored: Fri Feb 3 21:27:51 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Feb 3 21:27:51 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 17 ++-- .../aggregation/AggregationConcreteHandle.hpp | 66 ++-- expressions/aggregation/AggregationHandle.hpp | 21 ++-- .../aggregation/AggregationHandleAvg.cpp| 49 + .../aggregation/AggregationHandleAvg.hpp| 17 ++-- .../aggregation/AggregationHandleCount.cpp | 49 - .../aggregation/AggregationHandleCount.hpp | 17 ++-- .../aggregation/AggregationHandleMax.cpp| 45 .../aggregation/AggregationHandleMax.hpp| 17 ++-- .../aggregation/AggregationHandleMin.cpp| 45 .../aggregation/AggregationHandleMin.hpp| 17 ++-- .../aggregation/AggregationHandleSum.cpp| 49 + .../aggregation/AggregationHandleSum.hpp| 17 ++-- expressions/aggregation/CMakeLists.txt | 14 ++- relational_operators/CMakeLists.txt | 1 + storage/AggregationOperationState.cpp | 102 ++- storage/AggregationOperationState.hpp | 23 ++--- storage/CMakeLists.txt | 11 +- .../CollisionFreeAggregationStateHashTable.cpp | 83 --- .../CollisionFreeAggregationStateHashTable.hpp | 8 +- storage/HashTableBase.hpp | 8 +- .../PackedPayloadAggregationStateHashTable.cpp | 23 +++-- .../PackedPayloadAggregationStateHashTable.hpp | 94 - storage/ValueAccessorMultiplexer.hpp| 94 + 24 files changed, 491 insertions(+), 396 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3bcb5c89/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index d28aa6e..5fd7e0f 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -23,9 +23,9 @@ #include #include "catalog/CatalogTypedefs.hpp" -#include "storage/HashTable.hpp" #include "storage/HashTableFactory.hpp" #include "storage/PackedPayloadAggregationStateHashTable.hpp" +#include "storage/ValueAccessorMultiplexer.hpp" namespace quickstep { @@ -48,16 +48,17 @@ AggregationStateHashTableBase* AggregationConcreteHandle::createDistinctifyHashT } void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( -const std::vector &argument_ids, -const std::vector &key_attr_ids, +const std::vector &argument_ids, +const std::vector &key_ids, AggregationStateHashTableBase *distinctify_hash_table, -ValueAccessor *accessor, -ColumnVectorsValueAccessor *aux_accessor) const { - std::vector combined_ids(key_attr_ids); - combined_ids.insert(combined_ids.end(), argument_ids.begin(), argument_ids.end()); +ValueAccessorMultiplexer *accessor_mux) const { + std::vector concatenated_ids(key_ids); + for (const MultiSourceAttributeId &arg_id : argument_ids) { +concatenated_ids.emplace_back(arg_id); + } static_cast(distinctify_hash_table) - ->upsertValueAccessor({}, combined_ids, accessor, aux_accessor); + ->upsertValueAccessor({}, concatenated_ids, accessor_mux); } } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3bcb5c89/expressions/aggregation/AggregationConcreteHandle.hpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.hpp b/expressions/aggregation/AggregationConcreteHandle.hpp index 82aba66..5b49d0d 100644 --- a/expressions/aggregation/AggregationConcreteHandle.hpp +++ b/expressions/aggregation/AggregationConcreteHandle.hpp @@ -30,6 +30,7 @@ #include "expressions/aggregation/AggregationID.hpp" #include "storage/HashTableBase.hpp" #include "storage/PackedPayloadAggregationStateHashTable.hpp" +#include "storage/ValueAccessorMultiplexer.hpp" #include "threading/SpinMutex.hpp" #include "types/TypedValue.hpp" #include "types/containers/ColumnVector.hpp" @@ -110,11 +111,10 @@ class AggregationConcreteHandle : public AggregationHandle { StorageManager *storage_manager) const over
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 6986b2a3f -> 8a694213f Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8a694213 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8a694213 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8a694213 Branch: refs/heads/collision-free-agg Commit: 8a694213fd16082a886378b70effba45a2fc85cd Parents: 6986b2a Author: Jianqiao Zhu Authored: Fri Feb 3 14:45:14 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Feb 3 14:45:14 2017 -0600 -- query_optimizer/CMakeLists.txt | 2 +- query_optimizer/ExecutionGenerator.cpp | 8 +- relational_operators/CMakeLists.txt | 10 +- .../FinalizeAggregationOperator.cpp | 8 +- .../InitializeAggregationOperator.cpp | 78 .../InitializeAggregationOperator.hpp | 122 +++ .../InitializeAggregationStateOperator.cpp | 68 --- .../InitializeAggregationStateOperator.hpp | 103 relational_operators/WorkOrder.proto| 10 +- relational_operators/WorkOrderFactory.cpp | 13 ++ 10 files changed, 236 insertions(+), 186 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a694213/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 7f75264..a755832 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -126,7 +126,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_relationaloperators_DropTableOperator quickstep_relationaloperators_FinalizeAggregationOperator quickstep_relationaloperators_HashJoinOperator - quickstep_relationaloperators_InitializeAggregationStateOperator + quickstep_relationaloperators_InitializeAggregationOperator quickstep_relationaloperators_InsertOperator quickstep_relationaloperators_NestedLoopsJoinOperator quickstep_relationaloperators_RelationalOperator http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a694213/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index b2ce27b..04fb105 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -106,7 +106,7 @@ #include "relational_operators/DropTableOperator.hpp" #include "relational_operators/FinalizeAggregationOperator.hpp" #include "relational_operators/HashJoinOperator.hpp" -#include "relational_operators/InitializeAggregationStateOperator.hpp" +#include "relational_operators/InitializeAggregationOperator.hpp" #include "relational_operators/InsertOperator.hpp" #include "relational_operators/NestedLoopsJoinOperator.hpp" #include "relational_operators/RelationalOperator.hpp" @@ -1670,14 +1670,14 @@ void ExecutionGenerator::convertAggregate( } if (use_parallel_initialization) { -const QueryPlan::DAGNodeIndex initialize_aggregation_state_operator_index = +const QueryPlan::DAGNodeIndex initialize_aggregation_operator_index = execution_plan_->addRelationalOperator( -new InitializeAggregationStateOperator( +new InitializeAggregationOperator( query_handle_->query_id(), aggr_state_index)); execution_plan_->addDirectDependency(aggregation_operator_index, - initialize_aggregation_state_operator_index, + initialize_aggregation_operator_index, true /* is_pipeline_breaker */); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a694213/relational_operators/CMakeLists.txt -- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index bd20059..df4114d 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -47,9 +47,9 @@ add_library(quickstep_relationaloperators_FinalizeAggregationOperator FinalizeAggregationOperator.cpp FinalizeAggregationOperator.hpp) add_library(quickstep_relationaloperators_HashJoinOperator HashJoinOperator.cpp HashJoinOperator.hpp) -add_library(quickstep_relationaloperators_InitializeAggrega
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 963a60428 -> 12b112f85 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/12b112f8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/12b112f8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/12b112f8 Branch: refs/heads/collision-free-agg Commit: 12b112f851608c7f423cb9bca780b1be0489e55d Parents: 963a604 Author: Jianqiao Zhu Authored: Tue Jan 31 23:39:41 2017 -0600 Committer: Jianqiao Zhu Committed: Tue Jan 31 23:39:41 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 23 .../aggregation/AggregationConcreteHandle.hpp | 14 ++--- expressions/aggregation/AggregationHandle.hpp | 11 ++-- .../aggregation/AggregationHandleSum.cpp| 4 +- query_optimizer/ExecutionGenerator.cpp | 2 +- .../InitializeAggregationStateOperator.cpp | 2 +- storage/AggregationOperationState.cpp | 56 +--- storage/AggregationOperationState.hpp | 3 +- .../CollisionFreeAggregationStateHashTable.cpp | 3 +- 9 files changed, 76 insertions(+), 42 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/12b112f8/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index c3d133a..d28aa6e 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -48,21 +48,16 @@ AggregationStateHashTableBase* AggregationConcreteHandle::createDistinctifyHashT } void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( +const std::vector &argument_ids, +const std::vector &key_attr_ids, +AggregationStateHashTableBase *distinctify_hash_table, ValueAccessor *accessor, -const std::vector &key_ids, -AggregationStateHashTableBase *distinctify_hash_table) const { - // If the key-value pair is already there, we don't need to update the value, - // which should always be "true". I.e. the value is just a placeholder. -// AggregationStateFastHashTable *hash_table = -// static_cast(distinctify_hash_table); -// if (key_ids.size() == 1) { -//hash_table->upsertValueAccessorFast( -//key_ids, accessor, key_ids[0], true /* check_for_null_keys */); -// } else { -//std::vector empty_args {kInvalidAttributeID}; -//hash_table->upsertValueAccessorCompositeKeyFast( -//empty_args, accessor, key_ids, true /* check_for_null_keys */); -// } +ColumnVectorsValueAccessor *aux_accessor) const { + std::vector combined_ids(key_attr_ids); + combined_ids.insert(combined_ids.end(), argument_ids.begin(), argument_ids.end()); + + static_cast(distinctify_hash_table) + ->upsertValueAccessor({}, combined_ids, accessor, aux_accessor); } } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/12b112f8/expressions/aggregation/AggregationConcreteHandle.hpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.hpp b/expressions/aggregation/AggregationConcreteHandle.hpp index 04be232..c49f597 100644 --- a/expressions/aggregation/AggregationConcreteHandle.hpp +++ b/expressions/aggregation/AggregationConcreteHandle.hpp @@ -110,9 +110,11 @@ class AggregationConcreteHandle : public AggregationHandle { StorageManager *storage_manager) const override; void insertValueAccessorIntoDistinctifyHashTable( + const std::vector &argument_ids, + const std::vector &key_attr_ids, + AggregationStateHashTableBase *distinctify_hash_table, ValueAccessor *accessor, - const std::vector &key_ids, - AggregationStateHashTableBase *distinctify_hash_table) const override; + ColumnVectorsValueAccessor *aux_accessor = nullptr) const override; void blockUpdate() override { block_update_ = true; @@ -127,11 +129,11 @@ class AggregationConcreteHandle : public AggregationHandle { : AggregationHandle(agg_id) {} template - StateT* aggregateOnDistinctifyHashTableForSingleUnaryHelperFast( + StateT* aggregateOnDistinctifyHashTableForSingleUnaryHelper( const AggregationStateHashTableBase &distinctify_hash_table) const; template - void aggregateOnDistinctifyHashTableForGroupByUnaryHelperFast( + void aggregateOnDistinctifyHashTableForGroupByUnaryHelper( const AggregationStateHashTableBase &distinctify_hash_table, AggregationStateHashTableBase *hash_table, std::size_t index) const; @@
[2/2] incubator-quickstep git commit: updates
updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/963a6042 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/963a6042 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/963a6042 Branch: refs/heads/collision-free-agg Commit: 963a604288e158b953f99fac16ff03e0015d9860 Parents: 3fc85b2 Author: Jianqiao Zhu Authored: Tue Jan 31 21:52:01 2017 -0600 Committer: Jianqiao Zhu Committed: Tue Jan 31 21:52:01 2017 -0600 -- .../aggregation/AggregationHandleDistinct.cpp | 53 -- .../aggregation/AggregationHandleDistinct.hpp | 106 --- expressions/aggregation/CMakeLists.txt | 13 --- query_optimizer/ExecutionGenerator.cpp | 5 + storage/AggregationOperationState.cpp | 42 ++-- storage/CMakeLists.txt | 1 - 6 files changed, 38 insertions(+), 182 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/963a6042/expressions/aggregation/AggregationHandleDistinct.cpp -- diff --git a/expressions/aggregation/AggregationHandleDistinct.cpp b/expressions/aggregation/AggregationHandleDistinct.cpp deleted file mode 100644 index 1886335..000 --- a/expressions/aggregation/AggregationHandleDistinct.cpp +++ /dev/null @@ -1,53 +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 "expressions/aggregation/AggregationHandleDistinct.hpp" - -#include -#include -#include - -#include "catalog/CatalogTypedefs.hpp" -#include "storage/PackedPayloadAggregationStateHashTable.hpp" - -#include "types/TypedValue.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -class ColumnVector; - -ColumnVector* AggregationHandleDistinct::finalizeHashTable( -const AggregationStateHashTableBase &hash_table, -std::vector> *group_by_keys, -int index) const { - DCHECK(group_by_keys->empty()); - - const auto keys_retriever = [&group_by_keys](std::vector &group_by_key, - const std::uint8_t *dumb_placeholder) -> void { -group_by_keys->emplace_back(std::move(group_by_key)); - }; - static_cast( - hash_table).forEachCompositeKey(&keys_retriever); - - return nullptr; -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/963a6042/expressions/aggregation/AggregationHandleDistinct.hpp -- diff --git a/expressions/aggregation/AggregationHandleDistinct.hpp b/expressions/aggregation/AggregationHandleDistinct.hpp deleted file mode 100644 index 0d8905b..000 --- a/expressions/aggregation/AggregationHandleDistinct.hpp +++ /dev/null @@ -1,106 +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_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_DISTINCT_HPP_ -#define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_HANDLE_DISTINCT_HPP_ - -#include -#include -#include - -#include "catalog/CatalogTypedefs.hpp" -#include "expressions/aggregation/AggregationConcreteHandle.hpp" -#include "expressions/aggregation/AggregationID.hpp" -#include "storage/HashTableBase.hpp
[1/2] incubator-quickstep git commit: Updates for distinct
Repository: incubator-quickstep Updated Branches: refs/heads/collision-free-agg 34ea858db -> 963a60428 Updates for distinct Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3fc85b28 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3fc85b28 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3fc85b28 Branch: refs/heads/collision-free-agg Commit: 3fc85b28909fe49635325ea70d52d234ae2c957d Parents: 34ea858 Author: Jianqiao Zhu Authored: Tue Jan 31 21:05:13 2017 -0600 Committer: Jianqiao Zhu Committed: Tue Jan 31 21:05:13 2017 -0600 -- .../aggregation/AggregationConcreteHandle.cpp | 44 .../aggregation/AggregationConcreteHandle.hpp | 108 -- expressions/aggregation/AggregationHandle.hpp | 111 ++- .../aggregation/AggregationHandleDistinct.cpp | 4 +- .../aggregation/AggregationHandleSum.cpp| 17 +++ .../aggregation/AggregationHandleSum.hpp| 21 storage/AggregationOperationState.cpp | 13 +-- .../PackedPayloadAggregationStateHashTable.hpp | 94 +++- 8 files changed, 381 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fc85b28/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp index 3151a91..c3d133a 100644 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ b/expressions/aggregation/AggregationConcreteHandle.cpp @@ -19,6 +19,50 @@ #include "expressions/aggregation/AggregationConcreteHandle.hpp" +#include +#include + +#include "catalog/CatalogTypedefs.hpp" +#include "storage/HashTable.hpp" +#include "storage/HashTableFactory.hpp" +#include "storage/PackedPayloadAggregationStateHashTable.hpp" + namespace quickstep { +class StorageManager; +class Type; +class ValueAccessor; + +AggregationStateHashTableBase* AggregationConcreteHandle::createDistinctifyHashTable( +const HashTableImplType hash_table_impl, +const std::vector &key_types, +const std::size_t estimated_num_distinct_keys, +StorageManager *storage_manager) const { + // Create a hash table with key types as key_types and value type as bool. + return AggregationStateHashTableFactory::CreateResizable( + hash_table_impl, + key_types, + estimated_num_distinct_keys, + {}, + storage_manager); +} + +void AggregationConcreteHandle::insertValueAccessorIntoDistinctifyHashTable( +ValueAccessor *accessor, +const std::vector &key_ids, +AggregationStateHashTableBase *distinctify_hash_table) const { + // If the key-value pair is already there, we don't need to update the value, + // which should always be "true". I.e. the value is just a placeholder. +// AggregationStateFastHashTable *hash_table = +// static_cast(distinctify_hash_table); +// if (key_ids.size() == 1) { +//hash_table->upsertValueAccessorFast( +//key_ids, accessor, key_ids[0], true /* check_for_null_keys */); +// } else { +//std::vector empty_args {kInvalidAttributeID}; +//hash_table->upsertValueAccessorCompositeKeyFast( +//empty_args, accessor, key_ids, true /* check_for_null_keys */); +// } +} + } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fc85b28/expressions/aggregation/AggregationConcreteHandle.hpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.hpp b/expressions/aggregation/AggregationConcreteHandle.hpp index 93e9bd0..04be232 100644 --- a/expressions/aggregation/AggregationConcreteHandle.hpp +++ b/expressions/aggregation/AggregationConcreteHandle.hpp @@ -21,6 +21,7 @@ #define QUICKSTEP_EXPRESSIONS_AGGREGATION_AGGREGATION_CONCRETE_HANDLE_HPP_ #include +#include #include #include @@ -28,6 +29,7 @@ #include "expressions/aggregation/AggregationHandle.hpp" #include "expressions/aggregation/AggregationID.hpp" #include "storage/HashTableBase.hpp" +#include "storage/PackedPayloadAggregationStateHashTable.hpp" #include "threading/SpinMutex.hpp" #include "types/TypedValue.hpp" #include "types/containers/ColumnVector.hpp" @@ -101,10 +103,39 @@ class AggregationConcreteHandle : public AggregationHandle { << "takes at least one argument."; } + AggregationStateHashTableBase* createDistinctifyHashTable( + const HashTableImplType hash_table_impl, + const std::vector &key_types, + const std::size_t estimated_num_distinct_keys, + StorageManager *storage_manager) const override; + + void insertV
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/tpch-all-in-one 49ef7284a -> 27d43d54e Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/27d43d54 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/27d43d54 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/27d43d54 Branch: refs/heads/tpch-all-in-one Commit: 27d43d54ed0d4799b13d6513bc2cae97f7a558eb Parents: 49ef728 Author: Jianqiao Zhu Authored: Sun Jan 29 16:28:13 2017 -0600 Committer: Jianqiao Zhu Committed: Sun Jan 29 16:28:13 2017 -0600 -- query_optimizer/CMakeLists.txt | 1 + query_optimizer/ExecutionGenerator.cpp | 1 + query_optimizer/ExecutionGenerator.hpp | 2 + query_optimizer/PhysicalGenerator.cpp | 2 + query_optimizer/physical/HashJoin.hpp | 5 +- query_optimizer/rules/CMakeLists.txt| 15 ++ query_optimizer/rules/CoalesceLeftOuterJoin.cpp | 67 + query_optimizer/rules/CoalesceLeftOuterJoin.hpp | 60 query_optimizer/rules/SwapProbeBuild.cpp| 5 +- query_optimizer/rules/SwapProbeBuild.hpp| 20 ++- relational_operators/CMakeLists.txt | 21 +++ .../CoalesceAggregationStateOperator.cpp| 69 + .../CoalesceAggregationStateOperator.hpp| 146 +++ storage/AggregationOperationState.hpp | 1 + 14 files changed, 402 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/27d43d54/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 6091d2d..3b9f0c7 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -214,6 +214,7 @@ target_link_libraries(quickstep_queryoptimizer_PhysicalGenerator quickstep_queryoptimizer_logical_Logical quickstep_queryoptimizer_physical_Physical quickstep_queryoptimizer_rules_AttachLIPFilters + quickstep_queryoptimizer_rules_CoalesceLeftOuterJoin quickstep_queryoptimizer_rules_InjectJoinFilters quickstep_queryoptimizer_rules_PruneColumns quickstep_queryoptimizer_rules_PushDownLowCostDisjunctivePredicate http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/27d43d54/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index a86b1f3..ce40141 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -96,6 +96,7 @@ #include "relational_operators/AggregationOperator.hpp" #include "relational_operators/BuildHashOperator.hpp" #include "relational_operators/BuildLIPFilterOperator.hpp" +#include "relational_operators/CoalesceAggregationStateOperator.hpp" #include "relational_operators/CreateIndexOperator.hpp" #include "relational_operators/CreateTableOperator.hpp" #include "relational_operators/DeleteOperator.hpp" http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/27d43d54/query_optimizer/ExecutionGenerator.hpp -- diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp index 36f3bd7..b940550 100644 --- a/query_optimizer/ExecutionGenerator.hpp +++ b/query_optimizer/ExecutionGenerator.hpp @@ -264,6 +264,8 @@ class ExecutionGenerator { */ void convertHashJoin(const physical::HashJoinPtr &physical_plan); +// void convertHashLeftOuterJoinCoalesceZero(const physical::HashJoinPtr &physical_plan); + /** * @brief Converts a NestedLoopsJoin to a NestedLoopsJoin operator. * http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/27d43d54/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index 3828be6..9517ed6 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -27,6 +27,7 @@ #include "query_optimizer/logical/Logical.hpp" #include "query_optimizer/physical/Physical.hpp" #include "query_optimizer/rules/AttachLIPFilters.hpp" +#include "query_optimizer/rules/CoalesceLeftOuterJoin.hpp" #include "query_optimizer/rules/InjectJoinFilters.hpp" #include "query_optimizer/rules/PruneColumns.hpp" #include "query_optimizer/rules/PushDownLowCostDisjunctivePredicate.hpp" @@ -110,6 +11
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/reorder-attrs c2743f724 -> 9c14e86e3 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9c14e86e Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9c14e86e Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9c14e86e Branch: refs/heads/reorder-attrs Commit: 9c14e86e3567a9db642be357e3007c09b5e8cb5a Parents: c2743f7 Author: Jianqiao Zhu Authored: Sun Jan 29 00:56:30 2017 -0600 Committer: Jianqiao Zhu Committed: Sun Jan 29 00:56:30 2017 -0600 -- query_optimizer/PhysicalGenerator.cpp | 4 +-- relational_operators/HashJoinOperator.cpp | 39 ++ 2 files changed, 23 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c14e86e/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index dc2763d..e12f8be 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -46,7 +46,7 @@ namespace quickstep { namespace optimizer { DEFINE_bool(reorder_columns, true, -"Adjust the ordering of intermediate relations' attributes to improve " +"Adjust the ordering of intermediate relations' columns to improve " "copy performance."); DEFINE_bool(reorder_hash_joins, true, @@ -115,7 +115,7 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() { rules.emplace_back(new SwapProbeBuild()); } if (FLAGS_reorder_columns) { -// NOTE(jianqiao): This optimization is based on the fact that the intermediate +// NOTE(jianqiao): This optimization relies on the fact that the intermediate // relations all have SPLIT_ROW_STORE layouts. If this fact gets changed, the // optimization algorithm may need to be updated and the performance impact // should be re-evaluated. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9c14e86e/relational_operators/HashJoinOperator.cpp -- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index b72096c..64f73ea 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -547,7 +547,7 @@ void HashInnerJoinWorkOrder::executeWithoutCopyElision(ValueAccessor *probe_acce } void HashInnerJoinWorkOrder::executeWithCopyElision(ValueAccessor *probe_accessor) { - VectorsOfPairsJoinedTuplesCollector collector; + PairsOfVectorsJoinedTuplesCollector collector; if (join_key_attributes_.size() == 1) { hash_table_.getAllFromValueAccessor( probe_accessor, @@ -596,14 +596,14 @@ void HashInnerJoinWorkOrder::executeWithCopyElision(ValueAccessor *probe_accesso ++dest_attr; } - std::vector build_tids; - std::vector probe_tids; - for (std::pair + for (std::pair &build_block_entry : *collector.getJoinedTuples()) { BlockReference build_block = storage_manager_->getBlock(build_block_entry.first, build_relation_); const TupleStorageSubBlock &build_store = build_block->getTupleStorageSubBlock(); std::unique_ptr build_accessor(build_store.createValueAccessor()); +const std::vector &build_tids = build_block_entry.second.first; +const std::vector &probe_tids = build_block_entry.second.second; // Evaluate '*residual_predicate_', if any. // @@ -616,17 +616,17 @@ void HashInnerJoinWorkOrder::executeWithCopyElision(ValueAccessor *probe_accesso // hash join is below a reasonable threshold so that we don't blow up // temporary memory requirements to an unreasonable degree. if (residual_predicate_ != nullptr) { - VectorOfPairs filtered_matches; + PairOfVectors filtered_matches; - for (const std::pair &hash_match - : build_block_entry.second) { + for (std::size_t i = 0; i < build_tids.size(); ++i) { if (residual_predicate_->matchesForJoinedTuples(*build_accessor, build_relation_id, -hash_match.first, +build_tids[i], *probe_accessor, probe_relation_id, -hash_match.second)) { - filtered_matches.emplace_back(hash_match); +probe_tids[i])) { + filtered_
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/reorder-attrs 26c3db420 -> 4700b097b Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/4700b097 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/4700b097 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/4700b097 Branch: refs/heads/reorder-attrs Commit: 4700b097bb95b663cf47282cc77031377e54d28c Parents: 26c3db4 Author: Jianqiao Zhu Authored: Sat Jan 28 15:00:01 2017 -0600 Committer: Jianqiao Zhu Committed: Sat Jan 28 15:00:01 2017 -0600 -- query_optimizer/rules/ReorderColumns.cpp | 28 ++--- relational_operators/HashJoinOperator.cpp | 142 - relational_operators/HashJoinOperator.hpp | 4 + 3 files changed, 149 insertions(+), 25 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4700b097/query_optimizer/rules/ReorderColumns.cpp -- diff --git a/query_optimizer/rules/ReorderColumns.cpp b/query_optimizer/rules/ReorderColumns.cpp index e04b810..16a3750 100644 --- a/query_optimizer/rules/ReorderColumns.cpp +++ b/query_optimizer/rules/ReorderColumns.cpp @@ -54,17 +54,9 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input, // unchanged so that the output columns are ordered as specified by the user. // So here we use the flag "lock_ordering" to skip the first transformable // node (i.e. the first Selection or HashJoin). - bool skip_transform; - if (IsTransformable(input)) { -if (lock_ordering) { - skip_transform = true; - lock_ordering = false; -} else { - skip_transform = false; -} - } else { -skip_transform = true; - } + const bool is_not_transformable = !IsTransformable(input); + const bool skip_transform = lock_ordering || is_not_transformable; + lock_ordering = lock_ordering && is_not_transformable; if (skip_transform) { std::vector new_children; @@ -86,7 +78,9 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input, } std::reverse(nodes.begin(), nodes.end()); - // Analyze the attributes in the nodes. + // A greedy algorithm that reorders the output attributes based on the GEN/KILL + // intervals. This algorithm works well with SSB/TPCH queries and is not likely + // to make the plans worse for whatever queries. std::unordered_map base, gen, kill; const P::PhysicalPtr base_node = @@ -111,16 +105,6 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input, } } -// std::cout << "gen: \n"; -// for (const auto &pair : gen) { -//std::cout << pair.first << ": " << pair.second << "\n"; -// } -// -// std::cout << "kill: \n"; -// for (const auto &pair : kill) { -//std::cout << pair.first << ": " << pair.second << "\n"; -// } - const auto comparator = [&gen, &kill, &base](const E::NamedExpressionPtr &lhs, const E::NamedExpressionPtr &rhs) -> bool { const E::ExprId lhs_id = lhs->id(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4700b097/relational_operators/HashJoinOperator.cpp -- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index cda1465..67e7b97 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -470,16 +470,24 @@ void HashInnerJoinWorkOrder::execute() { base_accessor->createSharedTupleIdSequenceAdapterVirtual(*existence_map)); } + if (probe_accessor->getImplementationType() == ValueAccessor::Implementation::kSplitRowStore) { +executeWithCopyElision(probe_accessor.get()); + } else { +executeWithoutCopyElision(probe_accessor.get()); + } +} + +void HashInnerJoinWorkOrder::executeWithoutCopyElision(ValueAccessor *probe_accessor) { VectorsOfPairsJoinedTuplesCollector collector; if (join_key_attributes_.size() == 1) { hash_table_.getAllFromValueAccessor( -probe_accessor.get(), +probe_accessor, join_key_attributes_.front(), any_join_key_attributes_nullable_, &collector); } else { hash_table_.getAllFromValueAccessorCompositeKey( -probe_accessor.get(), +probe_accessor, join_key_attributes_, any_join_key_attributes_nullable_, &collector); @@ -530,7 +538,7 @@ void HashInnerJoinWorkOrder::execute() { temp_result.addColumn((*selection_cit)->getAllValuesForJoin(build_relation_id, build_accessor.get(),
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/exact-filter 8b70d662e -> 84e95cb29 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/84e95cb2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/84e95cb2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/84e95cb2 Branch: refs/heads/exact-filter Commit: 84e95cb2963ce7fbe7be08ae1029feba74a5dcbd Parents: 8b70d66 Author: Jianqiao Zhu Authored: Fri Jan 27 17:40:29 2017 -0600 Committer: Jianqiao Zhu Committed: Fri Jan 27 17:40:29 2017 -0600 -- query_optimizer/LIPFilterGenerator.cpp | 49 ++-- query_optimizer/LIPFilterGenerator.hpp | 4 +- .../physical/LIPFilterConfiguration.hpp | 280 +-- query_optimizer/rules/AttachLIPFilters.cpp | 18 +- query_optimizer/rules/InjectJoinFilters.cpp | 29 +- utility/PlanVisualizer.cpp | 4 +- utility/lip_filter/BitVectorExactFilter.hpp | 43 +-- utility/lip_filter/LIPFilter.proto | 7 +- utility/lip_filter/LIPFilterFactory.cpp | 30 +- 9 files changed, 303 insertions(+), 161 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84e95cb2/query_optimizer/LIPFilterGenerator.cpp -- diff --git a/query_optimizer/LIPFilterGenerator.cpp b/query_optimizer/LIPFilterGenerator.cpp index ef984d4..2ce2ea8 100644 --- a/query_optimizer/LIPFilterGenerator.cpp +++ b/query_optimizer/LIPFilterGenerator.cpp @@ -20,11 +20,13 @@ #include "query_optimizer/LIPFilterGenerator.hpp" #include +#include #include #include #include "catalog/CatalogAttribute.hpp" #include "query_execution/QueryContext.pb.h" +#include "query_optimizer/physical/LIPFilterConfiguration.hpp" #include "relational_operators/RelationalOperator.hpp" #include "types/Type.hpp" #include "utility/lip_filter/LIPFilter.hpp" @@ -47,7 +49,7 @@ void LIPFilterGenerator::registerAttributeMap( if (build_it != build_info_map.end()) { auto &map_entry = attribute_map_[node]; for (const auto &info : build_it->second) { - E::ExprId attr_id = info.build_attribute->id(); + E::ExprId attr_id = info->build_attribute()->id(); map_entry.emplace(attr_id, attribute_substitution_map.at(attr_id)); } } @@ -57,7 +59,7 @@ void LIPFilterGenerator::registerAttributeMap( if (probe_it != probe_info_map.end()) { auto &map_entry = attribute_map_[node]; for (const auto &info : probe_it->second) { - E::ExprId attr_id = info.probe_attribute->id(); + E::ExprId attr_id = info->probe_attribute()->id(); map_entry.emplace(attr_id, attribute_substitution_map.at(attr_id)); } } @@ -107,7 +109,7 @@ void LIPFilterGenerator::deployBuilderInternal( serialization::QueryContext *query_context_proto, const physical::PhysicalPtr &builder_node, const QueryPlan::DAGNodeIndex builder_operator_index, -const std::vector &build_info_vec) { +const std::vector &build_info_vec) { auto *lip_filter_deployment_info_proto = getLIPFilterDeploymentProto(builder_operator_index, query_context_proto); @@ -116,31 +118,37 @@ void LIPFilterGenerator::deployBuilderInternal( // Add the LIPFilter information into query context. const QueryContext::lip_filter_id lip_filter_id = query_context_proto->lip_filters_size(); serialization::LIPFilter *lip_filter_proto = query_context_proto->add_lip_filters(); -const CatalogAttribute *target_attr = builder_attribute_map.at(info.build_attribute->id()); +const CatalogAttribute *target_attr = +builder_attribute_map.at(info->build_attribute()->id()); const Type &attr_type = target_attr->getType(); -switch (info.filter_type) { +switch (info->filter_type()) { case LIPFilterType::kSingleIdentityHashFilter: { DCHECK(!attr_type.isVariableLength()); -DCHECK(!info.is_anti_filter); +const P::SingleIdentityHashFilterBuildInfo &sihf_info = +*std::static_pointer_cast(info); lip_filter_proto->set_lip_filter_type( serialization::LIPFilterType::SINGLE_IDENTITY_HASH_FILTER); -lip_filter_proto->SetExtension( -serialization::SingleIdentityHashFilter::filter_cardinality, info.filter_cardinality); -lip_filter_proto->SetExtension( -serialization::SingleIdentityHashFilter::attribute_size, attr_type.minimumByteLength()); + lip_filter_proto->SetExtension(serialization::SingleIdentityHashFilter::filter_cardinality, + sihf_info.filter_cardinality()); + lip_filter_proto->SetExtension(serialization::SingleIdentityHashFilter
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/exact-filter d52b91265 -> 8b70d662e Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8b70d662 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8b70d662 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8b70d662 Branch: refs/heads/exact-filter Commit: 8b70d662e46893a222372a0a8f2c4643fb3ccc48 Parents: d52b912 Author: Jianqiao Zhu Authored: Thu Jan 26 22:34:11 2017 -0600 Committer: Jianqiao Zhu Committed: Thu Jan 26 23:32:20 2017 -0600 -- query_optimizer/ExecutionGenerator.cpp | 7 ++ query_optimizer/LIPFilterGenerator.cpp | 2 - query_optimizer/LIPFilterGenerator.hpp | 2 + query_optimizer/PhysicalGenerator.cpp | 12 ++- .../cost_model/StarSchemaSimpleCostModel.cpp| 9 +- .../cost_model/StarSchemaSimpleCostModel.hpp| 103 +-- query_optimizer/physical/FilterJoin.hpp | 37 ++- query_optimizer/rules/CMakeLists.txt| 2 +- query_optimizer/rules/InjectJoinFilters.cpp | 103 +-- query_optimizer/rules/InjectJoinFilters.hpp | 24 - query_optimizer/tests/OptimizerTextTest.cpp | 2 + relational_operators/BuildLIPFilterOperator.cpp | 53 +++--- relational_operators/BuildLIPFilterOperator.hpp | 38 ++- relational_operators/CMakeLists.txt | 1 + relational_operators/WorkOrder.proto| 49 + relational_operators/WorkOrderFactory.cpp | 45 utility/lip_filter/BitVectorExactFilter.hpp | 12 ++- utility/lip_filter/LIPFilterDeployment.cpp | 2 - 18 files changed, 365 insertions(+), 138 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8b70d662/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 8249beb..ce1452e 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -617,6 +617,10 @@ void ExecutionGenerator::convertFilterJoin(const P::FilterJoinPtr &physical_plan 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 + // actual "concrete" input relation is B's probe side child, and B's build + // side becomes a LIPFilter that is attached to the BuildLIPFilterOperator + // created below. P::FilterJoinPtr filter_join; if (P::SomeFilterJoin::MatchesWithConditionalCast(build_physical, &filter_join)) { build_physical = filter_join->left(); @@ -638,6 +642,9 @@ void ExecutionGenerator::convertFilterJoin(const P::FilterJoinPtr &physical_plan const CatalogRelationInfo *build_relation_info = findRelationInfoOutputByPhysical(build_physical); + // Create a BuildLIPFilterOperator for the FilterJoin. This operator builds + // LIP filters that are applied properly in downstream operators to achieve + // the filter-join semantics. const QueryPlan::DAGNodeIndex build_filter_operator_index = execution_plan_->addRelationalOperator( new BuildLIPFilterOperator( http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8b70d662/query_optimizer/LIPFilterGenerator.cpp -- diff --git a/query_optimizer/LIPFilterGenerator.cpp b/query_optimizer/LIPFilterGenerator.cpp index a80c261..ef984d4 100644 --- a/query_optimizer/LIPFilterGenerator.cpp +++ b/query_optimizer/LIPFilterGenerator.cpp @@ -30,8 +30,6 @@ #include "utility/lip_filter/LIPFilter.hpp" #include "utility/lip_filter/LIPFilter.pb.h" -#include "google/protobuf/text_format.h" - #include "glog/logging.h" namespace quickstep { http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8b70d662/query_optimizer/LIPFilterGenerator.hpp -- diff --git a/query_optimizer/LIPFilterGenerator.hpp b/query_optimizer/LIPFilterGenerator.hpp index 43973cb..f6d931e 100644 --- a/query_optimizer/LIPFilterGenerator.hpp +++ b/query_optimizer/LIPFilterGenerator.hpp @@ -205,6 +205,8 @@ class LIPFilterGenerator { std::map, std::pair> lip_filter_builder_map_; + // Maps each relational operator's index to the attached LIPFilterDeployment's + // index and proto. std::map> lip_filter_deployment_protos_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8b70d662/query_optimizer/PhysicalGenerator.cpp ---
[2/2] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3a74a9fa Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3a74a9fa Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3a74a9fa Branch: refs/heads/output-attr-order Commit: 3a74a9fa61d913af7ed95a9b53f4f9486d17be5b Parents: f8089de Author: Jianqiao Zhu Authored: Tue Jan 10 09:13:40 2017 -0600 Committer: Jianqiao Zhu Committed: Tue Jan 10 09:13:40 2017 -0600 -- query_optimizer/rules/ReorderColumns.cpp | 2 +- relational_operators/HashJoinOperator.cpp | 443 + storage/StorageBlock.cpp | 110 +++--- 3 files changed, 227 insertions(+), 328 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3a74a9fa/query_optimizer/rules/ReorderColumns.cpp -- diff --git a/query_optimizer/rules/ReorderColumns.cpp b/query_optimizer/rules/ReorderColumns.cpp index c4f2aa1..8f139eb 100644 --- a/query_optimizer/rules/ReorderColumns.cpp +++ b/query_optimizer/rules/ReorderColumns.cpp @@ -137,7 +137,7 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input) { return lhs_id < rhs_id; }; - P::PhysicalPtr output = nodes.front()->children().front(); + P::PhysicalPtr output = applyInternal(nodes.front()->children().front()); for (const auto &node : nodes) { std::vector project_expressions; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3a74a9fa/relational_operators/HashJoinOperator.cpp -- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index cd1dc46..8ebb057 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -231,8 +231,7 @@ bool HashJoinOperator::getAllNonOuterJoinWorkOrders( hash_table, output_destination, storage_manager, - CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context), - op_index_), + CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)), op_index_); } started_ = true; @@ -253,8 +252,7 @@ bool HashJoinOperator::getAllNonOuterJoinWorkOrders( hash_table, output_destination, storage_manager, -CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context), -op_index_), +CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)), op_index_); ++num_workorders_generated_; } // end while @@ -453,19 +451,11 @@ serialization::WorkOrder* HashJoinOperator::createOuterJoinWorkOrderProto(const void HashInnerJoinWorkOrder::execute() { - auto *container = simple_profiler.getContainer(); - auto *all_line = container->getEventLine("all"); - all_line->emplace_back(); - - auto *lip_line = container->getEventLine("lip_probe"); - auto *hash_line = container->getEventLine("hash_probe"); - BlockReference probe_block( storage_manager_->getBlock(block_id_, probe_relation_)); const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock(); std::unique_ptr probe_accessor(probe_store.createValueAccessor()); - lip_line->emplace_back(); // Probe the LIPFilters to generate an existence bitmap for probe_accessor, if enabled. std::unique_ptr existence_map; std::unique_ptr base_accessor; @@ -476,28 +466,7 @@ void HashInnerJoinWorkOrder::execute() { probe_accessor.reset( base_accessor->createSharedTupleIdSequenceAdapterVirtual(*existence_map)); } - lip_line->back().endEvent(); - lip_line->back().setPayload(op_index_ + 0); - -// hash_line->emplace_back(); -// PairsOfVectorsJoinedTuplesCollector collector; -// if (join_key_attributes_.size() == 1) { -//hash_table_.getAllFromValueAccessor( -//probe_accessor.get(), -//join_key_attributes_.front(), -//any_join_key_attributes_nullable_, -//&collector); -// } else { -//hash_table_.getAllFromValueAccessorCompositeKey( -//probe_accessor.get(), -//join_key_attributes_, -//any_join_key_attributes_nullable_, -//&collector); -// } -// hash_line->back().endEvent(); -// hash_line->back().setPayload(op_index_ + 0); - - hash_line->emplace_back(); + VectorsOfPairsJoinedTuplesCollector collector; if (join_key_attributes_.
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/LIP-time-decomposition 81b931cc3 -> 63dcccf8c Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/63dcccf8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/63dcccf8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/63dcccf8 Branch: refs/heads/LIP-time-decomposition Commit: 63dcccf8ce7e3ceb7c48d6b3b8b1524b5176c9f5 Parents: 81b931c Author: Jianqiao Zhu Authored: Mon Dec 5 16:31:47 2016 -0600 Committer: Jianqiao Zhu Committed: Mon Dec 5 16:31:47 2016 -0600 -- cli/QuickstepCli.cpp | 3 +++ relational_operators/BuildHashOperator.cpp | 7 +++ relational_operators/CMakeLists.txt| 2 ++ relational_operators/HashJoinOperator.cpp | 10 +- utility/lip_filter/CMakeLists.txt | 2 -- utility/lip_filter/LIPFilterAdaptiveProber.hpp | 4 utility/lip_filter/LIPFilterBuilder.hpp| 4 7 files changed, 21 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/63dcccf8/cli/QuickstepCli.cpp -- diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp index 8766c82..841e22d 100644 --- a/cli/QuickstepCli.cpp +++ b/cli/QuickstepCli.cpp @@ -365,6 +365,8 @@ int main(int argc, char* argv[]) { } start = std::chrono::steady_clock::now(); +auto *event_container = quickstep::simple_profiler.getContainer(); +event_container->startEvent("overall"); QueryExecutionUtil::ConstructAndSendAdmitRequestMessage( main_thread_client_id, foreman.getBusClientID(), @@ -374,6 +376,7 @@ int main(int argc, char* argv[]) { try { QueryExecutionUtil::ReceiveQueryCompletionMessage( main_thread_client_id, &bus); + event_container->endEvent("overall"); end = std::chrono::steady_clock::now(); const CatalogRelation *query_result_relation = query_handle->getQueryResultRelation(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/63dcccf8/relational_operators/BuildHashOperator.cpp -- diff --git a/relational_operators/BuildHashOperator.cpp b/relational_operators/BuildHashOperator.cpp index 60e091f..d8ff588 100644 --- a/relational_operators/BuildHashOperator.cpp +++ b/relational_operators/BuildHashOperator.cpp @@ -34,6 +34,7 @@ #include "storage/TupleReference.hpp" #include "storage/TupleStorageSubBlock.hpp" #include "storage/ValueAccessor.hpp" +#include "utility/EventProfiler.hpp" #include "utility/lip_filter/LIPFilterBuilder.hpp" #include "utility/lip_filter/LIPFilterUtil.hpp" @@ -154,10 +155,15 @@ void BuildHashWorkOrder::execute() { // Build LIPFilters if enabled. if (lip_filter_builder_ != nullptr) { +auto *event_lip = simple_profiler.getContainer()->getEventLine("BuildLIP"); +event_lip->emplace_back(); lip_filter_builder_->insertValueAccessor(accessor.get()); accessor->beginIterationVirtual(); +event_lip->back().endEvent(); } + auto *event_hash = simple_profiler.getContainer()->getEventLine("BuildHash"); + event_hash->emplace_back(); HashTablePutResult result; if (join_key_attributes_.size() == 1) { result = hash_table_->putValueAccessor(accessor.get(), @@ -170,6 +176,7 @@ void BuildHashWorkOrder::execute() { any_join_key_attributes_nullable_, &generator); } + event_hash->back().endEvent(); CHECK(result == HashTablePutResult::kOK) << "Failed to add entries to join hash table."; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/63dcccf8/relational_operators/CMakeLists.txt -- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index 0735bce..4cfbcd8 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -112,6 +112,7 @@ target_link_libraries(quickstep_relationaloperators_BuildHashOperator quickstep_storage_TupleReference quickstep_storage_TupleStorageSubBlock quickstep_storage_ValueAccessor + quickstep_utility_EventProfiler quickstep_utility_Macros quickstep_utility_lipfilter_LIPFilterBuilder quickstep_utility_lipfilter_LIPFilterUtil @@ -226,6 +227,7 @@ target_link_libraries(quickstep_relationaloperato
incubator-quickstep git commit: Updates.
Repository: incubator-quickstep Updated Branches: refs/heads/delay-hashtable-memory-alloc 097328548 -> 50231d73f Updates. Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/50231d73 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/50231d73 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/50231d73 Branch: refs/heads/delay-hashtable-memory-alloc Commit: 50231d73f221c65107d9a4b17bb0b9db1fd01659 Parents: 0973285 Author: Harshad Deshmukh Authored: Wed Nov 2 20:41:58 2016 -0500 Committer: Harshad Deshmukh Committed: Wed Nov 2 20:41:58 2016 -0500 -- query_execution/CMakeLists.txt| 1 + query_execution/QueryContext.cpp | 4 + query_execution/QueryContext.hpp | 2 +- query_execution/QueryContext.proto| 2 +- query_execution/QueryManagerBase.hpp | 2 +- query_execution/QueryManagerSingleNode.cpp| 191 + query_execution/QueryManagerSingleNode.hpp| 12 ++ relational_operators/SortMergeRunOperator.cpp | 65 +++ relational_operators/SortMergeRunOperator.hpp | 9 + storage/HashTableKeyManager.hpp | 2 +- 10 files changed, 171 insertions(+), 119 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/50231d73/query_execution/CMakeLists.txt -- diff --git a/query_execution/CMakeLists.txt b/query_execution/CMakeLists.txt index b5e07df..78b72af 100644 --- a/query_execution/CMakeLists.txt +++ b/query_execution/CMakeLists.txt @@ -260,6 +260,7 @@ target_link_libraries(quickstep_queryexecution_QueryManagerSingleNode quickstep_relationaloperators_RelationalOperator quickstep_storage_InsertDestination quickstep_storage_StorageBlock + quickstep_storage_StorageManager quickstep_utility_DAG quickstep_utility_Macros tmb) http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/50231d73/query_execution/QueryContext.cpp -- diff --git a/query_execution/QueryContext.cpp b/query_execution/QueryContext.cpp index 068b208..6c5776e 100644 --- a/query_execution/QueryContext.cpp +++ b/query_execution/QueryContext.cpp @@ -65,6 +65,10 @@ QueryContext::QueryContext(const serialization::QueryContext &proto, << "Attempted to create QueryContext from an invalid proto description:\n" << proto.DebugString(); + for (int i = 0; i < proto.build_hash_operator_ids_size(); ++i) { +build_hash_operator_ids_.emplace_back(proto.build_hash_operator_ids(i)); + } + for (int i = 0; i < proto.aggregation_states_size(); ++i) { aggregation_states_.emplace_back( AggregationOperationState::ReconstructFromProto(proto.aggregation_states(i), http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/50231d73/query_execution/QueryContext.hpp -- diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp index 07297e3..428d526 100644 --- a/query_execution/QueryContext.hpp +++ b/query_execution/QueryContext.hpp @@ -135,7 +135,7 @@ class QueryContext { /** * @brief A unique identifier of a relational operator in the DAG. **/ - typedef std::uint32_t dag_operator_id; + typedef std::uint64_t dag_operator_id; /** * @brief Constructor. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/50231d73/query_execution/QueryContext.proto -- diff --git a/query_execution/QueryContext.proto b/query_execution/QueryContext.proto index f8831db..a1dce0a 100644 --- a/query_execution/QueryContext.proto +++ b/query_execution/QueryContext.proto @@ -63,5 +63,5 @@ message QueryContext { required uint64 query_id = 13; - repeated uint32 build_hash_operator_ids = 14; + repeated uint64 build_hash_operator_ids = 14; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/50231d73/query_execution/QueryManagerBase.hpp -- diff --git a/query_execution/QueryManagerBase.hpp b/query_execution/QueryManagerBase.hpp index a274742..77150ad 100644 --- a/query_execution/QueryManagerBase.hpp +++ b/query_execution/QueryManagerBase.hpp @@ -173,7 +173,7 @@ class QueryManagerBase { * * @param index The index of the given relational operator in the DAG. **/ - void markOperatorFinished(const dag_node_index index); + virtual void markOperatorFinished(const dag_node_
[5/6] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/584461ab Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/584461ab Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/584461ab Branch: refs/heads/delay-hashtable-memory-alloc Commit: 584461ab9539a13c316f928419842b2e60660b34 Parents: f54d1a2 Author: Harshad Deshmukh Authored: Tue Nov 1 16:17:03 2016 -0500 Committer: Harshad Deshmukh Committed: Tue Nov 1 16:56:38 2016 -0500 -- query_execution/QueryContext.hpp | 9 + query_execution/QueryContext.proto | 2 ++ query_optimizer/ExecutionGenerator.cpp | 3 +++ 3 files changed, 14 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_execution/QueryContext.hpp -- diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp index 7ad8fa1..820cbb6 100644 --- a/query_execution/QueryContext.hpp +++ b/query_execution/QueryContext.hpp @@ -133,6 +133,11 @@ class QueryContext { typedef std::uint32_t window_aggregation_state_id; /** + * @brief A unique identifier of a relational operator in the DAG. + **/ + typedef std::uint32_t dag_operator_id; + + /** * @brief Constructor. * * @param proto A serialized Protocol Buffer representation of a @@ -575,6 +580,10 @@ class QueryContext { std::vector>> update_groups_; std::vector> window_aggregation_states_; + // The IDs of the BuildHashOperator nodes in the query plan DAG. + // This vector has a 1-1 correspondence with join_hash_tables_ vector. + std::vector build_hash_operator_ids_; + DISALLOW_COPY_AND_ASSIGN(QueryContext); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_execution/QueryContext.proto -- diff --git a/query_execution/QueryContext.proto b/query_execution/QueryContext.proto index ab0f520..f8831db 100644 --- a/query_execution/QueryContext.proto +++ b/query_execution/QueryContext.proto @@ -62,4 +62,6 @@ message QueryContext { repeated WindowAggregationOperationState window_aggregation_states = 12; required uint64 query_id = 13; + + repeated uint32 build_hash_operator_ids = 14; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/584461ab/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 2e0d8f3..545f539 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -729,6 +729,9 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) { any_build_attributes_nullable, join_hash_table_index)); + // Add the index of build operator to QueryContext. + query_context_proto_->add_build_hash_operator_ids(build_operator_index); + // Create InsertDestination proto. const CatalogRelation *output_relation = nullptr; const QueryContext::insert_destination_id insert_destination_index =
[1/2] incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/exact-filter ceee17b67 -> 9cacbb17c http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9cacbb17/utility/lip_filter/LIPFilterDeployment.hpp -- diff --git a/utility/lip_filter/LIPFilterDeployment.hpp b/utility/lip_filter/LIPFilterDeployment.hpp index 9b37f88..ab1259b 100644 --- a/utility/lip_filter/LIPFilterDeployment.hpp +++ b/utility/lip_filter/LIPFilterDeployment.hpp @@ -39,11 +39,6 @@ class Type; * @{ */ -enum class LIPFilterActionType { - kBuild = 0, - kProbe -}; - /** * @brief Helper class for organizing a group of LIPFilters in the backend. *Each LIPFilterDeployment object is attached to a RelationalOperator. @@ -69,16 +64,6 @@ class LIPFilterDeployment { static bool ProtoIsValid(const serialization::LIPFilterDeployment &proto); /** - * @brief Get the action type for this group of LIPFilters (i.e. whether - *to build or probe the filters). - * - * @return The action type. - */ - LIPFilterActionType getActionType() const { -return action_type_; - } - - /** * @brief Create a LIPFilterBuilder for this group of LIPFilters. * * @return A new LIPFilterBuilder object for this group of LIPFilters. @@ -95,11 +80,14 @@ class LIPFilterDeployment { LIPFilterAdaptiveProber* createLIPFilterAdaptiveProber() const; private: - LIPFilterActionType action_type_; - - std::vector lip_filters_; - std::vector attr_ids_; - std::vector attr_types_; + struct LIPFilterDeploymentInfo { +std::vector lip_filters_; +std::vector attr_ids_; +std::vector attr_types_; + }; + + std::unique_ptr build_; + std::unique_ptr probe_; DISALLOW_COPY_AND_ASSIGN(LIPFilterDeployment); }; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9cacbb17/utility/lip_filter/LIPFilterFactory.cpp -- diff --git a/utility/lip_filter/LIPFilterFactory.cpp b/utility/lip_filter/LIPFilterFactory.cpp index 9cec4c5..a96151f 100644 --- a/utility/lip_filter/LIPFilterFactory.cpp +++ b/utility/lip_filter/LIPFilterFactory.cpp @@ -37,16 +37,34 @@ LIPFilter* LIPFilterFactory::ReconstructFromProto(const serialization::LIPFilter proto.GetExtension(serialization::BitVectorExactFilter::attribute_size); const std::size_t filter_cardinality = proto.GetExtension(serialization::BitVectorExactFilter::filter_cardinality); + const bool is_anti_filter = + proto.GetExtension(serialization::BitVectorExactFilter::is_anti_filter); switch (attr_size) { case 1: - return new BitVectorExactFilter(filter_cardinality); + if (is_anti_filter) { +return new BitVectorExactFilter(filter_cardinality); + } else { +return new BitVectorExactFilter(filter_cardinality); + } case 2: - return new BitVectorExactFilter(filter_cardinality); + if (is_anti_filter) { +return new BitVectorExactFilter(filter_cardinality); + } else { +return new BitVectorExactFilter(filter_cardinality); + } case 4: - return new BitVectorExactFilter(filter_cardinality); + if (is_anti_filter) { +return new BitVectorExactFilter(filter_cardinality); + } else { +return new BitVectorExactFilter(filter_cardinality); + } case 8: - return new BitVectorExactFilter(filter_cardinality); + if (is_anti_filter) { +return new BitVectorExactFilter(filter_cardinality); + } else { +return new BitVectorExactFilter(filter_cardinality); + } default: LOG(FATAL) << "Invalid attribute size for BitVectorExactFilter: " << attr_size;
[2/2] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9cacbb17 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9cacbb17 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9cacbb17 Branch: refs/heads/exact-filter Commit: 9cacbb17c5152130259dae0c2ce11b16a66f74c9 Parents: ceee17b Author: Jianqiao Zhu Authored: Sun Oct 30 01:28:25 2016 -0500 Committer: Jianqiao Zhu Committed: Sun Oct 30 01:28:25 2016 -0500 -- query_optimizer/CMakeLists.txt | 2 + query_optimizer/ExecutionGenerator.cpp | 43 +++ query_optimizer/ExecutionGenerator.hpp | 7 + query_optimizer/LIPFilterGenerator.cpp | 86 +++-- query_optimizer/LIPFilterGenerator.hpp | 47 ++- query_optimizer/PhysicalGenerator.cpp | 2 - query_optimizer/cost_model/CMakeLists.txt | 2 + query_optimizer/cost_model/SimpleCostModel.cpp | 9 + query_optimizer/cost_model/SimpleCostModel.hpp | 5 + .../cost_model/StarSchemaSimpleCostModel.cpp| 29 ++ .../cost_model/StarSchemaSimpleCostModel.hpp| 4 + query_optimizer/physical/CMakeLists.txt | 1 - query_optimizer/physical/FilterInjection.cpp| 42 ++- query_optimizer/physical/FilterInjection.hpp| 52 +-- .../physical/LIPFilterConfiguration.hpp | 65 +++- query_optimizer/physical/TopLevelPlan.hpp | 3 +- query_optimizer/rules/AttachLIPFilters.cpp | 14 +- query_optimizer/rules/CMakeLists.txt| 2 + query_optimizer/rules/InjectJoinFilters.cpp | 320 +-- query_optimizer/rules/InjectJoinFilters.hpp | 31 +- relational_operators/BuildLIPFilterOperator.cpp | 115 +++ relational_operators/BuildLIPFilterOperator.hpp | 164 ++ relational_operators/CMakeLists.txt | 23 ++ utility/PlanVisualizer.cpp | 3 +- utility/lip_filter/BitVectorExactFilter.hpp | 10 +- utility/lip_filter/LIPFilter.proto | 14 +- utility/lip_filter/LIPFilterDeployment.cpp | 70 ++-- utility/lip_filter/LIPFilterDeployment.hpp | 28 +- utility/lip_filter/LIPFilterFactory.cpp | 26 +- 29 files changed, 1039 insertions(+), 180 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9cacbb17/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 7fb4925..0699bbd 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -118,6 +118,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_queryoptimizer_physical_WindowAggregate quickstep_relationaloperators_AggregationOperator quickstep_relationaloperators_BuildHashOperator + quickstep_relationaloperators_BuildLIPFilterOperator quickstep_relationaloperators_CreateIndexOperator quickstep_relationaloperators_CreateTableOperator quickstep_relationaloperators_DeleteOperator @@ -164,6 +165,7 @@ target_link_libraries(quickstep_queryoptimizer_LIPFilterGenerator quickstep_queryoptimizer_QueryPlan quickstep_queryoptimizer_expressions_ExprId quickstep_queryoptimizer_physical_Aggregate + quickstep_queryoptimizer_physical_FilterInjection quickstep_queryoptimizer_physical_HashJoin quickstep_queryoptimizer_physical_LIPFilterConfiguration quickstep_queryoptimizer_physical_Physical http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9cacbb17/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index a5c9ef3..e449c49 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -94,6 +94,7 @@ #include "query_optimizer/physical/WindowAggregate.hpp" #include "relational_operators/AggregationOperator.hpp" #include "relational_operators/BuildHashOperator.hpp" +#include "relational_operators/BuildLIPFilterOperator.hpp" #include "relational_operators/CreateIndexOperator.hpp" #include "relational_operators/CreateTableOperator.hpp" #include "relational_operators/DeleteOperator.hpp" @@ -270,6 +271,9 @@ void ExecutionGenerator::generatePlanInternal( case P::PhysicalType::kDropTable: return convertDropTable( std::static_pointer_cast(physical_plan)); +case P::P
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/exact-filter b08b0ce4f -> ceee17b67 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/ceee17b6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/ceee17b6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/ceee17b6 Branch: refs/heads/exact-filter Commit: ceee17b67aca6dac7ccfda19515fdfae41c0e58c Parents: b08b0ce Author: Jianqiao Zhu Authored: Sat Oct 29 16:32:45 2016 -0500 Committer: Jianqiao Zhu Committed: Sat Oct 29 16:32:45 2016 -0500 -- utility/CMakeLists.txt | 2 +- utility/PlanVisualizer.cpp | 14 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ceee17b6/utility/CMakeLists.txt -- diff --git a/utility/CMakeLists.txt b/utility/CMakeLists.txt index 4394aa1..872225e 100644 --- a/utility/CMakeLists.txt +++ b/utility/CMakeLists.txt @@ -264,7 +264,7 @@ target_link_libraries(quickstep_utility_PlanVisualizer quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel quickstep_queryoptimizer_expressions_AttributeReference quickstep_queryoptimizer_expressions_ExprId - quickstep_queryoptimizer_physical_FilterJoin + quickstep_queryoptimizer_physical_FilterInjection quickstep_queryoptimizer_physical_HashJoin quickstep_queryoptimizer_physical_LIPFilterConfiguration quickstep_queryoptimizer_physical_Physical http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ceee17b6/utility/PlanVisualizer.cpp -- diff --git a/utility/PlanVisualizer.cpp b/utility/PlanVisualizer.cpp index 9ade057..7b2f14f 100644 --- a/utility/PlanVisualizer.cpp +++ b/utility/PlanVisualizer.cpp @@ -31,7 +31,7 @@ #include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp" #include "query_optimizer/expressions/AttributeReference.hpp" #include "query_optimizer/expressions/ExprId.hpp" -#include "query_optimizer/physical/FilterJoin.hpp" +#include "query_optimizer/physical/FilterInjection.hpp" #include "query_optimizer/physical/HashJoin.hpp" #include "query_optimizer/physical/Physical.hpp" #include "query_optimizer/physical/PhysicalType.hpp" @@ -58,7 +58,7 @@ std::string PlanVisualizer::visualize(const P::PhysicalPtr &input) { color_map_["TableReference"] = "skyblue"; color_map_["Selection"] = "#90EE90"; - color_map_["FilterJoin"] = "pink"; + color_map_["FilterInjection"] = "pink"; color_map_["HashJoin"] = "red"; color_map_["HashLeftOuterJoin"] = "orange"; color_map_["HashLeftSemiJoin"] = "orange"; @@ -166,13 +166,13 @@ void PlanVisualizer::visit(const P::PhysicalPtr &input) { } break; } -case P::PhysicalType::kFilterJoin: { - const P::FilterJoinPtr filter_join = -std::static_pointer_cast(input); +case P::PhysicalType::kFilterInjection: { + const P::FilterInjectionPtr filter_injection = +std::static_pointer_cast(input); node_info.labels.emplace_back(input->getName()); - const auto &probe_attributes = filter_join->probe_join_attributes(); - const auto &build_attributes = filter_join->build_join_attributes(); + const auto &probe_attributes = filter_injection->probe_attributes(); + const auto &build_attributes = filter_injection->build_attributes(); for (std::size_t i = 0; i < probe_attributes.size(); ++i) { node_info.labels.emplace_back( probe_attributes[i]->attribute_alias() + " = " +
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/exact-filter 8b68fa53c -> b08b0ce4f Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/b08b0ce4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b08b0ce4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b08b0ce4 Branch: refs/heads/exact-filter Commit: b08b0ce4fbd4eddf8789ae15af0f85e55452a0d7 Parents: 8b68fa5 Author: Jianqiao Zhu Authored: Sat Oct 29 16:22:59 2016 -0500 Committer: Jianqiao Zhu Committed: Sat Oct 29 16:22:59 2016 -0500 -- cli/QuickstepCli.cpp| 6 - query_optimizer/CMakeLists.txt | 4 +- query_optimizer/ExecutionGenerator.cpp | 2 +- query_optimizer/ExecutionGenerator.hpp | 2 +- query_optimizer/PhysicalGenerator.cpp | 6 +- .../cost_model/StarSchemaSimpleCostModel.cpp| 3 +- query_optimizer/physical/CMakeLists.txt | 6 +- query_optimizer/physical/FilterInjection.cpp| 68 + query_optimizer/physical/FilterInjection.hpp| 146 +++ query_optimizer/physical/FilterJoin.cpp | 98 - query_optimizer/physical/FilterJoin.hpp | 134 - query_optimizer/physical/PatternMatcher.hpp | 4 +- query_optimizer/physical/PhysicalType.hpp | 2 +- query_optimizer/rules/CMakeLists.txt| 8 +- query_optimizer/rules/InjectJoinFilters.cpp | 122 query_optimizer/rules/InjectJoinFilters.hpp | 78 ++ query_optimizer/rules/TransformFilterJoins.cpp | 92 query_optimizer/rules/TransformFilterJoins.hpp | 73 -- utility/CMakeLists.txt | 1 + utility/PlanVisualizer.cpp | 16 ++ 20 files changed, 452 insertions(+), 419 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b08b0ce4/cli/QuickstepCli.cpp -- diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp index b89a0f3..8269197 100644 --- a/cli/QuickstepCli.cpp +++ b/cli/QuickstepCli.cpp @@ -84,7 +84,6 @@ typedef quickstep::LineReaderDumb LineReaderImpl; #include "gflags/gflags.h" #include "glog/logging.h" -#include "google/protobuf/text_format.h" #include "tmb/address.h" #include "tmb/id_typedefs.h" @@ -301,11 +300,6 @@ int main(int argc, char* argv[]) { LOG(FATAL) << "NON-STANDARD EXCEPTION DURING STARTUP"; } - std::string str; - google::protobuf::TextFormat::PrintToString( - query_processor->getDefaultDatabase()->getProto(), &str); - std::cerr << str << "\n"; - // Parse the CPU affinities for workers and the preloader thread, if enabled // to warm up the buffer pool. const vector worker_cpu_affinities = http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b08b0ce4/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 3211919..7fb4925 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -98,7 +98,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_queryoptimizer_physical_CreateTable quickstep_queryoptimizer_physical_DeleteTuples quickstep_queryoptimizer_physical_DropTable - quickstep_queryoptimizer_physical_FilterJoin + quickstep_queryoptimizer_physical_FilterInjection quickstep_queryoptimizer_physical_HashJoin quickstep_queryoptimizer_physical_InsertSelection quickstep_queryoptimizer_physical_InsertTuple @@ -209,10 +209,10 @@ target_link_libraries(quickstep_queryoptimizer_PhysicalGenerator quickstep_queryoptimizer_logical_Logical quickstep_queryoptimizer_physical_Physical quickstep_queryoptimizer_rules_AttachLIPFilters + quickstep_queryoptimizer_rules_InjectJoinFilters quickstep_queryoptimizer_rules_PruneColumns quickstep_queryoptimizer_rules_StarSchemaHashJoinOrderOptimization quickstep_queryoptimizer_rules_SwapProbeBuild - quickstep_queryoptimizer_rules_TransformFilterJoins quickstep_queryoptimizer_strategy_Aggregate quickstep_queryoptimizer_strategy_Join quickstep_queryoptimizer_strategy_OneToOne http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b08b
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor-backend c28ffe1bb -> 41cdc1ba6 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/41cdc1ba Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/41cdc1ba Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/41cdc1ba Branch: refs/heads/lip-refactor-backend Commit: 41cdc1ba6fe1040e474394ddcc6a88f84a4d326a Parents: c28ffe1 Author: Jianqiao Zhu Authored: Sat Oct 22 15:27:25 2016 -0500 Committer: Jianqiao Zhu Committed: Sat Oct 22 15:27:25 2016 -0500 -- relational_operators/HashJoinOperator.cpp | 107 - relational_operators/HashJoinOperator.hpp | 15 +++- relational_operators/SelectOperator.cpp | 21 +++-- relational_operators/WorkOrder.proto | 5 +- relational_operators/WorkOrderFactory.cpp | 25 +++--- storage/AggregationOperationState.cpp | 16 ++-- storage/StorageBlock.cpp | 24 +- storage/StorageBlock.hpp | 6 -- 8 files changed, 117 insertions(+), 102 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/41cdc1ba/relational_operators/HashJoinOperator.cpp -- diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp index eeb2096..4a91f86 100644 --- a/relational_operators/HashJoinOperator.cpp +++ b/relational_operators/HashJoinOperator.cpp @@ -97,9 +97,8 @@ class MapBasedJoinedTupleCollector { class SemiAntiJoinTupleCollector { public: - explicit SemiAntiJoinTupleCollector(TupleIdSequence *existence_map) { -filter_ = existence_map; - } + explicit SemiAntiJoinTupleCollector(TupleIdSequence *filter) + : filter_(filter) {} template inline void operator()(const ValueAccessorT &accessor) { @@ -112,9 +111,8 @@ class SemiAntiJoinTupleCollector { class OuterJoinTupleCollector { public: - explicit OuterJoinTupleCollector(const TupleStorageSubBlock &tuple_store) { -filter_.reset(tuple_store.getExistenceMap()); - } + explicit OuterJoinTupleCollector(TupleIdSequence *filter) + : filter_(filter) {} template inline void operator()(const ValueAccessorT &accessor, @@ -132,14 +130,10 @@ class OuterJoinTupleCollector { return &joined_tuples_; } - const TupleIdSequence* filter() const { -return filter_.get(); - } - private: std::unordered_map>> joined_tuples_; // BitVector on the probe relation. 1 if the corresponding tuple has no match. - std::unique_ptr filter_; + TupleIdSequence *filter_; }; } // namespace @@ -264,7 +258,8 @@ bool HashJoinOperator::getAllOuterJoinWorkOrders( is_selection_on_build_, hash_table, output_destination, - storage_manager), + storage_manager, + CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)), op_index_); } started_ = true; @@ -284,7 +279,8 @@ bool HashJoinOperator::getAllOuterJoinWorkOrders( is_selection_on_build_, hash_table, output_destination, -storage_manager), +storage_manager, +CreateLIPFilterAdaptiveProberHelper(lip_deployment_index_, query_context)), op_index_); ++num_workorders_generated_; } @@ -409,6 +405,7 @@ serialization::WorkOrder* HashJoinOperator::createOuterJoinWorkOrderProto(const proto->SetExtension(serialization::HashJoinWorkOrder::join_hash_table_index, hash_table_index_); proto->SetExtension(serialization::HashJoinWorkOrder::selection_index, selection_index_); proto->SetExtension(serialization::HashJoinWorkOrder::block_id, block); + proto->SetExtension(serialization::HashJoinWorkOrder::lip_deployment_index, lip_deployment_index_); for (const bool is_attribute_on_build : is_selection_on_build_) { proto->AddExtension(serialization::HashJoinWorkOrder::is_selection_on_build, is_attribute_on_build); @@ -422,7 +419,6 @@ void HashInnerJoinWorkOrder::execute() { BlockReference probe_block( storage_manager_->getBlock(block_id_, probe_relation_)); const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock(); - std::unique_ptr probe_accessor(probe_store.createValueAccessor()); // Probe the LIPFilters to generate an existence bitmap for probe_accessor, if enabled. @@ -539,7 +535,6 @@ void HashSemiJoinWorkOrder::executeWithResidualPredicate() { BlockReference probe_block = storage_manager_->getBlock(block_id_, probe
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor-backend 3fbbdd2d1 -> 0ffb81840 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0ffb8184 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0ffb8184 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0ffb8184 Branch: refs/heads/lip-refactor-backend Commit: 0ffb818406b4c3c03ea12aff3a289c5950ecbea1 Parents: 3fbbdd2 Author: Jianqiao Zhu Authored: Fri Oct 21 16:33:59 2016 -0500 Committer: Jianqiao Zhu Committed: Fri Oct 21 16:33:59 2016 -0500 -- relational_operators/AggregationOperator.cpp | 21 ++ relational_operators/AggregationOperator.hpp | 3 +- relational_operators/BuildHashOperator.cpp | 12 +--- relational_operators/BuildHashOperator.hpp | 6 +- relational_operators/CMakeLists.txt | 8 +-- relational_operators/HashJoinOperator.cpp| 17 + relational_operators/SelectOperator.cpp | 78 +-- relational_operators/SelectOperator.hpp | 10 +-- utility/lip_filter/CMakeLists.txt| 4 ++ utility/lip_filter/LIPFilterBuilder.hpp | 3 - utility/lip_filter/LIPFilterUtil.hpp | 63 ++ 11 files changed, 122 insertions(+), 103 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0ffb8184/relational_operators/AggregationOperator.cpp -- diff --git a/relational_operators/AggregationOperator.cpp b/relational_operators/AggregationOperator.cpp index e2cb3a8..963012c 100644 --- a/relational_operators/AggregationOperator.cpp +++ b/relational_operators/AggregationOperator.cpp @@ -28,7 +28,7 @@ #include "storage/AggregationOperationState.hpp" #include "storage/StorageBlockInfo.hpp" #include "utility/lip_filter/LIPFilterAdaptiveProber.hpp" -#include "utility/lip_filter/LIPFilterDeployment.hpp" +#include "utility/lip_filter/LIPFilterUtil.hpp" #include "tmb/id_typedefs.h" @@ -40,24 +40,15 @@ bool AggregationOperator::getAllWorkOrders( StorageManager *storage_manager, const tmb::client_id scheduler_client_id, tmb::MessageBus *bus) { - const LIPFilterDeployment *lip_filter_deployment = nullptr; - if (lip_deployment_index_ != QueryContext::kInvalidLIPDeploymentId) { -lip_filter_deployment = query_context->getLIPDeployment(lip_deployment_index_); - } - if (input_relation_is_stored_) { if (!started_) { for (const block_id input_block_id : input_relation_block_ids_) { -LIPFilterAdaptiveProber *lip_filter_adaptive_prober = nullptr; -if (lip_filter_deployment != nullptr) { - lip_filter_adaptive_prober = lip_filter_deployment->createLIPFilterAdaptiveProber(); -} container->addNormalWorkOrder( new AggregationWorkOrder( query_id_, input_block_id, query_context->getAggregationState(aggr_state_index_), -lip_filter_adaptive_prober), +MakeLIPFilterAdaptiveProber(lip_deployment_index_, query_context)), op_index_); } started_ = true; @@ -65,16 +56,12 @@ bool AggregationOperator::getAllWorkOrders( return started_; } else { while (num_workorders_generated_ < input_relation_block_ids_.size()) { - LIPFilterAdaptiveProber *lip_filter_adaptive_prober = nullptr; - if (lip_filter_deployment != nullptr) { -lip_filter_adaptive_prober = lip_filter_deployment->createLIPFilterAdaptiveProber(); - } container->addNormalWorkOrder( new AggregationWorkOrder( query_id_, input_relation_block_ids_[num_workorders_generated_], query_context->getAggregationState(aggr_state_index_), - lip_filter_adaptive_prober), + MakeLIPFilterAdaptiveProber(lip_deployment_index_, query_context)), op_index_); ++num_workorders_generated_; } @@ -103,6 +90,7 @@ bool AggregationOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *contai } serialization::WorkOrder* AggregationOperator::createWorkOrderProto(const block_id block) { + // TODO(jianqiao): LIPFilter serialization::WorkOrder *proto = new serialization::WorkOrder; proto->set_work_order_type(serialization::AGGREGATION); proto->set_query_id(query_id_); @@ -113,7 +101,6 @@ serialization::WorkOrder* AggregationOperator::createWorkOrderProto(const block_ return proto; } - void AggregationWorkOrder::execute() { state_->aggregateBlock(input_block_id_, lip_filter_adaptive_prober_.get()); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0ffb8184/relational_operators/AggregationOperator.
[2/2] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3fbbdd2d Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3fbbdd2d Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3fbbdd2d Branch: refs/heads/lip-refactor-backend Commit: 3fbbdd2d13ae5b44c6395f45c7a116da40ca1afa Parents: 71b7330 Author: Jianqiao Zhu Authored: Fri Oct 21 15:18:29 2016 -0500 Committer: Jianqiao Zhu Committed: Fri Oct 21 15:18:29 2016 -0500 -- relational_operators/AggregationOperator.cpp | 4 ++- relational_operators/BuildHashOperator.cpp | 8 +++--- relational_operators/BuildHashOperator.hpp | 4 +-- relational_operators/CMakeLists.txt | 8 ++ relational_operators/HashJoinOperator.cpp| 35 --- relational_operators/HashJoinOperator.hpp| 6 relational_operators/SelectOperator.cpp | 3 +- storage/CMakeLists.txt | 7 +++-- 8 files changed, 49 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fbbdd2d/relational_operators/AggregationOperator.cpp -- diff --git a/relational_operators/AggregationOperator.cpp b/relational_operators/AggregationOperator.cpp index 71baa53..e2cb3a8 100644 --- a/relational_operators/AggregationOperator.cpp +++ b/relational_operators/AggregationOperator.cpp @@ -27,6 +27,8 @@ #include "relational_operators/WorkOrder.pb.h" #include "storage/AggregationOperationState.hpp" #include "storage/StorageBlockInfo.hpp" +#include "utility/lip_filter/LIPFilterAdaptiveProber.hpp" +#include "utility/lip_filter/LIPFilterDeployment.hpp" #include "tmb/id_typedefs.h" @@ -39,7 +41,7 @@ bool AggregationOperator::getAllWorkOrders( const tmb::client_id scheduler_client_id, tmb::MessageBus *bus) { const LIPFilterDeployment *lip_filter_deployment = nullptr; - if (lip_deployment_index_ != QueryContext::kInvalidILIPDeploymentId) { + if (lip_deployment_index_ != QueryContext::kInvalidLIPDeploymentId) { lip_filter_deployment = query_context->getLIPDeployment(lip_deployment_index_); } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fbbdd2d/relational_operators/BuildHashOperator.cpp -- diff --git a/relational_operators/BuildHashOperator.cpp b/relational_operators/BuildHashOperator.cpp index 35bb5cf..c0c0a4e 100644 --- a/relational_operators/BuildHashOperator.cpp +++ b/relational_operators/BuildHashOperator.cpp @@ -35,6 +35,7 @@ #include "storage/TupleStorageSubBlock.hpp" #include "storage/ValueAccessor.hpp" #include "utility/lip_filter/LIPFilterBuilder.hpp" +#include "utility/lip_filter/LIPFilterDeployment.hpp" #include "glog/logging.h" @@ -70,11 +71,9 @@ bool BuildHashOperator::getAllWorkOrders( DCHECK(query_context != nullptr); LIPFilterBuilderPtr lip_filter_builder = nullptr; - if (lip_deployment_index_ != QueryContext::kInvalidILIPDeploymentId) { -const LIPFilterDeployment *lip_filter_deployment = -query_context->getLIPDeployment(lip_deployment_index_); + if (lip_deployment_index_ != QueryContext::kInvalidLIPDeploymentId) { lip_filter_builder = std::shared_ptr( -lip_filter_deployment->createLIPFilterBuilder()); + query_context->getLIPDeployment(lip_deployment_index_)->createLIPFilterBuilder()); } JoinHashTable *hash_table = query_context->getJoinHashTable(hash_table_index_); @@ -159,6 +158,7 @@ void BuildHashWorkOrder::execute() { TupleReferenceGenerator generator(build_block_id_); std::unique_ptr accessor(block->getTupleStorageSubBlock().createValueAccessor()); + // Build LIPFilters if enabled. if (lip_filter_builder_ != nullptr) { lip_filter_builder_->insertValueAccessor(accessor.get()); accessor->beginIterationVirtual(); http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fbbdd2d/relational_operators/BuildHashOperator.hpp -- diff --git a/relational_operators/BuildHashOperator.hpp b/relational_operators/BuildHashOperator.hpp index 940298c..e1963b0 100644 --- a/relational_operators/BuildHashOperator.hpp +++ b/relational_operators/BuildHashOperator.hpp @@ -164,7 +164,7 @@ class BuildHashWorkOrder : public WorkOrder { * @param build_block_id The block id. * @param hash_table The JoinHashTable to use. * @param storage_manager The StorageManager to use. - * @param lip_filter_builder The attached builder for building LIP filters. + * @param lip_filter_builder The attached LIP filter builer. **/ BuildHashWorkOrder(const std::size_t query_id, c
[3/3] incubator-quickstep git commit: updates
updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/b9db77d9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b9db77d9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b9db77d9 Branch: refs/heads/exact-filter Commit: b9db77d96e19821c65f97eb1dc29df743dde0bf0 Parents: f298303 Author: Jianqiao Zhu Authored: Thu Oct 20 16:35:32 2016 -0500 Committer: Jianqiao Zhu Committed: Thu Oct 20 16:35:32 2016 -0500 -- query_execution/QueryContext.cpp| 3 +- utility/lip_filter/LIPFilter.proto | 12 +- utility/lip_filter/LIPFilterFactory.cpp | 40 +++- utility/lip_filter/LIPFilterFactory.hpp | 5 ++- utility/lip_filter/SimpleHashSetExactFilter.hpp | 17 ++--- 5 files changed, 65 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b9db77d9/query_execution/QueryContext.cpp -- diff --git a/query_execution/QueryContext.cpp b/query_execution/QueryContext.cpp index 0e6636d..bbb552a 100644 --- a/query_execution/QueryContext.cpp +++ b/query_execution/QueryContext.cpp @@ -98,7 +98,8 @@ QueryContext::QueryContext(const serialization::QueryContext &proto, for (int i = 0; i < proto.lip_filters_size(); ++i) { lip_filters_.emplace_back( std::unique_ptr( -LIPFilterFactory::ReconstructFromProto(proto.lip_filters(i; +LIPFilterFactory::ReconstructFromProto(proto.lip_filters(i), + storage_manager))); } for (int i = 0; i < proto.lip_filter_deployments_size(); ++i) { http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b9db77d9/utility/lip_filter/LIPFilter.proto -- diff --git a/utility/lip_filter/LIPFilter.proto b/utility/lip_filter/LIPFilter.proto index 0ec2978..2f80094 100644 --- a/utility/lip_filter/LIPFilter.proto +++ b/utility/lip_filter/LIPFilter.proto @@ -33,14 +33,22 @@ message LIPFilter { extensions 16 to max; } -message SingleIdentityHashFilter { +message SimpleHashSetExactFilter { extend LIPFilter { // All required -optional uint64 filter_cardinality = 16; +optional uint64 initial_num_entries = 16; optional uint64 attribute_size = 17; } } +message SingleIdentityHashFilter { + extend LIPFilter { +// All required +optional uint64 filter_cardinality = 24; +optional uint64 attribute_size = 25; + } +} + enum LIPFilterActionType { BUILD = 1; PROBE = 2; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b9db77d9/utility/lip_filter/LIPFilterFactory.cpp -- diff --git a/utility/lip_filter/LIPFilterFactory.cpp b/utility/lip_filter/LIPFilterFactory.cpp index e69e8f3..9f990e1 100644 --- a/utility/lip_filter/LIPFilterFactory.cpp +++ b/utility/lip_filter/LIPFilterFactory.cpp @@ -30,8 +30,37 @@ namespace quickstep { -LIPFilter* LIPFilterFactory::ReconstructFromProto(const serialization::LIPFilter &proto) { +LIPFilter* LIPFilterFactory::ReconstructFromProto(const serialization::LIPFilter &proto, + StorageManager *storage_manager) { switch (proto.lip_filter_type()) { +case serialization::LIPFilterType::SIMPLE_HASH_SET_EXACT_FILTER: { + const std::size_t attr_size = + proto.GetExtension(serialization::SimpleHashSetExactFilter::attribute_size); + const std::size_t initalial_num_entries = + proto.GetExtension(serialization::SimpleHashSetExactFilter::initial_num_entries); + + switch (attr_size) { +case 1: { + return new SimpleHashSetExactFilter(initalial_num_entries, +storage_manager); +} +case 2: { + return new SimpleHashSetExactFilter(initalial_num_entries, + storage_manager); +} +case 4: { + return new SimpleHashSetExactFilter(initalial_num_entries, + storage_manager); +} +case 8: { + return new SimpleHashSetExactFilter(initalial_num_entries, + storage_manager); +} +default: + LOG(FATAL) << "Unsupported attribute size for SimpleHashSetExactFilter: " + << attr_size; + } +} case serialization::LIPFilterType::SINGLE_IDENTITY_HASH_FILTER: { const std::size_t attr_size =
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/untyped-agg 9ccd5a311 -> c41451dbd Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/c41451db Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/c41451db Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/c41451db Branch: refs/heads/untyped-agg Commit: c41451dbd01fbc11609f996fe9357e091eb49307 Parents: 9ccd5a3 Author: Jianqiao Zhu Authored: Tue Oct 18 09:53:43 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 18 09:53:43 2016 -0500 -- .../aggregation/AggregationHandleAvg.cpp| 270 --- .../aggregation/AggregationHandleAvg.hpp| 33 ++- .../aggregation/AggregationHandleCount.cpp | 6 +- .../aggregation/AggregationHandleSum.cpp| 1 + storage/AggregationOperationState.cpp | 63 ++--- storage/AggregationOperationState.hpp | 1 + storage/AggregationStateHashTable.hpp | 157 +++ storage/AggregationStateManager.hpp | 48 ++-- storage/HashTableBase.hpp | 3 + storage/StorageBlock.cpp| 91 +++ storage/StorageBlock.hpp| 6 +- 11 files changed, 341 insertions(+), 338 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c41451db/expressions/aggregation/AggregationHandleAvg.cpp -- diff --git a/expressions/aggregation/AggregationHandleAvg.cpp b/expressions/aggregation/AggregationHandleAvg.cpp index 47f3f41..e90f10f 100644 --- a/expressions/aggregation/AggregationHandleAvg.cpp +++ b/expressions/aggregation/AggregationHandleAvg.cpp @@ -24,8 +24,6 @@ #include #include "catalog/CatalogTypedefs.hpp" -#include "storage/HashTable.hpp" -#include "storage/HashTableFactory.hpp" #include "types/Type.hpp" #include "types/TypeFactory.hpp" #include "types/TypeID.hpp" @@ -40,165 +38,113 @@ namespace quickstep { class StorageManager; -AggregationHandleAvg::AggregationHandleAvg(const Type &type) {} -//: argument_type_(type), block_update_(false) { -// // We sum Int as Long and Float as Double so that we have more headroom when -// // adding many values. -// TypeID type_precision_id; -// switch (type.getTypeID()) { -//case kInt: -//case kLong: -// type_precision_id = kLong; -// break; -//case kFloat: -//case kDouble: -// type_precision_id = kDouble; -// break; -//default: -// type_precision_id = type.getTypeID(); -// break; -// } -// -// const Type &sum_type = TypeFactory::GetType(type_precision_id); -// blank_state_.sum_ = sum_type.makeZeroValue(); -// blank_state_.count_ = 0; -// -// // Make operators to do arithmetic: -// // Add operator for summing argument values. -// fast_add_operator_.reset( -// BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd) -// .makeUncheckedBinaryOperatorForTypes(sum_type, argument_type_)); -// // Add operator for merging states. -// merge_add_operator_.reset( -// BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kAdd) -// .makeUncheckedBinaryOperatorForTypes(sum_type, sum_type)); -// // Divide operator for dividing sum by count to get final average. -// divide_operator_.reset( -// BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide) -// .makeUncheckedBinaryOperatorForTypes(sum_type, -// TypeFactory::GetType(kDouble))); -// -// // Result is nullable, because AVG() over 0 values (or all NULL values) is -// // NULL. -// result_type_ = -// &(BinaryOperationFactory::GetBinaryOperation(BinaryOperationID::kDivide) -//.resultTypeForArgumentTypes(sum_type, TypeFactory::GetType(kDouble)) -//->getNullableVersion()); -//} -// -//AggregationStateHashTableBase* AggregationHandleAvg::createGroupByHashTable( -//const HashTableImplType hash_table_impl, -//const std::vector &group_by_types, -//const std::size_t estimated_num_groups, -//StorageManager *storage_manager) const { -// return AggregationStateHashTableFactory::CreateResizable( -// hash_table_impl, group_by_types, estimated_num_groups, storage_manager); -//} -// -//AggregationState* AggregationHandleAvg::accumulateColumnVectors( -//const std::vector> &column_vectors) const { -// DCHECK_EQ(1u, column_vectors.size()) -// << "Got wrong number of ColumnVectors for AVG: " << column_vectors.size(); -// -// AggregationStateAvg *state = new AggregationStateAvg(blank_state_); -// std::size_t count = 0; -// state->sum_ = fast_add_operator_->accumulateColumnVector( -//
[2/6] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/storage/FastHashTableFactory.hpp -- diff --git a/storage/FastHashTableFactory.hpp b/storage/FastHashTableFactory.hpp deleted file mode 100644 index 6d0b693..000 --- a/storage/FastHashTableFactory.hpp +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Copyright 2015-2016 Pivotal Software, Inc. - * - * Licensed 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_STORAGE_FAST_HASH_TABLE_FACTORY_HPP_ -#define QUICKSTEP_STORAGE_FAST_HASH_TABLE_FACTORY_HPP_ - -#include -#include -#include - -#include "storage/HashTable.hpp" -#include "storage/FastHashTable.hpp" -#include "storage/HashTableBase.hpp" -#include "storage/HashTableFactory.hpp" -#include "storage/HashTable.pb.h" -#include "storage/LinearOpenAddressingHashTable.hpp" -#include "storage/SeparateChainingHashTable.hpp" -#include "storage/FastSeparateChainingHashTable.hpp" -#include "storage/SimpleScalarSeparateChainingHashTable.hpp" -#include "storage/TupleReference.hpp" -#include "types/TypeFactory.hpp" -#include "utility/BloomFilter.hpp" -#include "utility/Macros.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -class StorageManager; -class Type; - -/** \addtogroup Storage - * @{ - */ - -/** - * @brief Templated all-static factory class that makes it easier to - *instantiate HashTables with the particular HashTable implementation - *chosen at runtime. All template parameters are exactly the same as - *those of HashTable. - **/ -template -class FastHashTableFactory { - public: - /** - * @brief Create a new resizable HashTable, with the type selected by - *hash_table_type. Other parameters are forwarded to the HashTable's - *constructor. - * - * @param hash_table_type The specific HashTable implementation that should - *be used. - * @param key_types A vector of one or more types (>1 indicates a composite - *key). Forwarded as-is to the HashTable's constructor. - * @param num_entries The estimated number of entries the HashTable will - *hold. Forwarded as-is to the HashTable's constructor. - * @param payload_sizes The sizes in bytes for the AggregationStates for the - *respective AggregationHandles. - * @param handles The AggregationHandles used in this HashTable. - * @param storage_manager The StorageManager to use (a StorageBlob will be - *allocated to hold the HashTable's contents). Forwarded as-is to the - *HashTable's constructor. - * @return A new resizable HashTable. - **/ - static FastHashTable* - CreateResizable(const HashTableImplType hash_table_type, - const std::vector &key_types, - const std::size_t num_entries, - const std::vector &payload_sizes, - const std::vector &handles, - StorageManager *storage_manager) { -DCHECK(resizable); - -switch (hash_table_type) { - case HashTableImplType::kSeparateChaining: -return new FastSeparateChainingHashTable< -resizable, -serializable, -force_key_copy, -allow_duplicate_keys>(key_types, num_entries, payload_sizes, handles, storage_manager); - default: { -LOG(FATAL) << "Unrecognized HashTableImplType in HashTableFactory::createResizable()\n"; - } -} - } - - /** - * @brief Create a new fixed-sized HashTable, with the type selected by - *hash_table_type. Other parameters are forwarded to the HashTables's - *constructor. - * - * @param hash_table_type The specific HashTable implementation that should - *be used. - * @param key_types A vector of one or more types (>1 indicates a composite - *key). Forwarded as-is to the HashTable's constructor. - * @param hash_table_memory A pointer to memory to use for the HashTable. - *Forwarded as-is to the HashTable's constructor. - * @param hash_table_memory_size The size of hash_table_memory in bytes. - *Forwarded as-is to the HashTable's constructor. - * @param new_hash_table If true, the HashTable is being constructed for the - *first time and hash_table_memory will be cleared. If false, reload - *a pre-existing HashTable. Forwarded as-is to the HashTable's - *
[1/6] incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/untyped-agg 140069b95 -> 9ccd5a311 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/storage/HashTablePool.hpp -- diff --git a/storage/HashTablePool.hpp b/storage/HashTablePool.hpp index faa0abc..124b4f5 100644 --- a/storage/HashTablePool.hpp +++ b/storage/HashTablePool.hpp @@ -20,6 +20,7 @@ #ifndef QUICKSTEP_STORAGE_HASH_TABLE_POOL_HPP_ #define QUICKSTEP_STORAGE_HASH_TABLE_POOL_HPP_ +#include #include #include #include @@ -27,9 +28,7 @@ #include "expressions/aggregation/AggregationHandle.hpp" #include "storage/HashTableBase.hpp" -#include "storage/AggregationHashTable.hpp" -#include "storage/FastHashTable.hpp" -#include "storage/FastHashTableFactory.hpp" +#include "storage/AggregationStateHashTable.hpp" #include "threading/SpinMutex.hpp" #include "utility/Macros.hpp" #include "utility/StringUtil.hpp" @@ -57,36 +56,6 @@ class HashTablePool { /** * @brief Constructor. * - * @param estimated_num_entries The maximum number of entries in a hash table. - * @param hash_table_impl_type The type of hash table implementation. - * @param group_by_types A vector of pointer of types which form the group by - *key. - * @param agg_handle The aggregation handle. - * @param storage_manager A pointer to the storage manager. - * - * @note The estimate of number of entries is quite inaccurate at this time. - * If we go by the current estimate, each hash table demands much - * larger space than it actually needs, which causes the system to - * either trigger evictions or worse - run out of memory. To fix this - * issue, we divide the estimate by 100. The division will not affect - * correctness, however it may allocate some hash tables smaller space - * than their requirement, causing them to be resized during build - * phase, which has a performance penalty. - **/ - HashTablePool(const std::size_t estimated_num_entries, -const HashTableImplType hash_table_impl_type, -const std::vector &group_by_types, -AggregationHandle *agg_handle, -StorageManager *storage_manager) - : estimated_num_entries_(reduceEstimatedCardinality(estimated_num_entries)), -hash_table_impl_type_(hash_table_impl_type), -group_by_types_(group_by_types), -agg_handle_(DCHECK_NOTNULL(agg_handle)), -storage_manager_(DCHECK_NOTNULL(storage_manager)) {} - - /** - * @brief Constructor. - * * @note This constructor is relevant for HashTables specialized for * aggregation. * @@ -94,52 +63,29 @@ class HashTablePool { * @param hash_table_impl_type The type of hash table implementation. * @param group_by_types A vector of pointer of types which form the group by *key. - * @param payload_sizes The sizes in bytes for the AggregationStates for the - *respective AggregationHandles. * @param handles The AggregationHandles in this query. * @param storage_manager A pointer to the storage manager. **/ HashTablePool(const std::size_t estimated_num_entries, const HashTableImplType hash_table_impl_type, const std::vector &group_by_types, -const std::vector &payload_sizes, const std::vector &handles, StorageManager *storage_manager) : estimated_num_entries_(reduceEstimatedCardinality(estimated_num_entries)), hash_table_impl_type_(hash_table_impl_type), group_by_types_(group_by_types), -payload_sizes_(payload_sizes), handles_(handles), storage_manager_(DCHECK_NOTNULL(storage_manager)) {} /** * @brief Check out a hash table for insertion. * - * @return A hash table pointer. - **/ - AggregationStateHashTableBase* getHashTable() { -{ - SpinMutexLock lock(mutex_); - if (!hash_tables_.empty()) { -std::unique_ptr ret_hash_table( -std::move(hash_tables_.back())); -hash_tables_.pop_back(); -DCHECK(ret_hash_table != nullptr); -return ret_hash_table.release(); - } -} -return createNewHashTable(); - } - - /** - * @brief Check out a hash table for insertion. - * * @note This method is relevant for specialized (for aggregation) * hash table implementation. * * @return A hash table pointer. **/ - AggregationStateHashTableBase* getHashTableFast() { + AggregationStateHashTableBase* getHashTable() { { SpinMutexLock lock(mutex_); if (!hash_tables_.empty()) { @@ -150,7 +96,7 @@ class HashTablePool { return ret_hash_table.release(); } } -return createNewHashTableFast(); +return createNewHashTable(); } /** @@ -174,63 +120,38 @@ class HashTablePool { * @par
[3/6] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/storage/FastHashTable.hpp -- diff --git a/storage/FastHashTable.hpp b/storage/FastHashTable.hpp deleted file mode 100644 index 4a95cd9..000 --- a/storage/FastHashTable.hpp +++ /dev/null @@ -1,2515 +0,0 @@ -/** - * Copyright 2011-2015 Quickstep Technologies LLC. - * Copyright 2015-2016 Pivotal Software, Inc. - * Copyright 2016, Quickstep Research Group, Computer Sciences Department, - * University of Wisconsin—Madison. - * - * Licensed 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_STORAGE_FAST_HASH_TABLE_HPP_ -#define QUICKSTEP_STORAGE_FAST_HASH_TABLE_HPP_ - -#include -#include -#include -#include -#include - -#include "catalog/CatalogTypedefs.hpp" -#include "storage/HashTableBase.hpp" -#include "storage/StorageBlob.hpp" -#include "storage/StorageBlockInfo.hpp" -#include "storage/StorageConstants.hpp" -#include "storage/StorageManager.hpp" -#include "storage/TupleReference.hpp" -#include "storage/ValueAccessor.hpp" -#include "storage/ValueAccessorUtil.hpp" -#include "threading/SpinMutex.hpp" -#include "threading/SpinSharedMutex.hpp" -#include "types/Type.hpp" -#include "types/TypedValue.hpp" -#include "utility/BloomFilter.hpp" -#include "utility/HashPair.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -/** \addtogroup Storage - * @{ - */ - -/** - * @brief Base class for the hash table implementation in which the payload can - *be just a bunch of bytes. This implementation is suitable for - *aggregation hash table with multiple aggregation handles (e.g. SUM, - *MAX, MIN etc). - * - * At present there is one implementation for this base class. - * 1. SeparateChainingHashTable - Keys/values are stored in a separate - * region of memory from the base hash table slot array. Every bucket - * has a "next" pointer so that entries that collide (i.e. map to the - * same base slot) form chains of pointers with each other. Although - * this implementation has some extra indirection compared to - * LinearOpenAddressingHashTable, it does not have the same - * vulnerabilities to key skew, and it additionally supports a very - * efficient bucket-preallocation mechanism that minimizes cache - * coherency overhead when multiple threads are building a HashTable. - * - * @note If you need to create a HashTable and not just use it as a client, see - * HashTableFactory, which simplifies the process of creating a - * HashTable. - * - * @param resizable Whether this hash table is resizable (using memory from a - *StorageManager) or not (using a private, fixed memory allocation). - * @param serializable If true, this hash table can safely be saved to and - *loaded from disk. If false, some out of band memory may be used (e.g. - *to store variable length keys). - * @param force_key_copy If true, inserted keys are always copied into this - *HashTable's memory. If false, pointers to external values may be - *stored instead. force_key_copy should be true if the hash table will - *outlive the external key values which are inserted into it. Note that - *if serializable is true and force_key_copy is false, then relative - *offsets will be used instead of absolute pointers to keys, meaning - *that the pointed-to keys must be serialized and deserialized in - *exactly the same relative byte order (e.g. as part of the same - *StorageBlock), and keys must not change position relative to this - *HashTable (beware TupleStorageSubBlocks that may self-reorganize when - *modified). If serializable and resizable are both true, then - *force_key_copy must also be true. - * @param allow_duplicate_keys If true, multiple values can be mapped to the - *same key. If false, one and only one value may be mapped. - **/ -template -class FastHashTable : public HashTableBase { - static_assert(!(serializable && resizable && !force_key_copy), -"A HashTable must have force_key_copy=true when serializable " -"and resizable are both true."); - - public: - // Shadow template parameters. This is useful for shared test harnesses. - static constexpr bool template_resizable = resizable; - static co
[4/6] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/storage/AggregationOperationState.hpp -- diff --git a/storage/AggregationOperationState.hpp b/storage/AggregationOperationState.hpp index cbbfc22..9fa3bd2 100644 --- a/storage/AggregationOperationState.hpp +++ b/storage/AggregationOperationState.hpp @@ -34,6 +34,7 @@ #include "storage/HashTablePool.hpp" #include "storage/StorageBlockInfo.hpp" #include "utility/Macros.hpp" +#include "utility/ScopedBuffer.hpp" namespace quickstep { @@ -167,8 +168,8 @@ class AggregationOperationState { **/ void finalizeAggregate(InsertDestination *output_destination); - static void mergeGroupByHashTables(AggregationStateHashTableBase *src, - AggregationStateHashTableBase *dst); + static void mergeGroupByHashTables(AggregationStateHashTableBase *destination_hash_table, + const AggregationStateHashTableBase *source_hash_table); int dflag; @@ -176,7 +177,7 @@ class AggregationOperationState { // Merge locally (per storage block) aggregated states with global aggregation // states. void mergeSingleState( - const std::vector> &local_state); + const std::vector &local_state); // Aggregate on input block. void aggregateBlockSingleState(const block_id input_block); @@ -201,10 +202,6 @@ class AggregationOperationState { // arguments. std::vector is_distinct_; - // Hash table for obtaining distinct (i.e. unique) arguments. - std::vector> - distinctify_hashtables_; - #ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION // If all an aggregate's argument expressions are simply attributes in // 'input_relation_', then this caches the attribute IDs of those arguments. @@ -212,14 +209,7 @@ class AggregationOperationState { #endif // Per-aggregate global states for aggregation without GROUP BY. - std::vector> single_states_; - - // Per-aggregate HashTables for aggregation with GROUP BY. - // - // TODO(shoban): We should ideally store the aggregation state together in one - // hash table to prevent multiple lookups. - std::vector> - group_by_hashtables_; + std::vector single_states_; // A vector of group by hash table pools. std::unique_ptr group_by_hashtable_pool_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/storage/AggregationResultIterator.hpp -- diff --git a/storage/AggregationResultIterator.hpp b/storage/AggregationResultIterator.hpp new file mode 100644 index 000..259c533 --- /dev/null +++ b/storage/AggregationResultIterator.hpp @@ -0,0 +1,104 @@ +/** + * 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_STORAGE_AGGREGATION_RESULT_ITERATOR_HPP_ +#define QUICKSTEP_STORAGE_AGGREGATION_RESULT_ITERATOR_HPP_ + +#include +#include + +#include "storage/AggregationStateManager.hpp" +#include "storage/HashTableUntypedKeyManager.hpp" +#include "utility/Macros.hpp" + +namespace quickstep { + +/** \addtogroup Storage + * @{ + */ + +class AggregationResultIterator { + public: + AggregationResultIterator(const void *buckets, +const std::size_t bucket_size, +const std::size_t num_entries, +const HashTableUntypedKeyManager &key_manager, +const AggregationStateManager &state_manager) + : buckets_(buckets), +bucket_size_(bucket_size), +num_entries_(num_entries), +key_manager_(key_manager), +state_manager_(state_manager) {} + + inline std::size_t getKeySize() const { +return key_manager_.getFixedKeySize(); + } + + inline std::size_t getResultsSize() const { +return state_manager_.getResultsSizeInBytes(); + } + + inline void beginIteration() { +current_position_ = std::numeric_limits::max(); + } + + inline bool iterationFinished() const { +return current_position_ + 1 >= num_entries_; + } + + inline bool next() { +++current_position_; +return current_position_ < num_entries_; + } + +
[6/6] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9ccd5a31 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9ccd5a31 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9ccd5a31 Branch: refs/heads/untyped-agg Commit: 9ccd5a31189823f0e63b0a34ec02978c8695b25f Parents: 140069b Author: Jianqiao Zhu Authored: Mon Oct 17 16:55:49 2016 -0500 Committer: Jianqiao Zhu Committed: Mon Oct 17 16:55:49 2016 -0500 -- .../aggregation/AggregationConcreteHandle.cpp | 68 - .../aggregation/AggregationConcreteHandle.hpp | 325 --- expressions/aggregation/AggregationHandle.hpp | 405 +-- .../aggregation/AggregationHandleAvg.cpp| 321 ++- .../aggregation/AggregationHandleAvg.hpp| 200 +- .../aggregation/AggregationHandleCount.cpp | 134 +- .../aggregation/AggregationHandleCount.hpp | 183 +- .../aggregation/AggregationHandleDistinct.cpp | 81 - .../aggregation/AggregationHandleDistinct.hpp | 130 - .../aggregation/AggregationHandleMax.cpp| 190 +- .../aggregation/AggregationHandleMax.hpp| 174 +- .../aggregation/AggregationHandleMin.cpp| 192 +- .../aggregation/AggregationHandleMin.hpp| 176 +- .../aggregation/AggregationHandleSum.cpp| 128 +- .../aggregation/AggregationHandleSum.hpp| 187 +- expressions/aggregation/CMakeLists.txt | 49 +- storage/AggregationHashTable.hpp| 330 --- storage/AggregationOperationState.cpp | 317 +-- storage/AggregationOperationState.hpp | 20 +- storage/AggregationResultIterator.hpp | 104 + storage/AggregationStateHashTable.hpp | 338 +++ storage/AggregationStateManager.hpp | 181 ++ storage/CMakeLists.txt | 98 +- storage/FastHashTable.hpp | 2515 -- storage/FastHashTableFactory.hpp| 257 -- storage/FastSeparateChainingHashTable.hpp | 1734 storage/HashTableBase.hpp | 43 +- storage/HashTablePool.hpp | 109 +- storage/HashTableUntypedKeyManager.hpp | 34 +- storage/InsertDestination.cpp | 18 + storage/InsertDestination.hpp |3 + storage/PackedRowStoreTupleStorageSubBlock.cpp | 30 + storage/PackedRowStoreTupleStorageSubBlock.hpp |3 + storage/StorageBlock.cpp| 152 +- storage/StorageBlock.hpp| 55 +- storage/TupleStorageSubBlock.hpp|7 + types/CharType.hpp | 12 + types/DateType.hpp | 13 +- types/DatetimeIntervalType.hpp | 12 +- types/DatetimeLit.hpp |4 + types/DatetimeType.hpp | 12 +- types/NullType.hpp |4 + types/NumericSuperType.hpp | 11 +- types/Type.hpp |9 +- types/TypeFunctors.cpp | 54 +- types/TypeFunctors.hpp | 15 +- types/VarCharType.hpp | 12 + types/YearMonthIntervalType.hpp | 12 +- .../ArithmeticBinaryOperators.hpp | 20 + .../binary_operations/BinaryOperation.hpp |7 + 50 files changed, 1592 insertions(+), 7896 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/expressions/aggregation/AggregationConcreteHandle.cpp -- diff --git a/expressions/aggregation/AggregationConcreteHandle.cpp b/expressions/aggregation/AggregationConcreteHandle.cpp deleted file mode 100644 index e3fb520..000 --- a/expressions/aggregation/AggregationConcreteHandle.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the Lic
[5/6] incubator-quickstep git commit: Updates
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9ccd5a31/expressions/aggregation/AggregationHandleMax.cpp -- diff --git a/expressions/aggregation/AggregationHandleMax.cpp b/expressions/aggregation/AggregationHandleMax.cpp index c2d571b..d40ae9f 100644 --- a/expressions/aggregation/AggregationHandleMax.cpp +++ b/expressions/aggregation/AggregationHandleMax.cpp @@ -38,100 +38,100 @@ namespace quickstep { class StorageManager; -AggregationHandleMax::AggregationHandleMax(const Type &type) -: type_(type), block_update_(false) { - fast_comparator_.reset( - ComparisonFactory::GetComparison(ComparisonID::kGreater) - .makeUncheckedComparatorForTypes(type, type.getNonNullableVersion())); -} - -AggregationStateHashTableBase* AggregationHandleMax::createGroupByHashTable( -const HashTableImplType hash_table_impl, -const std::vector &group_by_types, -const std::size_t estimated_num_groups, -StorageManager *storage_manager) const { - return AggregationStateHashTableFactory::CreateResizable( - hash_table_impl, group_by_types, estimated_num_groups, storage_manager); -} - -AggregationState* AggregationHandleMax::accumulateColumnVectors( -const std::vector> &column_vectors) const { - DCHECK_EQ(1u, column_vectors.size()) - << "Got wrong number of ColumnVectors for MAX: " << column_vectors.size(); - - return new AggregationStateMax(fast_comparator_->accumulateColumnVector( - type_.getNullableVersion().makeNullValue(), *column_vectors.front())); -} - -#ifdef QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION -AggregationState* AggregationHandleMax::accumulateValueAccessor( -ValueAccessor *accessor, -const std::vector &accessor_ids) const { - DCHECK_EQ(1u, accessor_ids.size()) - << "Got wrong number of attributes for MAX: " << accessor_ids.size(); - - return new AggregationStateMax(fast_comparator_->accumulateValueAccessor( - type_.getNullableVersion().makeNullValue(), - accessor, - accessor_ids.front())); -} -#endif // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION - -void AggregationHandleMax::aggregateValueAccessorIntoHashTable( -ValueAccessor *accessor, -const std::vector &argument_ids, -const std::vector &group_by_key_ids, -AggregationStateHashTableBase *hash_table) const { - DCHECK_EQ(1u, argument_ids.size()) - << "Got wrong number of arguments for MAX: " << argument_ids.size(); -} - -void AggregationHandleMax::mergeStates(const AggregationState &source, - AggregationState *destination) const { - const AggregationStateMax &max_source = - static_cast(source); - AggregationStateMax *max_destination = - static_cast(destination); - - if (!max_source.max_.isNull()) { -compareAndUpdate(max_destination, max_source.max_); - } -} - -void AggregationHandleMax::mergeStatesFast(const std::uint8_t *source, - std::uint8_t *destination) const { - const TypedValue *src_max_ptr = reinterpret_cast(source); - TypedValue *dst_max_ptr = reinterpret_cast(destination); - if (!(src_max_ptr->isNull())) { -compareAndUpdateFast(dst_max_ptr, *src_max_ptr); - } -} - -ColumnVector* AggregationHandleMax::finalizeHashTable( -const AggregationStateHashTableBase &hash_table, -std::vector> *group_by_keys, -int index) const { - return finalizeHashTableHelperFast( - type_.getNullableVersion(), hash_table, group_by_keys, index); -} - -AggregationState* -AggregationHandleMax::aggregateOnDistinctifyHashTableForSingle( -const AggregationStateHashTableBase &distinctify_hash_table) const { - return aggregateOnDistinctifyHashTableForSingleUnaryHelperFast< - AggregationHandleMax, - AggregationStateMax>(distinctify_hash_table); -} - -void AggregationHandleMax::aggregateOnDistinctifyHashTableForGroupBy( -const AggregationStateHashTableBase &distinctify_hash_table, -AggregationStateHashTableBase *aggregation_hash_table, -std::size_t index) const { - aggregateOnDistinctifyHashTableForGroupByUnaryHelperFast< - AggregationHandleMax, - AggregationStateFastHashTable>( - distinctify_hash_table, aggregation_hash_table, index); -} +AggregationHandleMax::AggregationHandleMax(const Type &type) {} +//: type_(type), block_update_(false) { +// fast_comparator_.reset( +// ComparisonFactory::GetComparison(ComparisonID::kGreater) +// .makeUncheckedComparatorForTypes(type, type.getNonNullableVersion())); +//} +// +//AggregationStateHashTableBase* AggregationHandleMax::createGroupByHashTable( +//const HashTableImplType hash_table_impl, +//const std::vector &group_by_types, +//const std::size_t estimated_num_groups, +//StorageManager *storage_manager) const { +// return AggregationStateHashTableFactory::CreateResizable( +// hash_table_impl, group_by_types, estimated_num_groups, storage_
[2/2] incubator-quickstep git commit: Updates
Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3fcbd5d7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3fcbd5d7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3fcbd5d7 Branch: refs/heads/inline-memcpy Commit: 3fcbd5d787ae483dd547294d52151151945bcc57 Parents: 07cff2d Author: Jianqiao Zhu Authored: Sat Oct 15 18:14:50 2016 -0500 Committer: Jianqiao Zhu Committed: Sat Oct 15 18:14:50 2016 -0500 -- .../BasicColumnStoreTupleStorageSubBlock.cpp| 88 +++- .../BasicColumnStoreTupleStorageSubBlock.hpp| 4 + storage/PackedRowStoreTupleStorageSubBlock.cpp | 75 ++--- storage/PackedRowStoreTupleStorageSubBlock.hpp | 2 + storage/StorageBlockLayout.cpp | 1 + 5 files changed, 134 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3fcbd5d7/storage/BasicColumnStoreTupleStorageSubBlock.cpp -- diff --git a/storage/BasicColumnStoreTupleStorageSubBlock.cpp b/storage/BasicColumnStoreTupleStorageSubBlock.cpp index a62ab02..f4ef126 100644 --- a/storage/BasicColumnStoreTupleStorageSubBlock.cpp +++ b/storage/BasicColumnStoreTupleStorageSubBlock.cpp @@ -313,19 +313,39 @@ tuple_id BasicColumnStoreTupleStorageSubBlock::bulkInsertTuples(ValueAccessor *a ++(header_->num_tuples); } } else { - while (this->hasSpaceToInsert(1) && accessor->next()) { -attribute_id accessor_attr_id = 0; -for (CatalogRelationSchema::const_iterator attr_it = relation_.begin(); - attr_it != relation_.end(); - ++attr_it) { - const std::size_t attr_size = attr_it->getType().maximumByteLength(); - InlineMemcpy(static_cast(column_stripes_[attr_it->getID()]) - + header_->num_tuples * attr_size, - accessor->template getUntypedValue(accessor_attr_id), + const std::size_t max_tuples = this->getNumAvailableTuplesForInsertion(); + const std::size_t num_attrs = relation_.size(); + const std::vector &attrs_max_size = + relation_.getMaximumAttributeByteLengths(); + + if (num_attrs == 1) { +const std::size_t attr_size = attrs_max_size.front(); +char *dest_addr = static_cast(column_stripes_.front()) + + header_->num_tuples * attr_size; +for (std::size_t i = 0; i < max_tuples && accessor->next(); ++i) { + InlineMemcpy(dest_addr, + accessor->template getUntypedValue(0), attr_size); - ++accessor_attr_id; + dest_addr += attr_size; + ++(header_->num_tuples); } -++(header_->num_tuples); + } else { +std::vector tuples; +for (std::size_t i = 0; i < max_tuples && accessor->next(); ++i) { + tuples.emplace_back(accessor->getCurrentPosition()); +} +for (attribute_id attr_id = 0; attr_id < num_attrs; ++attr_id) { + const std::size_t attr_size = attrs_max_size[attr_id]; + char *dest_addr = static_cast(column_stripes_[attr_id]) ++ header_->num_tuples * attr_size; + for (const tuple_id tid : tuples) { +InlineMemcpy(dest_addr, + accessor->template getUntypedValueAtAbsolutePosition(attr_id, tid), + attr_size); +dest_addr += attr_size; + } +} +header_->num_tuples += tuples.size(); } } }); @@ -376,19 +396,41 @@ tuple_id BasicColumnStoreTupleStorageSubBlock::bulkInsertTuplesWithRemappedAttri ++(header_->num_tuples); } } else { - while (this->hasSpaceToInsert(1) && accessor->next()) { -std::vector::const_iterator attribute_map_it = attribute_map.begin(); -for (CatalogRelationSchema::const_iterator attr_it = relation_.begin(); - attr_it != relation_.end(); - ++attr_it) { - const std::size_t attr_size = attr_it->getType().maximumByteLength(); - InlineMemcpy(static_cast(column_stripes_[attr_it->getID()]) - + header_->num_tuples * attr_size, - accessor->template getUntypedValue(*attribute_map_it), - attr_size); - ++attribute_map_it; + const std::size_t max_tuples = this->getNumAvailableTuplesForInsertion(); + const std::size_t num_attrs = relation_.size(); + const std::vector &attrs_max_size = + relation_.getMaximumAttributeByteLengths(); + + if (num_attrs == 1) { +const attribute_id attr_id = attribute_map.front(); +const
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor c4bf1e62d -> 969b02f57 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/969b02f5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/969b02f5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/969b02f5 Branch: refs/heads/lip-refactor Commit: 969b02f577aa09122170e129b56f952d416ad9c8 Parents: c4bf1e6 Author: Jianqiao Zhu Authored: Wed Oct 12 15:53:05 2016 -0500 Committer: Jianqiao Zhu Committed: Wed Oct 12 15:53:05 2016 -0500 -- .../StarSchemaHashJoinOrderOptimization.cpp | 66 +--- .../StarSchemaHashJoinOrderOptimization.hpp | 29 - relational_operators/HashJoinOperator.cpp | 40 +++- utility/lip_filter/LIPFilter.hpp| 2 + utility/lip_filter/SingleIdentityHashFilter.hpp | 14 - 5 files changed, 96 insertions(+), 55 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/969b02f5/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp -- diff --git a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp index 150d9d7..78a1680 100644 --- a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp +++ b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp @@ -28,6 +28,7 @@ #include "query_optimizer/expressions/AttributeReference.hpp" #include "query_optimizer/expressions/NamedExpression.hpp" #include "query_optimizer/expressions/PatternMatcher.hpp" +#include "query_optimizer/physical/Aggregate.hpp" #include "query_optimizer/physical/HashJoin.hpp" #include "query_optimizer/physical/PatternMatcher.hpp" #include "query_optimizer/physical/Physical.hpp" @@ -75,7 +76,7 @@ P::PhysicalPtr StarSchemaHashJoinOrderOptimization::applyInternal(const P::Physi JoinGroupInfo *join_group = nullptr; if (parent_join_group == nullptr || !is_valid_cascading_hash_join) { new_join_group.reset(new JoinGroupInfo()); - for (const auto &attr : input->getReferencedAttributes()) { + for (const auto &attr : input->getOutputAttributes()) { new_join_group->referenced_attributes.emplace(attr->id()); } join_group = new_join_group.get(); @@ -211,14 +212,14 @@ physical::PhysicalPtr StarSchemaHashJoinOrderOptimization::generatePlan( if (probe_table_info != build_table_info) { const std::size_t probe_table_id = probe_table_info->table_info_id; const std::size_t build_table_id = build_table_info->table_info_id; - bool has_join_attribute = false; + std::size_t num_join_attributes = 0; double build_side_uniqueness = 1.0; for (const auto &attr_group_pair : join_attribute_groups) { const auto &attr_group = attr_group_pair.second; auto probe_it = attr_group.find(probe_table_id); auto build_it = attr_group.find(build_table_id); if (probe_it != attr_group.end() && build_it != attr_group.end()) { - has_join_attribute = true; + ++num_join_attributes; build_side_uniqueness *= std::max( 1uL, cost_model_->estimateNumDistinctValues( @@ -227,27 +228,29 @@ physical::PhysicalPtr StarSchemaHashJoinOrderOptimization::generatePlan( } build_side_uniqueness /= build_table_info->estimated_cardinality; - if (has_join_attribute) { + if (num_join_attributes > 0) { +//std::cerr << "Unqueness = " << build_side_uniqueness << "\n"; std::unique_ptr new_join( new JoinPair(probe_table_info, build_table_info, - build_side_uniqueness >= 0.9)); + build_side_uniqueness >= 0.9, + num_join_attributes)); if (best_join == nullptr || new_join->isBetterThan(*best_join)) { - if (best_join != nullptr) { -std::cerr << "(" << best_join->probe->estimated_selectivity - << ", " << best_join->probe->estimated_cardinality << ")" - << " -- " - << "(" << best_join->build->estimated_selectivity - << ", " << best_join->build->estimated_cardinality << ")" - << "\n"; -std::cerr << "REPLACED WITH\n"; - } - std::cerr << "(" << new_join->probe->estimated_selectivity -<< ", " << new_join->probe->estimated_cardinality <<
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor-optimizer 166860222 -> 3cfea1d5b Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3cfea1d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3cfea1d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3cfea1d5 Branch: refs/heads/lip-refactor-optimizer Commit: 3cfea1d5b4d92277f7f38ead630186156f3e733e Parents: 1668602 Author: Jianqiao Zhu Authored: Tue Oct 11 14:08:53 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 11 14:08:53 2016 -0500 -- query_optimizer/PhysicalGenerator.cpp | 2 +- query_optimizer/physical/TopLevelPlan.hpp | 41 +--- query_optimizer/rules/AttachLIPFilters.cpp | 10 + query_optimizer/rules/AttachLIPFilters.hpp | 18 + .../StarSchemaHashJoinOrderOptimization.hpp | 6 ++- utility/CMakeLists.txt | 4 +- utility/DisjointTreeForest.hpp | 1 + utility/lip_filter/CMakeLists.txt | 2 +- utility/lip_filter/LIPFilter.hpp| 12 -- 9 files changed, 56 insertions(+), 40 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3cfea1d5/query_optimizer/PhysicalGenerator.cpp -- diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp index 41d822e..8143d5c 100644 --- a/query_optimizer/PhysicalGenerator.cpp +++ b/query_optimizer/PhysicalGenerator.cpp @@ -51,7 +51,7 @@ DEFINE_bool(reorder_hash_joins, true, "for queries on star-schema tables."); DEFINE_bool(use_lip_filters, false, -"If true, use LIP (Lookahead Information Passing) filters to accelerate " +"If true, use LIP (lookahead information passing) filters to accelerate " "hash joins."); DEFINE_bool(visualize_plan, false, http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3cfea1d5/query_optimizer/physical/TopLevelPlan.hpp -- diff --git a/query_optimizer/physical/TopLevelPlan.hpp b/query_optimizer/physical/TopLevelPlan.hpp index c6ea940..7dfc2b6 100644 --- a/query_optimizer/physical/TopLevelPlan.hpp +++ b/query_optimizer/physical/TopLevelPlan.hpp @@ -90,6 +90,29 @@ class TopLevelPlan : public Physical { return shared_subplans_[index]; } + /** + * @brief Creates a copy of the TopLevelPlan with lip_filter_configuration_ + *replaced by \p new_lip_filter_configuration. + * + * @param new_lip_filter_configuration The new lip_filter_configuration to be + *substituted for the existing one. + * @return A copy of this TopLevelPlan with the new lip_filter_configuration. + */ + TopLevelPlanPtr copyWithLIPFilterConfiguration( + const LIPFilterConfigurationPtr &new_lip_filter_configuration) const { +return TopLevelPlan::Create(plan_, +shared_subplans_, +uncorrelated_subquery_map_, +new_lip_filter_configuration); + } + + /** + * @return The LIPFilter configuration information for the overall query plan. + */ + const LIPFilterConfigurationPtr& lip_filter_configuration() const { +return lip_filter_configuration_; + } + PhysicalPtr copyWithNewChildren( const std::vector &new_children) const override { DCHECK_EQ(getNumChildren(), new_children.size()); @@ -121,25 +144,15 @@ class TopLevelPlan : public Physical { return false; } - TopLevelPlanPtr copyWithLIPFilterConfiguration( - const LIPFilterConfigurationPtr &new_lip_filter_configuration) const { -return TopLevelPlan::Create(plan_, -shared_subplans_, -uncorrelated_subquery_map_, -new_lip_filter_configuration); - } - - const LIPFilterConfigurationPtr& lip_filter_configuration() const { -return lip_filter_configuration_; - } - /** * @brief Creates a TopLevelPlan. * * @param plan The query plan. * @param shared_subplans The subplans referenced in the main input plan. - * @param Map from the expression ID of an attribute reference to the - *uncorrelated subquery that produces the attribute. + * @param uncorrelated_subquery_map Map from the expression ID of an attribute + *reference to the uncorrelated subquery that produces the attribute. + * @param lip_filter_configuration The LIPFilter configuration information + *for the overall query plan. * @return An immutable TopLevelPlan. */ static TopLevelPl
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor-optimizer 10eff2c1d -> 166860222 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/16686022 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/16686022 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/16686022 Branch: refs/heads/lip-refactor-optimizer Commit: 166860222deedb0dbf64e36bde66e43320bf72f3 Parents: 10eff2c Author: Jianqiao Zhu Authored: Tue Oct 11 13:33:13 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 11 13:33:13 2016 -0500 -- query_optimizer/ExecutionGenerator.cpp | 17 query_optimizer/ExecutionGenerator.hpp | 5 +- query_optimizer/PhysicalGenerator.cpp | 4 + .../physical/LIPFilterConfiguration.hpp | 68 -- .../StarSchemaHashJoinOrderOptimization.hpp | 5 - utility/CMakeLists.txt | 7 ++ utility/DisjointTreeForest.hpp | 52 +-- utility/PlanVisualizer.cpp | 4 +- utility/lip_filter/LIPFilter.hpp| 27 -- utility/tests/DisjointTreeForest_unittest.cpp | 97 10 files changed, 216 insertions(+), 70 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/16686022/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 9347c9c..29dec38 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -54,7 +54,6 @@ #include "expressions/window_aggregation/WindowAggregateFunction.pb.h" #include "query_execution/QueryContext.hpp" #include "query_execution/QueryContext.pb.h" -#include "query_optimizer/ExecutionHeuristics.hpp" #include "query_optimizer/OptimizerContext.hpp" #include "query_optimizer/QueryHandle.hpp" #include "query_optimizer/QueryPlan.hpp" @@ -211,11 +210,6 @@ void ExecutionGenerator::generatePlan(const P::PhysicalPtr &physical_plan) { temporary_relation_info.producer_operator_index); } - // Optimize execution plan based on heuristics captured during execution plan generation, if enabled. - if (FLAGS_optimize_joins) { -execution_heuristics_->optimizeExecutionPlan(execution_plan_, query_context_proto_); - } - #ifdef QUICKSTEP_DISTRIBUTED catalog_database_cache_proto_->set_name(catalog_database_->getName()); @@ -828,17 +822,6 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) { std::forward_as_tuple(join_operator_index, output_relation)); temporary_relation_info_vec_.emplace_back(join_operator_index, output_relation); - - // Add heuristics for the Hash Join, if enabled. - if (FLAGS_optimize_joins && !skip_hash_join_optimization) { -execution_heuristics_->addHashJoinInfo(build_operator_index, - join_operator_index, - referenced_stored_build_relation, - referenced_stored_probe_relation, - std::move(build_original_attribute_ids), - std::move(probe_original_attribute_ids), - join_hash_table_index); - } } void ExecutionGenerator::convertNestedLoopsJoin( http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/16686022/query_optimizer/ExecutionGenerator.hpp -- diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp index 2aaf5ab..495955e 100644 --- a/query_optimizer/ExecutionGenerator.hpp +++ b/query_optimizer/ExecutionGenerator.hpp @@ -33,7 +33,6 @@ #include "catalog/CatalogTypedefs.hpp" #include "query_execution/QueryContext.hpp" #include "query_execution/QueryContext.pb.h" -#include "query_optimizer/ExecutionHeuristics.hpp" #include "query_optimizer/QueryHandle.hpp" #include "query_optimizer/QueryPlan.hpp" #include "query_optimizer/cost_model/CostModel.hpp" @@ -102,8 +101,7 @@ class ExecutionGenerator { : catalog_database_(DCHECK_NOTNULL(catalog_database)), query_handle_(DCHECK_NOTNULL(query_handle)), execution_plan_(DCHECK_NOTNULL(query_handle->getQueryPlanMutable())), - query_context_proto_(DCHECK_NOTNULL(query_handle->getQueryContextProtoMutable())), -execution_heuristics_(new ExecutionHeuristics()) { + query_context_proto_(DCHECK_NOTNULL(query_handle->getQueryContextProtoMutable())) { query_context_proto
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor-optimizer 72b349d5f -> 10eff2c1d Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/10eff2c1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/10eff2c1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/10eff2c1 Branch: refs/heads/lip-refactor-optimizer Commit: 10eff2c1d6aff4d29db469e64897be9e1d984779 Parents: 72b349d Author: Jianqiao Zhu Authored: Tue Oct 11 11:04:27 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 11 11:04:27 2016 -0500 -- query_optimizer/CMakeLists.txt | 20 --- query_optimizer/ExecutionGenerator.cpp | 51 +++--- query_optimizer/ExecutionGenerator.hpp | 10 +- query_optimizer/LIPFilterGenerator.cpp | 190 -- query_optimizer/LIPFilterGenerator.hpp | 129 --- relational_operators/AggregationOperator.cpp | 21 +-- relational_operators/AggregationOperator.hpp | 9 +- relational_operators/BuildHashOperator.cpp | 23 +-- relational_operators/BuildHashOperator.hpp | 18 +- relational_operators/HashJoinOperator.cpp| 52 +- relational_operators/HashJoinOperator.hpp| 43 ++--- relational_operators/RelationalOperator.hpp | 12 +- relational_operators/SelectOperator.cpp | 67 +--- relational_operators/SelectOperator.hpp | 18 +- 14 files changed, 63 insertions(+), 600 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/10eff2c1/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index e1f36d1..fa9141c 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -41,7 +41,6 @@ add_subdirectory(tests) # Declare micro-libs: add_library(quickstep_queryoptimizer_ExecutionGenerator ExecutionGenerator.cpp ExecutionGenerator.hpp) -add_library(quickstep_queryoptimizer_LIPFilterGenerator LIPFilterGenerator.cpp LIPFilterGenerator.hpp) add_library(quickstep_queryoptimizer_LogicalGenerator LogicalGenerator.cpp LogicalGenerator.hpp) add_library(quickstep_queryoptimizer_LogicalToPhysicalMapper ../empty_src.cpp @@ -73,7 +72,6 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_expressions_windowaggregation_WindowAggregateFunction_proto quickstep_queryexecution_QueryContext quickstep_queryexecution_QueryContext_proto - quickstep_queryoptimizer_LIPFilterGenerator quickstep_queryoptimizer_OptimizerContext quickstep_queryoptimizer_QueryHandle quickstep_queryoptimizer_QueryPlan @@ -153,23 +151,6 @@ if (ENABLE_DISTRIBUTED) target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_catalog_Catalog_proto) endif() -target_link_libraries(quickstep_queryoptimizer_LIPFilterGenerator - glog - quickstep_catalog_CatalogAttribute - quickstep_catalog_CatalogTypedefs - quickstep_queryexecution_QueryContext - quickstep_queryexecution_QueryContext_proto - quickstep_queryoptimizer_QueryPlan - quickstep_queryoptimizer_physical_Aggregate - quickstep_queryoptimizer_physical_HashJoin - quickstep_queryoptimizer_physical_LIPFilterConfiguration - quickstep_queryoptimizer_physical_Physical - quickstep_queryoptimizer_physical_Selection - quickstep_relationaloperators_RelationalOperator - quickstep_types_Type - quickstep_utility_lipfilter_LIPFilter - quickstep_utility_lipfilter_LIPFilterDeployment - quickstep_utility_lipfilter_LIPFilter_proto) target_link_libraries(quickstep_queryoptimizer_LogicalGenerator glog quickstep_parser_ParseStatement @@ -243,7 +224,6 @@ target_link_libraries(quickstep_queryoptimizer_Validator add_library(quickstep_queryoptimizer ../empty_src.cpp QueryOptimizerModule.hpp) target_link_libraries(quickstep_queryoptimizer quickstep_queryoptimizer_ExecutionGenerator - quickstep_queryoptimizer_LIPFilterGenerator quickstep_queryoptimizer_LogicalGenerator quickstep_queryoptimizer_LogicalToPhysicalMapper quickstep_queryoptimizer_Optimizer
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor c4bb94421 -> c4bf1e62d Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/c4bf1e62 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/c4bf1e62 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/c4bf1e62 Branch: refs/heads/lip-refactor Commit: c4bf1e62dd80c923c45ec172ee25c955b3df0d4b Parents: c4bb944 Author: Jianqiao Zhu Authored: Tue Oct 11 10:38:54 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 11 10:38:54 2016 -0500 -- query_optimizer/ExecutionGenerator.cpp | 7 +- query_optimizer/ExecutionGenerator.hpp | 1 + query_optimizer/LIPFilterGenerator.cpp | 3 +- query_optimizer/LIPFilterGenerator.hpp | 3 +- query_optimizer/PhysicalGenerator.cpp | 6 +- .../cost_model/StarSchemaSimpleCostModel.cpp| 2 +- query_optimizer/rules/CMakeLists.txt| 1 + .../StarSchemaHashJoinOrderOptimization.cpp | 264 +++ .../StarSchemaHashJoinOrderOptimization.hpp | 104 +--- utility/CMakeLists.txt | 4 + utility/DisjointTreeForest.hpp | 116 utility/PlanVisualizer.cpp | 8 + 12 files changed, 378 insertions(+), 141 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4bf1e62/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 0436ae8..23d9a53 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -58,6 +58,7 @@ #include "query_optimizer/OptimizerContext.hpp" #include "query_optimizer/QueryHandle.hpp" #include "query_optimizer/QueryPlan.hpp" +#include "query_optimizer/cost_model/SimpleCostModel.hpp" #include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp" #include "query_optimizer/expressions/AggregateFunction.hpp" #include "query_optimizer/expressions/Alias.hpp" @@ -166,8 +167,8 @@ void ExecutionGenerator::generatePlan(const P::PhysicalPtr &physical_plan) { cost_model_.reset( new cost::StarSchemaSimpleCostModel(top_level_physical_plan_->shared_subplans())); - lip_filter_generator_.reset( - new LIPFilterGenerator(top_level_physical_plan_->lip_filter_configuration())); + simple_cost_model_.reset( + new cost::SimpleCostModel(top_level_physical_plan_->shared_subplans())); const P::LIPFilterConfigurationPtr &lip_filter_configuration = top_level_physical_plan_->lip_filter_configuration(); if (lip_filter_configuration != nullptr) { @@ -618,7 +619,7 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) { const CatalogRelation *referenced_stored_probe_relation = nullptr; const CatalogRelation *referenced_stored_build_relation = nullptr; - std::size_t build_cardinality = cost_model_->estimateCardinality(build_physical); + std::size_t build_cardinality = simple_cost_model_->estimateCardinality(build_physical); bool any_probe_attributes_nullable = false; bool any_build_attributes_nullable = false; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4bf1e62/query_optimizer/ExecutionGenerator.hpp -- diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp index 6acb764..8890296 100644 --- a/query_optimizer/ExecutionGenerator.hpp +++ b/query_optimizer/ExecutionGenerator.hpp @@ -420,6 +420,7 @@ class ExecutionGenerator { * @brief The cost model to use for creating the execution plan. */ std::unique_ptr cost_model_; + std::unique_ptr simple_cost_model_; physical::TopLevelPlanPtr top_level_physical_plan_; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c4bf1e62/query_optimizer/LIPFilterGenerator.cpp -- diff --git a/query_optimizer/LIPFilterGenerator.cpp b/query_optimizer/LIPFilterGenerator.cpp index 09ee12f..ef10400 100644 --- a/query_optimizer/LIPFilterGenerator.cpp +++ b/query_optimizer/LIPFilterGenerator.cpp @@ -139,7 +139,8 @@ void LIPFilterGenerator::deployBuilderInternal( lip_filter_entry_proto->mutable_attribute_type()->CopyFrom(attr_type.getProto()); std::cerr << "Build " << info.build_attribute->toString() - << " @" << builder_node << "\n"; + << " @" << builder_node + << " size = " << info.filter_cardinality << "\n"; } RelationalOperator *relop = http://git-wip-us.apache.org/repos/asf/in
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/lip-refactor 51f020ecc -> 0cca12890 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0cca1289 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0cca1289 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0cca1289 Branch: refs/heads/lip-refactor Commit: 0cca1289019c2e5aab623327a2268605af2dbf17 Parents: 51f020e Author: Jianqiao Zhu Authored: Tue Oct 4 23:22:51 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 4 23:22:51 2016 -0500 -- query_execution/QueryContext.cpp| 21 +--- query_optimizer/ExecutionGenerator.cpp | 5 +- query_optimizer/LIPFilterGenerator.cpp | 109 --- query_optimizer/LIPFilterGenerator.hpp | 14 ++- query_optimizer/PhysicalGenerator.cpp | 1 - .../physical/LIPFilterConfiguration.hpp | 18 +-- query_optimizer/rules/AttachLIPFilters.cpp | 4 +- storage/HashTableFactory.hpp| 5 +- utility/PlanVisualizer.cpp | 4 +- 9 files changed, 102 insertions(+), 79 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0cca1289/query_execution/QueryContext.cpp -- diff --git a/query_execution/QueryContext.cpp b/query_execution/QueryContext.cpp index 1a1b296..47408d4 100644 --- a/query_execution/QueryContext.cpp +++ b/query_execution/QueryContext.cpp @@ -68,10 +68,6 @@ QueryContext::QueryContext(const serialization::QueryContext &proto, storage_manager)); } -// for (int i = 0; i < proto.bloom_filters_size(); ++i) { -//bloom_filters_.emplace_back(new BloomFilter(proto.bloom_filters(i))); -// } - for (int i = 0; i < proto.generator_functions_size(); ++i) { const GeneratorFunctionHandle *func_handle = GeneratorFunctionFactory::Instance().reconstructFromProto(proto.generator_functions(i)); @@ -80,12 +76,11 @@ QueryContext::QueryContext(const serialization::QueryContext &proto, std::unique_ptr(func_handle)); } -// for (int i = 0; i < proto.join_hash_tables_size(); ++i) { -//join_hash_tables_.emplace_back( -// JoinHashTableFactory::CreateResizableFromProto(proto.join_hash_tables(i), -// storage_manager, -// bloom_filters_)); -// } + for (int i = 0; i < proto.join_hash_tables_size(); ++i) { +join_hash_tables_.emplace_back( + JoinHashTableFactory::CreateResizableFromProto(proto.join_hash_tables(i), + storage_manager)); + } for (int i = 0; i < proto.insert_destinations_size(); ++i) { const serialization::InsertDestination &insert_destination_proto = proto.insert_destinations(i); @@ -157,12 +152,6 @@ bool QueryContext::ProtoIsValid(const serialization::QueryContext &proto, } } -// for (int i = 0; i < proto.bloom_filters_size(); ++i) { -//if (!BloomFilter::ProtoIsValid(proto.bloom_filters(i))) { -// return false; -//} -// } - // Each GeneratorFunctionHandle object is serialized as a function name with // a list of arguments. Here checks that the arguments are valid TypedValue's. for (int i = 0; i < proto.generator_functions_size(); ++i) { http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0cca1289/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 7bfa949..0047818 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -176,6 +176,8 @@ void ExecutionGenerator::generatePlan(const P::PhysicalPtr &physical_plan) { } generatePlanInternal(top_level_physical_plan_->plan()); +lip_filter_generator_->deployLIPFilters(execution_plan_, query_context_proto_); + // Set the query result relation if the input plan exists in physical_to_execution_map_, // which indicates the plan is the result of a SELECT query. const std::unordered_map::const_iterator it = @@ -1412,7 +1414,8 @@ void ExecutionGenerator::convertAggregate( aggr_state_proto->mutable_predicate()->CopyFrom(predicate->getProto()); } - aggr_state_proto->set_estimated_num_entries(cost_model_->estimateCardinality(physical_plan)); +// aggr_state_proto->set_estimated_num_entries(cost_model_->estimateCardinality(physical_plan)); + aggr_state_proto->set_estimated_num_entries(64uL); const QueryPlan::DAG
incubator-quickstep git commit: updates
Repository: incubator-quickstep Updated Branches: refs/heads/estimate-num-distinct-values 7196bf187 -> 4625c135f updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/4625c135 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/4625c135 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/4625c135 Branch: refs/heads/estimate-num-distinct-values Commit: 4625c135f4c805dbeeeff7ad947b759202216746 Parents: 7196bf1 Author: Jianqiao Zhu Authored: Tue Oct 4 17:03:58 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 4 17:03:58 2016 -0500 -- query_optimizer/ExecutionGenerator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4625c135/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index fb44e83..9347c9c 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -1411,7 +1411,9 @@ void ExecutionGenerator::convertAggregate( aggr_state_proto->mutable_predicate()->CopyFrom(predicate->getProto()); } - aggr_state_proto->set_estimated_num_entries(cost_model_->estimateCardinality(physical_plan)); + const std::size_t estimated_num_groups = + cost_model_->estimateNumGroupsForAggregate(physical_plan); + aggr_state_proto->set_estimated_num_entries(std::max(16uL, estimated_num_groups)); const QueryPlan::DAGNodeIndex aggregation_operator_index = execution_plan_->addRelationalOperator(
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/estimate-num-distinct-values 19b68cd52 -> 7196bf187 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/7196bf18 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/7196bf18 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/7196bf18 Branch: refs/heads/estimate-num-distinct-values Commit: 7196bf187a27c0e339756a6ea2045c6405e11048 Parents: 19b68cd Author: Jianqiao Zhu Authored: Tue Oct 4 16:53:45 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 4 16:53:45 2016 -0500 -- query_optimizer/CMakeLists.txt | 2 +- query_optimizer/ExecutionGenerator.cpp | 4 ++-- query_optimizer/ExecutionGenerator.hpp | 1 - query_optimizer/cost_model/CMakeLists.txt| 1 + query_optimizer/cost_model/CostModel.hpp | 11 +++ query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp | 3 ++- 6 files changed, 17 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7196bf18/query_optimizer/CMakeLists.txt -- diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt index 32f7885..988ffd8 100644 --- a/query_optimizer/CMakeLists.txt +++ b/query_optimizer/CMakeLists.txt @@ -78,7 +78,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator quickstep_queryoptimizer_QueryHandle quickstep_queryoptimizer_QueryPlan quickstep_queryoptimizer_costmodel_CostModel - quickstep_queryoptimizer_costmodel_SimpleCostModel + quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel quickstep_queryoptimizer_expressions_AggregateFunction quickstep_queryoptimizer_expressions_Alias quickstep_queryoptimizer_expressions_AttributeReference http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7196bf18/query_optimizer/ExecutionGenerator.cpp -- diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp index 968314e..fb44e83 100644 --- a/query_optimizer/ExecutionGenerator.cpp +++ b/query_optimizer/ExecutionGenerator.cpp @@ -58,7 +58,7 @@ #include "query_optimizer/OptimizerContext.hpp" #include "query_optimizer/QueryHandle.hpp" #include "query_optimizer/QueryPlan.hpp" -#include "query_optimizer/cost_model/SimpleCostModel.hpp" +#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp" #include "query_optimizer/expressions/AggregateFunction.hpp" #include "query_optimizer/expressions/Alias.hpp" #include "query_optimizer/expressions/AttributeReference.hpp" @@ -167,7 +167,7 @@ void ExecutionGenerator::generatePlan(const P::PhysicalPtr &physical_plan) { << "The physical plan must be rooted by a TopLevelPlan"; cost_model_.reset( - new cost::SimpleCostModel(top_level_physical_plan_->shared_subplans())); + new cost::StarSchemaSimpleCostModel(top_level_physical_plan_->shared_subplans())); const CatalogRelation *result_relation = nullptr; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7196bf18/query_optimizer/ExecutionGenerator.hpp -- diff --git a/query_optimizer/ExecutionGenerator.hpp b/query_optimizer/ExecutionGenerator.hpp index 6017aa5..2aaf5ab 100644 --- a/query_optimizer/ExecutionGenerator.hpp +++ b/query_optimizer/ExecutionGenerator.hpp @@ -37,7 +37,6 @@ #include "query_optimizer/QueryHandle.hpp" #include "query_optimizer/QueryPlan.hpp" #include "query_optimizer/cost_model/CostModel.hpp" -#include "query_optimizer/cost_model/SimpleCostModel.hpp" #include "query_optimizer/expressions/ExprId.hpp" #include "query_optimizer/expressions/NamedExpression.hpp" #include "query_optimizer/expressions/Predicate.hpp" http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7196bf18/query_optimizer/cost_model/CMakeLists.txt -- diff --git a/query_optimizer/cost_model/CMakeLists.txt b/query_optimizer/cost_model/CMakeLists.txt index d1646fc..ba99de3 100644 --- a/query_optimizer/cost_model/CMakeLists.txt +++ b/query_optimizer/cost_model/CMakeLists.txt @@ -24,6 +24,7 @@ add_library(quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel # Link dependencies: target_link_libraries(quickstep_queryoptimizer_costmodel_CostModel + quickstep_queryoptimizer_physical_Ag
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/estimate-num-distinct-values a12ee48a9 -> 19b68cd52 Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/19b68cd5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/19b68cd5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/19b68cd5 Branch: refs/heads/estimate-num-distinct-values Commit: 19b68cd522bb8fb2b2b63d1198b62462a9d9a8d5 Parents: a12ee48 Author: Jianqiao Zhu Authored: Tue Oct 4 16:45:12 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 4 16:45:12 2016 -0500 -- .../cost_model/StarSchemaSimpleCostModel.cpp| 28 +--- .../cost_model/StarSchemaSimpleCostModel.hpp| 8 ++ 2 files changed, 27 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19b68cd5/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp -- diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp index 019c5ed..8d254fa 100644 --- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp +++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp @@ -149,18 +149,32 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForNestedLoopsJoin( std::size_t StarSchemaSimpleCostModel::estimateCardinalityForAggregate( const P::AggregatePtr &physical_plan) { - if (physical_plan->grouping_expressions().empty()) { -return 1; + double filter_selectivity = + estimateSelectivityForPredicate(physical_plan->filter_predicate(), physical_plan); + return static_cast( + estimateNumGroupsForAggregate(physical_plan) * filter_selectivity); +} + +std::size_t StarSchemaSimpleCostModel::estimateCardinalityForWindowAggregate( +const P::WindowAggregatePtr &physical_plan) { + return estimateCardinality(physical_plan->input()); +} + + +std::size_t StarSchemaSimpleCostModel::estimateNumGroupsForAggregate( +const physical::AggregatePtr &aggregate) { + if (aggregate->grouping_expressions().empty()) { +return 1uL; } - std::size_t estimated_child_cardinality = estimateCardinality(physical_plan->input()); + std::size_t estimated_child_cardinality = estimateCardinality(aggregate->input()); std::size_t estimated_num_groups = 1; std::size_t max_attr_num_distinct_values = 0; - for (const auto &expr : physical_plan->grouping_expressions()) { + for (const auto &expr : aggregate->grouping_expressions()) { E::AttributeReferencePtr attr; if (E::SomeAttributeReference::MatchesWithConditionalCast(expr, &attr)) { std::size_t attr_num_distinct_values = - estimateNumDistinctValues(attr->id(), physical_plan->input()); + estimateNumDistinctValues(attr->id(), aggregate->input()); estimated_num_groups *= std::max(1uL, attr_num_distinct_values); max_attr_num_distinct_values = std::max(max_attr_num_distinct_values, attr_num_distinct_values); @@ -175,10 +189,6 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForAggregate( return estimated_num_groups; } -std::size_t StarSchemaSimpleCostModel::estimateCardinalityForWindowAggregate( -const P::WindowAggregatePtr &physical_plan) { - return estimateCardinality(physical_plan->input()); -} std::size_t StarSchemaSimpleCostModel::estimateNumDistinctValues( const expressions::ExprId attribute_id, http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19b68cd5/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp -- diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp index d752065..662b118 100644 --- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp +++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp @@ -67,6 +67,14 @@ class StarSchemaSimpleCostModel : public CostModel { const physical::PhysicalPtr &physical_plan) override; /** + * @brief Estimate the number of groups in an aggregation. + * + * @param aggregate The physical plan of the aggregation. + * @return The estimated number of groups. + */ + std::size_t estimateNumGroupsForAggregate(const physical::AggregatePtr &aggregate); + + /** * @brief Estimate the number of distinct values of an attribute in a relation. * * @param attribute_id The expression id of the target attribute.
incubator-quickstep git commit: Updates
Repository: incubator-quickstep Updated Branches: refs/heads/estimate-num-distinct-values 2e689f126 -> 3b4ef8c9b Updates Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3b4ef8c9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3b4ef8c9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3b4ef8c9 Branch: refs/heads/estimate-num-distinct-values Commit: 3b4ef8c9ba7cab225da77e97b7af5f9777899310 Parents: 2e689f1 Author: Jianqiao Zhu Authored: Tue Oct 4 15:47:09 2016 -0500 Committer: Jianqiao Zhu Committed: Tue Oct 4 15:47:09 2016 -0500 -- .../cost_model/StarSchemaSimpleCostModel.cpp| 146 ++- .../cost_model/StarSchemaSimpleCostModel.hpp| 22 ++- query_optimizer/expressions/ExpressionUtil.hpp | 19 +++ .../StarSchemaHashJoinOrderOptimization.cpp | 1 + .../StarSchemaHashJoinOrderOptimization.hpp | 4 - 5 files changed, 109 insertions(+), 83 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3b4ef8c9/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp -- diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp index c45d4f2..122485a 100644 --- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp +++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp @@ -113,7 +113,9 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForTableReference( std::size_t StarSchemaSimpleCostModel::estimateCardinalityForSelection( const P::SelectionPtr &physical_plan) { - double selectivity = estimateSelectivity(physical_plan); + double selectivity = + estimateSelectivityForPredicate(physical_plan->filter_predicate(), + physical_plan); return static_cast(estimateCardinality(physical_plan->input()) * selectivity); } @@ -135,7 +137,7 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForHashJoin( std::size_t right_cardinality = estimateCardinality(physical_plan->right()); double left_selectivity = estimateSelectivity(physical_plan->left()); double right_selectivity = estimateSelectivity(physical_plan->right()); - return std::min(static_cast(left_cardinality * right_selectivity + 0.5), + return std::max(static_cast(left_cardinality * right_selectivity + 0.5), static_cast(right_cardinality * left_selectivity + 0.5)); } @@ -151,19 +153,25 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForAggregate( return 1; } + const std::size_t estimated_child_cardinality = estimateCardinality(physical_plan->input()); std::size_t estimated_num_groups = 1; + std::size_t max_attr_num_distinct_values = 0; for (const auto &expr : physical_plan->grouping_expressions()) { E::AttributeReferencePtr attr; if (E::SomeAttributeReference::MatchesWithConditionalCast(expr, &attr)) { - estimated_num_groups *= - std::max(1uL, estimateNumDistinctValues(attr, physical_plan->input())); + const std::size_t attr_num_distinct_values = + estimateNumDistinctValues(attr->id(), physical_plan->input()); + estimated_num_groups *= std::max(1uL, attr_num_distinct_values); + max_attr_num_distinct_values = + std::max(max_attr_num_distinct_values, attr_num_distinct_values); } else { // TODO(jianqiao): implement estimateNumDistinctValues() for expressions. - return estimateCardinality(physical_plan) /10; + estimated_num_groups *= 64uL; } } - estimated_num_groups = - std::min(estimated_num_groups, estimateCardinality(physical_plan)); + estimated_num_groups = std::max( + std::min(estimated_num_groups, estimated_child_cardinality / 10), + max_attr_num_distinct_values); return estimated_num_groups; } @@ -173,44 +181,23 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForWindowAggregate( } std::size_t StarSchemaSimpleCostModel::estimateNumDistinctValues( -const expressions::AttributeReferencePtr &attribute, +const expressions::ExprId attribute_id, const physical::PhysicalPtr &physical_plan) { - DCHECK(E::ContainsExpression(physical_plan->getOutputAttributes(), attribute)); + DCHECK(E::ContainsExprId(physical_plan->getOutputAttributes(), attribute_id)); P::TableReferencePtr table_reference; if (P::SomeTableReference::MatchesWithConditionalCast(physical_plan, &table_reference)) { -return getNumDistinctValues(attribute, table_reference); - } - - E::PredicatePtr filter_predicate = nullptr; - switch (physical_plan->getPhysicalType()) { -case P::PhysicalType::kSelection: - filter_p