You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ha...@apache.org on 2017/04/11 02:02:27 UTC

incubator-quickstep git commit: First commit for frontend-backend separation.

Repository: incubator-quickstep
Updated Branches:
  refs/heads/frontend-backend [created] 596cb529f


First commit for frontend-backend separation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/596cb529
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/596cb529
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/596cb529

Branch: refs/heads/frontend-backend
Commit: 596cb529f0928964d19e55f9da761cebbd08f4a7
Parents: 5b7b5cb
Author: Hakan Memisoglu <ha...@apache.org>
Authored: Mon Apr 10 21:02:00 2017 -0500
Committer: Hakan Memisoglu <ha...@apache.org>
Committed: Mon Apr 10 21:02:00 2017 -0500

----------------------------------------------------------------------
 query_optimizer/CMakeLists.txt      |  10 ++
 query_optimizer/Optimizer.cpp       |   5 +
 query_optimizer/QueryPlan.proto     |  44 +++++++
 relational_operators/CMakeLists.txt |   6 +
 relational_operators/Operator.proto | 198 +++++++++++++++++++++++++++++++
 5 files changed, 263 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/596cb529/query_optimizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt
index 9bdb753..abe59e2 100644
--- a/query_optimizer/CMakeLists.txt
+++ b/query_optimizer/CMakeLists.txt
@@ -24,6 +24,10 @@ configure_file (
   "${CMAKE_CURRENT_BINARY_DIR}/QueryOptimizerConfig.h"
 )
 
+QS_PROTOBUF_GENERATE_CPP(queryoptimizer_QueryPlan_proto_srcs
+                         queryoptimizer_QueryPlan_proto_hdrs
+                         QueryPlan.proto)
+
 set_gflags_lib_name ()
 
 add_subdirectory(cost_model)
@@ -48,6 +52,9 @@ add_library(quickstep_queryoptimizer_OptimizerTree ../empty_src.cpp OptimizerTre
 add_library(quickstep_queryoptimizer_PhysicalGenerator PhysicalGenerator.cpp PhysicalGenerator.hpp)
 add_library(quickstep_queryoptimizer_QueryHandle ../empty_src.cpp QueryHandle.hpp)
 add_library(quickstep_queryoptimizer_QueryPlan ../empty_src.cpp QueryPlan.hpp)
+add_library(quickstep_queryoptimizer_QueryPlan_proto
+            ${queryoptimizer_QueryPlan_proto_srcs}
+            ${queryoptimizer_QueryPlan_proto_hdrs})
 add_library(quickstep_queryoptimizer_QueryProcessor QueryProcessor.cpp QueryProcessor.hpp)
 add_library(quickstep_queryoptimizer_Validator ../empty_src.cpp Validator.hpp)
 
@@ -239,6 +246,9 @@ target_link_libraries(quickstep_queryoptimizer_QueryPlan
                       quickstep_relationaloperators_RelationalOperator
                       quickstep_utility_DAG
                       quickstep_utility_Macros)
+target_link_libraries(quickstep_queryoptimizer_QueryPlan_proto
+                      quickstep_relationaloperators_Operator_proto
+                      ${PROTOBUF_LIBRARY})
 target_link_libraries(quickstep_queryoptimizer_QueryProcessor
                       quickstep_catalog_Catalog
                       quickstep_catalog_Catalog_proto

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/596cb529/query_optimizer/Optimizer.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/Optimizer.cpp b/query_optimizer/Optimizer.cpp
index 1b91574..9ce517f 100644
--- a/query_optimizer/Optimizer.cpp
+++ b/query_optimizer/Optimizer.cpp
@@ -36,6 +36,11 @@ void Optimizer::generateQueryHandle(const ParseStatement &parse_statement,
   execution_generator.generatePlan(
       physical_generator.generatePlan(
           logical_generator.generatePlan(*catalog_database, parse_statement)));
+
+  // TODO(Hakan): Break at this point.
+  // execution_serializer.serializePlan(
+  //     physical_generator.generatePlan(
+  //         logical_generator.generatePlan(*catalog_database, parse_statement)));
 }
 
 }  // namespace optimizer

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/596cb529/query_optimizer/QueryPlan.proto
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryPlan.proto b/query_optimizer/QueryPlan.proto
new file mode 100644
index 0000000..a255b34
--- /dev/null
+++ b/query_optimizer/QueryPlan.proto
@@ -0,0 +1,44 @@
+syntax = "proto2";
+
+package quickstep.serialization;
+
+import "relational_operators/Operator.proto";
+
+message Vertex {
+    required OperatorType = 1;
+    oneof operator {
+        AggregationOperator aggregate_operator = 2;
+        BuildHashOperator build_hash_operator = 3;
+        BuildLIPFilterOperator build_lip_filter_operator = 4;
+        CreateIndexOperator create_index_operator = 5;
+        CreateTableOperator create_table_operator = 6;
+        DeleteOperator delete_operator = 7;
+        DestroyAggregationStateOperator destroy_aggregation_state_operator = 8;
+        DestroyHashOperator destroy_hash_operator = 9;
+        DropTableOperator drop_table_operator = 10;
+        FinalizeAggregationOperator finalize_aggregation_operator = 11;
+        HashJoinOperator hash_join_operator = 12;
+        InitializeAggregationOperator initialize_aggregation_operator = 13;
+        InsertOperator insert_operator = 14;
+        NestedLoopsJoinOperator nested_loops_join_operator = 15;
+        SampleOperator sample_operator = 16;
+        SaveBlocksOperator save_blocks_operator = 17;
+        SelectOperator select_operator = 18;
+        SortMergeRunOperator sort_merge_run_operator = 19;
+        SortRunGenerationOperator sort_run_generation_operator = 20;
+        TableGeneratorOperator table_generator_operator = 21;
+        TextScanOperator text_scan_operator = 22;
+        UpdateOperator update_operator = 23;
+        WindowAggregationOperator window_aggregation_operator = 24;
+    }
+}
+
+message Edges {
+    repeated uint64 outgoing_id = 1;
+    repeated bool payload = 2;
+}
+
+message DAG {
+    repeated Node = 1;
+    repeated Edges = 2;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/596cb529/relational_operators/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt
index 1693ec2..c25c17e 100644
--- a/relational_operators/CMakeLists.txt
+++ b/relational_operators/CMakeLists.txt
@@ -28,6 +28,9 @@ QS_PROTOBUF_GENERATE_CPP(relationaloperators_SortMergeRunOperator_proto_srcs
 QS_PROTOBUF_GENERATE_CPP(relationaloperators_WorkOrder_proto_srcs
                          relationaloperators_WorkOrder_proto_hdrs
                          WorkOrder.proto)
+QS_PROTOBUF_GENERATE_CPP(relationaloperators_Operator_proto_srcs
+                         relationaloperators_Operator_proto_hdrs
+                         Operator.proto)
 
 set_gflags_lib_name ()
 
@@ -57,6 +60,9 @@ add_library(quickstep_relationaloperators_InsertOperator InsertOperator.cpp Inse
 add_library(quickstep_relationaloperators_NestedLoopsJoinOperator
             NestedLoopsJoinOperator.cpp
             NestedLoopsJoinOperator.hpp)
+add_library(quickstep_relationaloperators_Operator_proto
+            ${relationaloperators_Operator_proto_srcs}
+            ${relationaloperators_Operator_proto_hdrs})
 add_library(quickstep_relationaloperators_RebuildWorkOrder ../empty_src.cpp RebuildWorkOrder.hpp)
 add_library(quickstep_relationaloperators_RelationalOperator ../empty_src.cpp RelationalOperator.hpp)
 add_library(quickstep_relationaloperators_SampleOperator SampleOperator.cpp SampleOperator.hpp)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/596cb529/relational_operators/Operator.proto
----------------------------------------------------------------------
diff --git a/relational_operators/Operator.proto b/relational_operators/Operator.proto
new file mode 100644
index 0000000..d96f183
--- /dev/null
+++ b/relational_operators/Operator.proto
@@ -0,0 +1,198 @@
+syntax = "proto2";
+
+package quickstep.serialization;
+
+enum OperatorType {
+    AGGREGATION = 1;
+    BUILD_AGGREGATION_EXISTENCE_MAP = 2;
+    BUILD_HASH = 3;
+    BUILD_LIP_FILTER = 4;
+    CREATE_INDEX = 5;  // Placeholder.
+    CREATE_TABLE = 6;  // Placeholder.
+    DELETE = 7;
+    DESTROY_AGGREGATION_STATE = 8;
+    DESTROY_HASH = 9;
+    DROP_TABLE = 10;
+    FINALIZE_AGGREGATION = 11;
+    HASH_JOIN = 12;
+    INITIALIZE_AGGREGATION = 13;
+    INSERT = 14;
+    NESTED_LOOP_JOIN = 15;
+    SAMPLE = 16;
+    SAVE_BLOCKS = 17;
+    SELECT = 18;
+    SORT_MERGE_RUN = 19;
+    SORT_RUN_GENERATION = 20;
+    TABLE_GENERATOR = 21;
+    TEXT_SCAN = 22;
+    UPDATE = 23;
+    WINDOW_AGGREGATION = 24;
+}
+
+message Operator {
+    required uint64 query_id = 1;
+    required OperatorType operator_type = 2;
+    extensions 16 to max;
+}
+
+message AggregationOperator {
+    extend Operator {
+        // We need relation_id to retrieve CatalogRelation object. (?)
+        required int32 relation_id = 16;
+        // Learn whether we can check this one from relation id. (?)
+        required bool relation_is_stored = 17;
+        // Aggregate state index in QueryContext
+        required uint32 aggr_state_index = 18;
+    }
+}
+
+message BuildHashOperator {
+    extend Operator {
+        required int32 relation_id = 16;
+        required bool relation_is_stored = 17;
+        repeated int32 join_key_attributes = 18;
+        required bool any_join_key_nullable = 19;
+        required uint64 num_partitions = 20;
+        required uint32 hash_table_index = 21;
+    }
+}
+
+message CreateTableOperator {
+    extend Operator {
+
+    }
+}
+
+message DeleteOperator {
+    extend Operator {
+
+    }
+}
+
+message DestroyHashOperator {
+    extend Operator {
+        required uint64 build_num_partitions = 16;
+        required uint32 hash_table_index = 17;
+    }
+}
+
+message DropTableOperator {
+    extend Operator {
+        required int32 relation_id = 16;
+        required int32 database_id = 17;
+        required bool only_drop_blocks = 18;
+    }
+}
+
+message FinalizeAggregationOperator {
+    extend Operator {
+        required uint32 aggr_state_index = 16;
+        required int32 output_relation_id = 17;
+        required uint32 output_destination_index = 18;
+    }
+}
+
+
+message HashJoinOperator {
+    enum JoinType {
+        LEFT_INNER = 1;
+        LEFT_SEMI = 2;
+        LEFT_ANTI = 3;
+        LEFT_OUTER = 4;
+    }
+
+    extend Operator {
+        required int32 build_relation_id = 16;
+        required int32 probe_relation_id = 17;
+        repeated int32 join_key_attributes = 18;
+        required bool any_join_key_attributes_nullable = 19;
+        required uint64 build_num_partitions = 20;
+        required int32 output_relation_id = 21;
+        required int32 output_destionation_index = 22;
+        required int32 hash_table_index = 23;
+        required int32 residiual_predicate_index = 24;
+        repeated bool is_selection_on_build = 25;
+        required JoinType join_type = 26;
+    }
+}
+
+message InitializeAggregationOperator {
+    extend Operator {
+        required uint32 aggr_state_index = 16;
+    }
+}
+
+message InsertOperator {
+    extend Operator {
+        required int32 output_relation_id = 16;
+        required uint32 output_destination_index = 17;
+        required uint32 tuple_index = 18;
+    }
+}
+
+message SampleOperator {
+    extend Operator {
+        required int32 input_relation_id = 16;
+        required int32 output_relation_id = 17;
+        required int32 output_destination_index = 18;
+        required bool input_relation_is_stored = 19;
+        required bool is_block_sample = 20;
+        required int32 percentage = 21;
+    }
+}
+
+message SaveBlocksOperator {
+    extend Operator {
+        required int32 relation_id = 16;
+        required bool force = 17;
+    }
+}
+
+message SelectOperator {
+    extend Operator {
+        required int32 input_relation_id = 16;
+        required int32 output_relation_id = 17;
+        required int32 output_destination_index = 18;
+        required int32 predicate_index = 19;
+        required int32 selection_index = 20;
+        required bool input_relation_is_stored = 21;
+        required uint64 num_partitions = 22;
+    }
+}
+
+message TableGeneratorOperator {
+    extend Operator {
+        required int32 output_relation_id = 16;
+        required int32 output_destination_index = 17;
+        required uint32 generator_function_index = 18;
+    }
+}
+
+message TextScanOperator {
+    extend Operator {
+        required string file_pattern = 16;
+        required int32 field_terminator = 17;
+        required bool process_escap_sequences = 18;
+        required int32 output_relation_id = 19;
+        required int32 output_destination_index = 20;
+    }
+}
+
+message UpdateOperator {
+    extend Operator {
+        required int32 relation_id = 16;
+        required int32 relocation_destionation_index = 17;
+        required int32 predicate_index = 18;
+        required uint32 update_group_index = 19;
+    }
+}
+
+message WindowAggregationOperator {
+    extend Operator {
+        required int32 input_relation_id = 16;
+        required int32 output_relation_id = 17;
+        required uint32 window_aggregation_state_index = 18;
+        required int32 output_destination_index = 19;
+    }
+}
+