You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ji...@apache.org on 2017/12/23 05:06:39 UTC

[1/7] incubator-quickstep git commit: Quickstep for GRAIL [Forced Update!]

Repository: incubator-quickstep
Updated Branches:
  refs/heads/trace 7e8b33f8a -> 0bb163a7e (forced update)


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index 142059d..96c649d 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -156,29 +156,30 @@ extern int quickstep_yydebug;
     TOKEN_SMA = 366,
     TOKEN_SMALLINT = 367,
     TOKEN_STDERR = 368,
-    TOKEN_STDOUT = 369,
-    TOKEN_SUBSTRING = 370,
-    TOKEN_TABLE = 371,
-    TOKEN_THEN = 372,
-    TOKEN_TIME = 373,
-    TOKEN_TIMESTAMP = 374,
-    TOKEN_TO = 375,
-    TOKEN_TRUE = 376,
-    TOKEN_TUPLESAMPLE = 377,
-    TOKEN_UNBOUNDED = 378,
-    TOKEN_UNIQUE = 379,
-    TOKEN_UPDATE = 380,
-    TOKEN_USING = 381,
-    TOKEN_VALUES = 382,
-    TOKEN_VARCHAR = 383,
-    TOKEN_WHEN = 384,
-    TOKEN_WHERE = 385,
-    TOKEN_WINDOW = 386,
-    TOKEN_WITH = 387,
-    TOKEN_YEAR = 388,
-    TOKEN_YEARMONTH = 389,
-    TOKEN_EOF = 390,
-    TOKEN_LEX_ERROR = 391
+    TOKEN_STDIN = 369,
+    TOKEN_STDOUT = 370,
+    TOKEN_SUBSTRING = 371,
+    TOKEN_TABLE = 372,
+    TOKEN_THEN = 373,
+    TOKEN_TIME = 374,
+    TOKEN_TIMESTAMP = 375,
+    TOKEN_TO = 376,
+    TOKEN_TRUE = 377,
+    TOKEN_TUPLESAMPLE = 378,
+    TOKEN_UNBOUNDED = 379,
+    TOKEN_UNIQUE = 380,
+    TOKEN_UPDATE = 381,
+    TOKEN_USING = 382,
+    TOKEN_VALUES = 383,
+    TOKEN_VARCHAR = 384,
+    TOKEN_WHEN = 385,
+    TOKEN_WHERE = 386,
+    TOKEN_WINDOW = 387,
+    TOKEN_WITH = 388,
+    TOKEN_YEAR = 389,
+    TOKEN_YEARMONTH = 390,
+    TOKEN_EOF = 391,
+    TOKEN_LEX_ERROR = 392
   };
 #endif
 
@@ -289,7 +290,7 @@ union YYSTYPE
 
   quickstep::ParsePriority *opt_priority_clause_;
 
-#line 293 "SqlParser_gen.hpp" /* yacc.c:1915  */
+#line 294 "SqlParser_gen.hpp" /* yacc.c:1915  */
 };
 
 typedef union YYSTYPE YYSTYPE;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 14d8949..3bca344 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -1212,10 +1212,13 @@ void ExecutionGenerator::convertCopyFrom(
         ->MergeFrom(output_relation->getPartitionScheme()->getProto());
   } else {
     insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
-
-    const vector<block_id> blocks(output_relation->getBlocksSnapshot());
-    for (const block_id block : blocks) {
-      insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
+    const StorageBlockLayout &layout = output_relation->getDefaultStorageBlockLayout();
+    const auto sub_block_type = layout.getDescription().tuple_store_description().sub_block_type();
+    if (sub_block_type != TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE) {
+      const vector<block_id> blocks(output_relation->getBlocksSnapshot());
+      for (const block_id block : blocks) {
+        insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
+      }
     }
   }
 
@@ -1880,7 +1883,6 @@ void ExecutionGenerator::convertAggregate(
       use_parallel_initialization = true;
       aggr_state_num_partitions = CalculateNumFinalizationPartitionsForCollisionFreeVectorTable(max_num_groups);
 
-      DCHECK(!group_by_aggrs_info.empty());
       CalculateCollisionFreeAggregationInfo(max_num_groups, group_by_aggrs_info,
                                             aggr_state_proto->mutable_collision_free_vector_info());
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
index e0e3dff..2c84fc5 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<const P::TableReference>(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 =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 0b6dc22..17198c2 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -1019,10 +1019,13 @@ L::LogicalPtr Resolver::resolveInsertSelection(
     if (destination_type.equals(selection_type)) {
       cast_expressions.emplace_back(selection_attributes[aid]);
     } else {
-      // TODO(jianqiao): implement Cast operation for non-numeric types.
+      // TODO(jianqiao): Implement Cast operation for non-numeric types.
+      // TODO(jianqiao): We temporarily disable the safely-coercible check for
+      // tricks that work around "argmin". Will switch it back once the "Cast"
+      // function is supported.
       if (destination_type.getSuperTypeID() == Type::SuperTypeID::kNumeric &&
           selection_type.getSuperTypeID() == Type::SuperTypeID::kNumeric &&
-          destination_type.isSafelyCoercibleFrom(selection_type)) {
+          destination_type.isCoercibleFrom(selection_type)) {
         // Add cast operation
         const E::AttributeReferencePtr attr = selection_attributes[aid];
         const E::ExpressionPtr cast_expr =
@@ -1038,7 +1041,7 @@ L::LogicalPtr Resolver::resolveInsertSelection(
             << insert_statement.relation_name()->value() << "."
             << destination_attributes[aid]->attribute_name() << " has type "
             << selection_attributes[aid]->getValueType().getName()
-            << ", which cannot be safely coerced to the column's type "
+            << ", which cannot be coerced to the column's type "
             << destination_attributes[aid]->getValueType().getName();
      }
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/relational_operators/TableExportOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TableExportOperator.cpp b/relational_operators/TableExportOperator.cpp
index f6a73bf..cb90d72 100644
--- a/relational_operators/TableExportOperator.cpp
+++ b/relational_operators/TableExportOperator.cpp
@@ -120,6 +120,8 @@ void TableExportOperator::receiveFeedbackMessage(
     } else if (lo_file_name == "$stderr") {
       file_ = stderr;
     } else {
+      DCHECK(!file_name_.empty());
+      DCHECK_EQ('@', file_name_.front());
       file_ = std::fopen(file_name_.substr(1).c_str(), "wb");
       // TODO(quickstep-team): Decent handling of exceptions at query runtime.
       if (file_ == nullptr) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index 66137d8..88b7214 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -57,6 +57,7 @@
 #include "types/containers/Tuple.hpp"
 #include "utility/BulkIoConfiguration.hpp"
 #include "utility/Glob.hpp"
+#include "utility/ScopedBuffer.hpp"
 
 #include "gflags/gflags.h"
 #include "glog/logging.h"
@@ -110,19 +111,36 @@ bool TextScanOperator::getAllWorkOrders(
     const tmb::client_id scheduler_client_id,
     tmb::MessageBus *bus) {
   DCHECK(query_context != nullptr);
+  DCHECK(!file_pattern_.empty());
 
-  const std::vector<std::string> files = utility::file::GlobExpand(file_pattern_);
-
-  CHECK_NE(files.size(), 0u)
-      << "No files matched '" << file_pattern_ << "'. Exiting.";
+  if (work_generated_) {
+    return true;
+  }
 
   InsertDestination *output_destination =
       query_context->getInsertDestination(output_destination_index_);
 
-  if (work_generated_) {
+  if (file_pattern_ == "$stdin") {
+    container->addNormalWorkOrder(
+        new TextScanWorkOrder(query_id_,
+                              file_pattern_,
+                              0,
+                              -1 /* text_segment_size */,
+                              options_->getDelimiter(),
+                              options_->escapeStrings(),
+                              output_destination),
+        op_index_);
+    work_generated_ = true;
     return true;
   }
 
+  DCHECK_EQ('@', file_pattern_.front());
+  const std::vector<std::string> files =
+      utility::file::GlobExpand(file_pattern_.substr(1));
+
+  CHECK_NE(files.size(), 0u)
+      << "No files matched '" << file_pattern_ << "'. Exiting.";
+
   for (const std::string &file : files) {
 #ifdef QUICKSTEP_HAVE_UNISTD
     // Check file permissions before trying to open it.
@@ -221,6 +239,12 @@ serialization::WorkOrder* TextScanOperator::createWorkOrderProto(
 }
 
 void TextScanWorkOrder::execute() {
+  DCHECK(!filename_.empty());
+  if (filename_ == "$stdin") {
+    executeInputStream();
+    return;
+  }
+
   const CatalogRelationSchema &relation = output_destination_->getRelation();
   std::vector<Tuple> tuples;
   bool is_faulty;
@@ -436,6 +460,76 @@ void TextScanWorkOrder::execute() {
   output_destination_->bulkInsertTuples(&column_vectors);
 }
 
+void TextScanWorkOrder::executeInputStream() {
+  std::string data;
+  const int len = std::ftell(stdin);
+  if (len >= 0) {
+    ScopedBuffer buffer(len, false);
+    std::rewind(stdin);
+    std::fread(buffer.get(), 1, len, stdin);
+    data = std::string(static_cast<char*>(buffer.get()), len);
+  } else {
+    std::unique_ptr<std::ostringstream> oss = std::make_unique<std::ostringstream>();
+    *oss << std::cin.rdbuf();
+    data = oss->str();
+    oss.reset();
+  }
+
+  if (data.back() != '\n') {
+    data.push_back('\n');
+  }
+
+  const CatalogRelationSchema &relation = output_destination_->getRelation();
+  std::vector<Tuple> tuples;
+  std::vector<TypedValue> row_tuple;
+  bool is_faulty;
+
+  const char *row_ptr = data.c_str();
+  const char *end_ptr = row_ptr + data.length();
+
+  while (row_ptr < end_ptr) {
+    if (*row_ptr == '\r' || *row_ptr == '\n') {
+      // Skip empty lines.
+      ++row_ptr;
+    } else {
+      row_tuple = parseRow(&row_ptr, relation, &is_faulty);
+      if (is_faulty) {
+        // Skip faulty rows
+        LOG(INFO) << "Faulty row found. Hence switching to next row.";
+      } else {
+        // Convert vector returned to tuple only when a valid row is encountered.
+        tuples.emplace_back(Tuple(std::move(row_tuple)));
+      }
+    }
+  }
+
+  // Store the tuples in a ColumnVectorsValueAccessor for bulk insert.
+  ColumnVectorsValueAccessor column_vectors;
+  std::size_t attr_id = 0;
+  for (const auto &attribute : relation) {
+    const Type &attr_type = attribute.getType();
+    if (attr_type.isVariableLength()) {
+      std::unique_ptr<IndirectColumnVector> column(
+          new IndirectColumnVector(attr_type, tuples.size()));
+      for (const auto &tuple : tuples) {
+        column->appendTypedValue(tuple.getAttributeValue(attr_id));
+      }
+      column_vectors.addColumn(column.release());
+    } else {
+      std::unique_ptr<NativeColumnVector> column(
+          new NativeColumnVector(attr_type, tuples.size()));
+      for (const auto &tuple : tuples) {
+        column->appendTypedValue(tuple.getAttributeValue(attr_id));
+      }
+      column_vectors.addColumn(column.release());
+    }
+    ++attr_id;
+  }
+
+  // Bulk insert the tuples.
+  output_destination_->bulkInsertTuples(&column_vectors);
+}
+
 std::vector<TypedValue> TextScanWorkOrder::parseRow(const char **row_ptr,
                                                     const CatalogRelationSchema &relation,
                                                     bool *is_faulty) const {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/relational_operators/TextScanOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.hpp b/relational_operators/TextScanOperator.hpp
index 01c559c..30462d7 100644
--- a/relational_operators/TextScanOperator.hpp
+++ b/relational_operators/TextScanOperator.hpp
@@ -225,6 +225,8 @@ class TextScanWorkOrder : public WorkOrder {
   void execute() override;
 
  private:
+  void executeInputStream();
+
   /**
    * @brief Extract a field string starting at \p *field_ptr. This method also
    *        expands escape sequences if \p process_escape_sequences_ is true.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/storage/AggregationOperationState.cpp
----------------------------------------------------------------------
diff --git a/storage/AggregationOperationState.cpp b/storage/AggregationOperationState.cpp
index 73f1983..9d58107 100644
--- a/storage/AggregationOperationState.cpp
+++ b/storage/AggregationOperationState.cpp
@@ -393,8 +393,7 @@ bool AggregationOperationState::ProtoIsValid(
       }
 
       const S::CollisionFreeVectorInfo &proto_collision_free_vector_info = proto.collision_free_vector_info();
-      if (!proto_collision_free_vector_info.IsInitialized() ||
-          proto_collision_free_vector_info.state_offsets_size() != group_by_expressions_size) {
+      if (!proto_collision_free_vector_info.IsInitialized()) {
         return false;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/utility/ExecutionDAGVisualizer.cpp
----------------------------------------------------------------------
diff --git a/utility/ExecutionDAGVisualizer.cpp b/utility/ExecutionDAGVisualizer.cpp
index 8059ef3..f009a72 100644
--- a/utility/ExecutionDAGVisualizer.cpp
+++ b/utility/ExecutionDAGVisualizer.cpp
@@ -234,9 +234,6 @@ void ExecutionDAGVisualizer::bindProfilingStats(
         std::max(time_end[relop_index], workorder_end_time);
     time_elapsed[relop_index] += (workorder_end_time - workorder_start_time);
 
-    if (workorders_count.find(relop_index) == workorders_count.end()) {
-      workorders_count[relop_index] = 0;
-    }
     ++workorders_count[relop_index];
     if (mean_time_per_workorder.find(relop_index) ==
         mean_time_per_workorder.end()) {
@@ -292,8 +289,7 @@ void ExecutionDAGVisualizer::bindProfilingStats(
       node_info.labels.emplace_back(
           "effective concurrency: " + FormatDigits(concurrency, 2));
 
-      DCHECK(workorders_count.find(node_index) != workorders_count.end());
-      const std::size_t workorders_count_for_node = workorders_count.at(node_index);
+      const std::size_t workorders_count_for_node = workorders_count[node_index];
       if (workorders_count_for_node > 0) {
         mean_time_per_workorder[node_index] =
             mean_time_per_workorder[node_index] /


[3/7] incubator-quickstep git commit: Quickstep for GRAIL

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/preprocessed/SqlLexer_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.cpp b/parser/preprocessed/SqlLexer_gen.cpp
index 4800cde..628b0ce 100644
--- a/parser/preprocessed/SqlLexer_gen.cpp
+++ b/parser/preprocessed/SqlLexer_gen.cpp
@@ -592,8 +592,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 164
-#define YY_END_OF_BUFFER 165
+#define YY_NUM_RULES 165
+#define YY_END_OF_BUFFER 166
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -601,72 +601,72 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_accept[589] =
+static const flex_int16_t yy_accept[591] =
     {   0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-        0,    0,  165,    2,    2,  163,  163,  162,  161,  163,
-      140,  136,  139,  136,  136,  159,  132,  129,  133,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  137,    4,    5,    5,    3,  155,
-      155,  152,  156,  156,  150,  157,  157,  154,    1,  162,
-      130,  160,  159,  159,  159,    0,  134,  131,  135,  158,
-      158,  158,  158,   10,  158,  158,  158,   22,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  138,
-
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,  158,   58,   67,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,   81,   82,  158,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  113,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,    4,    5,    3,  155,  151,  156,
-      149,  149,  141,  143,  144,  145,  146,  147,  148,  149,
-      157,  153,  160,  159,    0,  159,    6,    7,  158,    9,
-       11,  158,  158,   15,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,   33,  158,  158,  158,  158,
-
-      158,  158,  158,  158,   43,  158,  158,  158,  158,  158,
-      158,   50,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,   62,  158,   69,  158,  158,  158,  158,  158,  158,
-      158,   77,  158,   80,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,   98,  158,  158,
-      103,  104,  158,  158,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,  158,  141,
-      143,  142,  158,  158,  158,  158,  158,  158,  158,   20,
-       23,  158,  158,  158,   28,  158,  158,  158,   31,  158,
-      158,  158,   37,  158,  158,   41,   42,  158,  158,  158,
-
-      158,  158,  158,  158,   52,   53,  158,   55,  158,   57,
-      158,  158,  158,  158,   66,   68,   70,   71,   72,  158,
-       74,  158,  158,   78,  158,  158,   85,  158,  158,  158,
-      158,  158,   92,  158,   94,  158,  158,  158,  100,  158,
-      158,  158,  158,  158,  158,  158,  158,  110,  111,  114,
-      158,  158,  158,  158,  158,  158,  158,  158,  123,  158,
-      158,  126,  127,  141,  142,    8,  158,  158,  158,  158,
-      158,  158,  158,   25,  158,  158,  158,  158,  158,  158,
-      158,  158,  158,  158,  158,  158,  158,  158,   46,   47,
-       48,  158,  158,   54,  158,   59,   60,  158,  158,  158,
-
-       73,  158,   76,   79,   83,   84,  158,  158,  158,  158,
-      158,   93,  158,  158,   97,  158,  158,  158,  158,  158,
-      158,  158,  109,  158,  158,  158,  117,  158,  158,  120,
-      158,  158,  124,  158,  158,  158,  158,   14,  158,  158,
-      158,  158,  158,   26,  158,   29,  158,  158,  158,  158,
-      158,   36,  158,  158,   40,   44,  158,  158,  158,   56,
-       61,  158,  158,  158,   75,  158,  158,  158,  158,  158,
-      158,   96,  158,  101,  102,  158,  106,  107,  158,  158,
-      158,  158,  118,  119,  121,  158,  125,  158,  158,   13,
-      158,  158,  158,  158,  158,  158,   21,   30,  158,   34,
-
-       35,  158,  158,   45,  158,   51,   63,  158,  158,  158,
-       88,  158,   90,  158,  158,  158,  158,  158,  158,  158,
-      158,  122,  158,  158,  158,  158,  158,  158,  158,  158,
-       32,  158,   39,  158,  158,   65,  158,  158,   91,  158,
-      158,  105,  158,  158,  158,  158,  158,   12,  158,  158,
-      158,  158,   24,  158,  158,   49,   64,   86,   89,  158,
-      158,  108,  112,  158,  116,  128,   16,  158,  158,  158,
-       27,   38,   87,   95,  158,  158,  158,   18,   19,  158,
-      115,  158,  158,  158,   99,  158,   17,    0
+        0,    0,  166,    2,    2,  164,  164,  163,  162,  164,
+      141,  137,  140,  137,  137,  160,  133,  130,  134,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  138,    4,    5,    5,    3,  156,
+      156,  153,  157,  157,  151,  158,  158,  155,    1,  163,
+      131,  161,  160,  160,  160,    0,  135,  132,  136,  159,
+      159,  159,  159,   10,  159,  159,  159,   22,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  139,
+
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,  159,   58,   67,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,   81,   82,  159,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  114,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,    4,    5,    3,  156,  152,  157,
+      150,  150,  142,  144,  145,  146,  147,  148,  149,  150,
+      158,  154,  161,  160,    0,  160,    6,    7,  159,    9,
+       11,  159,  159,   15,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,   33,  159,  159,  159,  159,
+
+      159,  159,  159,  159,   43,  159,  159,  159,  159,  159,
+      159,   50,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,   62,  159,   69,  159,  159,  159,  159,  159,  159,
+      159,   77,  159,   80,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,   98,  159,  159,
+      103,  104,  159,  159,  159,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,  142,
+      144,  143,  159,  159,  159,  159,  159,  159,  159,   20,
+       23,  159,  159,  159,   28,  159,  159,  159,   31,  159,
+      159,  159,   37,  159,  159,   41,   42,  159,  159,  159,
+
+      159,  159,  159,  159,   52,   53,  159,   55,  159,   57,
+      159,  159,  159,  159,   66,   68,   70,   71,   72,  159,
+       74,  159,  159,   78,  159,  159,   85,  159,  159,  159,
+      159,  159,   92,  159,   94,  159,  159,  159,  100,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  111,  112,
+      115,  159,  159,  159,  159,  159,  159,  159,  159,  124,
+      159,  159,  127,  128,  142,  143,    8,  159,  159,  159,
+      159,  159,  159,  159,   25,  159,  159,  159,  159,  159,
+      159,  159,  159,  159,  159,  159,  159,  159,  159,   46,
+       47,   48,  159,  159,   54,  159,   59,   60,  159,  159,
+
+      159,   73,  159,   76,   79,   83,   84,  159,  159,  159,
+      159,  159,   93,  159,  159,   97,  159,  159,  159,  159,
+      159,  107,  159,  159,  110,  159,  159,  159,  118,  159,
+      159,  121,  159,  159,  125,  159,  159,  159,  159,   14,
+      159,  159,  159,  159,  159,   26,  159,   29,  159,  159,
+      159,  159,  159,   36,  159,  159,   40,   44,  159,  159,
+      159,   56,   61,  159,  159,  159,   75,  159,  159,  159,
+      159,  159,  159,   96,  159,  101,  102,  159,  106,  108,
+      159,  159,  159,  159,  119,  120,  122,  159,  126,  159,
+      159,   13,  159,  159,  159,  159,  159,  159,   21,   30,
+
+      159,   34,   35,  159,  159,   45,  159,   51,   63,  159,
+      159,  159,   88,  159,   90,  159,  159,  159,  159,  159,
+      159,  159,  159,  123,  159,  159,  159,  159,  159,  159,
+      159,  159,   32,  159,   39,  159,  159,   65,  159,  159,
+       91,  159,  159,  105,  159,  159,  159,  159,  159,   12,
+      159,  159,  159,  159,   24,  159,  159,   49,   64,   86,
+       89,  159,  159,  109,  113,  159,  117,  129,   16,  159,
+      159,  159,   27,   38,   87,   95,  159,  159,  159,   18,
+       19,  159,  116,  159,  159,  159,   99,  159,   17,    0
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -713,27 +713,27 @@ static const YY_CHAR yy_meta[72] =
         8
     } ;
 
-static const flex_int16_t yy_base[604] =
+static const flex_int16_t yy_base[606] =
     {   0,
         0,    1,   46,    0,  117,  162,    2,    3,  127,  128,
-        6,   10,  147, 1316, 1316,    0, 1316,   13, 1316,  130,
-     1316, 1316, 1316,  129,    6,  129,    4, 1316,   28,  124,
+        6,   10,  147, 1318, 1318,    0, 1318,   13, 1318,  130,
+     1318, 1318, 1318,  129,    6,  129,    4, 1318,   28,  124,
       159,  213,  165,  167,  263,   92,  158,  163,   96,  107,
       214,  160,  186,  219,  221,  155,  281,  274,  325,  257,
-      186,  209,    0,  219, 1316,   27,    4,   19,    0,    0,
+      186,  209,    0,  219, 1318,   27,    4,   19,    0,    0,
         0,   17,    0,    0,  389,    0,    0,    8,    0,   22,
-     1316,    0,  293,  325,  343,   18, 1316, 1316, 1316,    0,
+     1318,    0,  293,  325,  343,   18, 1318, 1318, 1318,    0,
       223,  265,  234,  242,  260,  292,  288,    0,  299,  330,
-      337,  324,  334,  324,  325,  380,  325,  331,  346, 1316,
+      337,  324,  334,  324,  325,  380,  325,  331,  346, 1318,
 
       348,  364,  378,  376,  371,  378,  382,  386,  390,  389,
       386,  385,  435,    0,  402,  389,  400,  435,  433,  431,
       433,  436,  431,  440,  447,    0,  452,  437,  453,  441,
       442,  456,  453,  449,  465,  457,  444,  494,  468,  495,
       500,  501,  499,  492,    0,  486,  492,  507,  506,  502,
-      500,  508,  501,  516,    0,   29,    0,    0, 1316,    0,
-     1316, 1316,   22,   24, 1316, 1316, 1316, 1316, 1316,    0,
-        0, 1316,    0,  524,   26,   28,    0,    0,  517,    0,
+      500,  508,  501,  516,    0,   29,    0,    0, 1318,    0,
+     1318, 1318,   22,   24, 1318, 1318, 1318, 1318, 1318,    0,
+        0, 1318,    0,  524,   26,   28,    0,    0,  517,    0,
       518,  501,  516,  504,  545,  525,  531,  552,  536,  542,
       537,  562,  544,  547,  561,    0,  558,  567,  564,  567,
 
@@ -742,126 +742,126 @@ static const flex_int16_t yy_base[604] =
       614,  615,  607,    0,  602,  603,  619,  616,  619,  606,
       608,    0,  617,    0,  626,  627,  615,  614,  634,  635,
       626,  620,  636,  633,  641,  659,  657,  652,  658,  671,
-        0,  665,  673,  660,  668,  668,  678,  679,  673,  671,
-      672,  689,  677,  671,  692,  683,  692,  690,  681,   30,
-      125,    0,  685,  690,  705,  708,  718,  718,  718,    0,
-      733,  724,  723,  717,    0,  718,  722,  736,  722,  730,
-      723,  725,  741,  738,  736,    0,    0,  729,  749,  748,
-
-      734,  735,  741,  748,    0,    0,  743,    0,  747,    0,
-      738,  750,  762,  774,    0,    0,    0,    0,    0,  767,
-        0,  769,  785,  775,  777,  778,    0,  789,  794,  795,
-      800,  784,    0,  798,    0,  786,  781,  786,    0,  803,
-      794,  808,  800,  795,  793,  795,  812,    0,  800,    0,
-      815,  805,  824,  818,  825,  840,  845,  843,    0,  847,
-      838,    0,  841,  131, 1316,    0,  852,  852,  838,  858,
-      844,  855,  859,    0,  850,  847,  861,  864,  856,  862,
-      871,  861,  870,  863,  864,  879,  877,  894,    0,    0,
-        0,  880,  898,    0,  901,    0,    0,  889,  905,  892,
-
-        0,  907,    0,    0,    0,    0,  895,  902,  913,  900,
-      910,    0,  915,  905,    0,  917,  919,  904,  918,  910,
-      909,  912,    0,  911,  914,  921,    0,  931,  937,    0,
-      935,  954,    0,  938,  948,  957,  953,    0,  946,  951,
-      969,  963,  953,    0,  973,    0,  970,  956,  964,  966,
-      959,    0,  976,  978,    0,    0,  962,  976,  972,    0,
-        0,  969,  983,  988,    0,  982,  973,  985,  975,  992,
-      999,    0, 1007,    0,    0, 1007,    0,    0, 1015, 1024,
-     1025, 1023,    0,    0,    0, 1010,    0, 1016, 1017,    0,
-     1023, 1018, 1021, 1023, 1031, 1028,    0,    0, 1033,    0,
-
-        0, 1030, 1020,    0, 1029,    0,    0, 1041, 1033, 1031,
-        0, 1033,    0, 1024, 1048, 1043, 1038, 1056, 1058, 1064,
-     1074,    0, 1062, 1076, 1070, 1069, 1070, 1068, 1071, 1076,
-        0, 1077,    0, 1085, 1073,    0, 1080, 1088,    0, 1091,
-     1084,    0, 1091, 1085, 1086, 1099, 1096,    0, 1098, 1102,
-     1097, 1105,    0, 1096, 1121,    0,    0, 1110,    0, 1116,
-     1128,    0,    0, 1128,    0,    0,    0, 1123, 1137, 1125,
-        0,    0,    0,    0, 1124, 1141, 1127,    0,    0, 1143,
-        0, 1140, 1132, 1146,    0, 1133,    0, 1316, 1198, 1208,
-     1218, 1228, 1238, 1242, 1245, 1251, 1261, 1271, 1281, 1291,
-
-     1301, 1306, 1308
+        0,  665,  673,  660,  668,  669,  679,  680,  674,  672,
+      674,  689,  678,  674,  693,  683,  694,  691,  685,   30,
+      125,    0,  686,  696,  717,  709,  724,  720,  721,    0,
+      734,  725,  724,  718,    0,  720,  723,  737,  723,  731,
+      724,  726,  742,  739,  737,    0,    0,  730,  752,  749,
+
+      735,  736,  742,  750,    0,    0,  745,    0,  748,    0,
+      744,  762,  763,  780,    0,    0,    0,    0,    0,  769,
+        0,  772,  785,  775,  777,  778,    0,  790,  795,  796,
+      801,  785,    0,  799,    0,  787,  782,  787,    0,  804,
+      797,  809,  801,  796,  801,  796,  799,  815,    0,  807,
+        0,  833,  818,  831,  826,  830,  844,  847,  845,    0,
+      849,  841,    0,  844,  131, 1318,    0,  854,  854,  840,
+      860,  846,  857,  861,    0,  852,  851,  865,  866,  858,
+      864,  874,  865,  873,  870,  882,  892,  884,  902,    0,
+        0,    0,  885,  902,    0,  903,    0,    0,  891,  907,
+
+      895,    0,  910,    0,    0,    0,    0,  896,  904,  915,
+      902,  912,    0,  917,  907,    0,  919,  923,  908,  920,
+      912,    0,  911,  915,    0,  915,  917,  928,    0,  949,
+      950,    0,  942,  962,    0,  943,  952,  959,  955,    0,
+      948,  954,  972,  965,  955,    0,  975,    0,  972,  958,
+      966,  968,  961,    0,  978,  982,    0,    0,  966,  978,
+      974,    0,    0,  971,  986,  992,    0,  985,  980, 1003,
+      988,  999, 1007,    0, 1012,    0,    0, 1011,    0,    0,
+     1017, 1026, 1027, 1026,    0,    0,    0, 1013,    0, 1018,
+     1019,    0, 1025, 1020, 1023, 1025, 1033, 1030,    0,    0,
+
+     1035,    0,    0, 1034, 1024,    0, 1031,    0,    0, 1043,
+     1035, 1034,    0, 1037,    0, 1027, 1055, 1061, 1051, 1063,
+     1066, 1069, 1078,    0, 1064, 1078, 1072, 1072, 1073, 1070,
+     1073, 1078,    0, 1079,    0, 1087, 1075,    0, 1082, 1090,
+        0, 1093, 1088,    0, 1095, 1087, 1088, 1101, 1099,    0,
+     1102, 1105, 1104, 1123,    0, 1109, 1128,    0,    0, 1118,
+        0, 1121, 1132,    0,    0, 1130,    0,    0,    0, 1125,
+     1139, 1128,    0,    0,    0,    0, 1127, 1143, 1129,    0,
+        0, 1145,    0, 1142, 1134, 1148,    0, 1135,    0, 1318,
+     1200, 1210, 1220, 1230, 1240, 1244, 1247, 1253, 1263, 1273,
+
+     1283, 1293, 1303, 1308, 1310
     } ;
 
-static const flex_int16_t yy_def[604] =
+static const flex_int16_t yy_def[606] =
     {   0,
-      589,  589,  588,    3,  590,  590,  591,  591,  592,  592,
-      593,  593,  588,  588,  588,  594,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  588,  588,  588,  588,  596,  597,
-      597,  588,  598,  598,  599,  600,  600,  588,  594,  588,
-      588,  601,  588,  588,  588,  588,  588,  588,  588,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  588,
-
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  588,  588,  596,  597,  588,  598,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  602,
-      600,  588,  601,  588,  588,  588,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  588,
-      588,  603,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  588,  588,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
-      595,  595,  595,  595,  595,  595,  595,    0,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-
-      588,  588,  588
+      591,  591,  590,    3,  592,  592,  593,  593,  594,  594,
+      595,  595,  590,  590,  590,  596,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  590,  590,  590,  590,  598,  599,
+      599,  590,  600,  600,  601,  602,  602,  590,  596,  590,
+      590,  603,  590,  590,  590,  590,  590,  590,  590,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  590,
+
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  590,  590,  598,  599,  590,  600,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  604,
+      602,  590,  603,  590,  590,  590,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  590,
+      590,  605,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  590,  590,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,  597,
+      597,  597,  597,  597,  597,  597,  597,  597,  597,    0,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+
+      590,  590,  590,  590,  590
     } ;
 
-static const flex_int16_t yy_nxt[1388] =
+static const flex_int16_t yy_nxt[1390] =
     {   0,
-      588,  155,   15,   15,   61,   61,  156,  156,   67,   62,
+      590,  155,   15,   15,   61,   61,  156,  156,   67,   62,
        62,   68,   67,  172,   70,   68,   70,   73,   73,   77,
        78,  156,  156,   70,  159,   70,  175,  175,  155,  176,
       176,  156,  156,  270,  271,  271,  271,  176,  176,  176,
-      176,  364,  271,   79,   16,   16,   17,   18,   19,   18,
+      176,  365,  271,   79,   16,   16,   17,   18,   19,   18,
        20,   21,   22,   23,   22,   24,   25,   26,   26,   17,
        27,   28,   29,   30,   31,   32,   33,   34,   35,   36,
        37,   38,   39,   40,   41,   42,   43,   44,   45,   46,
@@ -872,45 +872,45 @@ static const flex_int16_t yy_nxt[1388] =
        48,   49,   50,   51,   52,   53,   54,   17,   56,   57,
        58,   17,   17,   17,   17,   17,  110,  115,  116,   64,
        64,   17,   17,   17,   62,   62,  271,  271,   72,   74,
-       75,   75,  271,  271,   81,   71,  588,  588,  588,  588,
-       76,  588,   82,  588,   83,  110,  115,  116,  588,   84,
+       75,   75,  271,  271,   81,   71,  590,  590,  590,  590,
+       76,  590,   82,  590,   83,  110,  115,  116,  590,   84,
        17,   17,   17,   56,   57,   58,   17,   17,   17,   17,
        17,   65,   65,   81,  100,  111,   17,   17,   17,   76,
        85,   82,   95,   83,   86,  121,   96,   87,   84,  112,
-       97,  122,  133,  113,  588,  101,   98,  102,  114,   99,
+       97,  122,  133,  113,  590,  101,   98,  102,  114,   99,
 
-       88,  588,  588,  151,  111,   17,   17,  103,  588,   85,
-      588,   95,  588,   86,  121,   96,   87,  123,  112,   97,
+       88,  590,  590,  151,  111,   17,   17,  103,  590,   85,
+      590,   95,  590,   86,  121,   96,   87,  123,  112,   97,
       122,  133,  113,  124,  101,   98,  102,  114,   99,   88,
        89,  117,  151,  152,  153,  118,  103,   90,  130,  119,
       154,  125,  131,  177,   91,  120,  123,   92,   93,  126,
-       94,  588,  124,  127,  180,  132,  128,  129,  588,   89,
-      117,  181,  152,  153,  118,  588,   90,  130,  119,  154,
-      125,  131,  177,   91,  120,  588,   92,   93,  126,   94,
-      104,  588,  127,  180,  132,  128,  129,  148,  105,  149,
-      181,  106,  150,  178,  107,  138,  182,  108,  134,  588,
-
-      109,  179,  135,  139,   73,   73,  136,  588,  588,  104,
-      140,  141,  137,  588,   76,  183,  148,  105,  149,  185,
+       94,  590,  124,  127,  180,  132,  128,  129,  590,   89,
+      117,  181,  152,  153,  118,  590,   90,  130,  119,  154,
+      125,  131,  177,   91,  120,  590,   92,   93,  126,   94,
+      104,  590,  127,  180,  132,  128,  129,  148,  105,  149,
+      181,  106,  150,  178,  107,  138,  182,  108,  134,  590,
+
+      109,  179,  135,  139,   73,   73,  136,  590,  590,  104,
+      140,  141,  137,  590,   76,  183,  148,  105,  149,  185,
       106,  150,  178,  107,  138,  182,  108,  134,  184,  109,
-      179,  135,  139,  588,  186,  136,  174,  174,  588,  140,
+      179,  135,  139,  590,  186,  136,  174,  174,  590,  140,
       141,  137,  142,   76,  183,  192,   76,  187,  185,  143,
       144,  188,  193,   74,   75,   75,  145,  184,  194,  146,
       201,  195,  147,  186,   76,  189,  196,  190,  202,  191,
-      588,  142,  588,  588,  192,   76,  187,  203,  143,  144,
-      188,  193,  588,  204,  205,  145,  588,  194,  146,  201,
+      590,  142,  590,  590,  192,   76,  187,  203,  143,  144,
+      188,  193,  590,  204,  205,  145,  590,  194,  146,  201,
       195,  147,  162,   76,  189,  196,  190,  202,  191,  197,
 
       163,  164,  198,  206,  208,  209,  203,  165,  199,  210,
       211,  166,  204,  205,  207,  200,  212,  213,  214,  167,
-      215,  216,  218,  168,  217,  169,  588,  223,  197,  170,
+      215,  216,  218,  168,  217,  169,  590,  223,  197,  170,
       224,  198,  206,  208,  209,  225,  165,  199,  210,  211,
-      166,  588,  588,  207,  200,  212,  213,  214,  167,  215,
+      166,  590,  590,  207,  200,  212,  213,  214,  167,  215,
       216,  218,  168,  217,  169,  219,  223,  226,  170,  224,
       227,  229,  228,  230,  225,  220,  231,  232,  233,  234,
       221,  222,  235,  236,  237,  238,  239,  240,  242,  243,
       247,  241,  244,  248,  219,  252,  226,  245,  246,  227,
-      229,  228,  230,  588,  220,  231,  232,  233,  234,  221,
+      229,  228,  230,  590,  220,  231,  232,  233,  234,  221,
 
       222,  235,  236,  237,  238,  239,  240,  242,  243,  247,
       241,  244,  248,  249,  252,  253,  245,  246,  254,  255,
@@ -932,37 +932,37 @@ static const flex_int16_t yy_nxt[1388] =
       311,  335,  336,  312,  313,  314,  316,  317,  318,  319,
       320,  321,  322,  323,  324,  315,  325,  326,  327,  328,
       337,  338,  329,  330,  331,  333,  332,  339,  334,  341,
-      335,  336,  342,  343,  344,  346,  347,  340,  348,  349,
+      335,  336,  342,  343,  344,  347,  348,  340,  345,  349,
 
-      350,  351,  352,  353,  345,  354,  355,  356,  357,  337,
-      338,  358,  361,  359,  362,  363,  339,  360,  341,  366,
-      367,  342,  343,  344,  346,  347,  368,  348,  349,  350,
-      351,  352,  353,  345,  354,  355,  356,  357,  369,  370,
-      358,  361,  359,  362,  363,  371,  360,  372,  366,  367,
+      350,  351,  352,  353,  346,  354,  356,  355,  357,  337,
+      338,  358,  359,  360,  362,  363,  339,  361,  341,  364,
+      367,  342,  343,  344,  347,  348,  368,  345,  349,  350,
+      351,  352,  353,  346,  354,  356,  355,  357,  369,  370,
+      358,  359,  360,  362,  363,  371,  361,  372,  364,  367,
       373,  374,  375,  376,  377,  368,  378,  379,  380,  381,
       382,  383,  384,  385,  386,  387,  388,  369,  370,  389,
       390,  391,  392,  393,  371,  394,  372,  395,  396,  373,
       374,  375,  376,  377,  397,  378,  379,  380,  381,  382,
       383,  384,  385,  386,  387,  388,  398,  399,  389,  390,
 
-      391,  392,  393,  401,  394,  402,  395,  396,  400,  403,
-      404,  405,  406,  397,  407,  408,  409,  410,  411,  412,
+      391,  392,  393,  400,  394,  402,  395,  396,  403,  404,
+      405,  406,  407,  397,  401,  408,  409,  410,  411,  412,
       413,  414,  415,  416,  417,  398,  399,  418,  419,  420,
-      421,  422,  401,  423,  402,  424,  425,  400,  403,  404,
-      405,  406,  426,  407,  408,  409,  410,  411,  412,  413,
+      421,  422,  400,  423,  402,  424,  425,  403,  404,  405,
+      406,  407,  426,  401,  408,  409,  410,  411,  412,  413,
       414,  415,  416,  417,  427,  428,  418,  419,  420,  421,
       422,  429,  423,  430,  424,  425,  431,  432,  433,  434,
-      435,  426,  436,  437,  438,  439,  440,  442,  443,  441,
-      444,  445,  446,  427,  428,  447,  448,  449,  450,  451,
+      435,  426,  436,  437,  438,  439,  440,  441,  442,  444,
+      445,  443,  446,  427,  428,  447,  448,  449,  450,  451,
       429,  452,  430,  453,  454,  431,  432,  433,  434,  435,
 
-      455,  436,  437,  438,  439,  440,  442,  443,  441,  444,
-      445,  446,  456,  457,  447,  448,  449,  450,  451,  458,
-      452,  459,  453,  454,  460,  461,  462,  463,  465,  455,
-      464,  466,  467,  468,  469,  470,  471,  472,  473,  474,
+      455,  436,  437,  438,  439,  440,  441,  442,  444,  445,
+      443,  446,  456,  457,  447,  448,  449,  450,  451,  458,
+      452,  459,  453,  454,  460,  461,  462,  463,  464,  455,
+      465,  467,  468,  466,  469,  470,  471,  472,  473,  474,
       475,  456,  457,  476,  477,  478,  479,  480,  458,  481,
-      459,  482,  483,  460,  461,  462,  463,  465,  484,  464,
-      466,  467,  468,  469,  470,  471,  472,  473,  474,  475,
+      459,  482,  483,  460,  461,  462,  463,  464,  484,  465,
+      467,  468,  466,  469,  470,  471,  472,  473,  474,  475,
       485,  486,  476,  477,  478,  479,  480,  487,  481,  488,
       482,  483,  489,  490,  491,  492,  493,  484,  494,  495,
       496,  497,  498,  499,  500,  501,  502,  503,  504,  485,
@@ -985,33 +985,33 @@ static const flex_int16_t yy_nxt[1388] =
       559,  560,  561,  562,  572,  573,  563,  564,  565,  566,
       567,  574,  568,  575,  569,  570,  576,  577,  578,  579,
       580,  571,  581,  582,  583,  584,  585,  586,  587,  588,
-      588,  588,  588,  572,  573,  588,  588,  588,  588,  588,
-      574,  588,  575,  588,  588,  576,  577,  578,  579,  580,
-      588,  581,  582,  583,  584,  585,  586,  587,   14,   14,
-
-       14,   14,   14,   14,   14,   14,   14,   14,   59,   59,
-       59,   59,   59,   59,   59,   59,   59,   59,   60,   60,
-       60,   60,   60,   60,   60,   60,   60,   60,   63,   63,
-       63,   63,   63,   63,   63,   63,   63,   63,   66,   66,
-       66,   66,   66,   66,   66,   66,   66,   66,   69,   69,
-       80,   80,   80,  588,   80,  157,  157,  157,  157,  588,
-      157,  158,  158,  158,  588,  158,  158,  158,  158,  158,
-      158,  160,  160,  160,  588,  160,  160,  160,  160,  588,
-      160,  161,  161,  161,  161,  161,  161,  161,  161,  161,
-      161,  171,  171,  588,  171,  171,  171,  171,  171,  171,
-
-      171,  173,  588,  173,  173,  173,  173,  173,  173,  173,
-      173,  272,  272,  365,  365,   13,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588
+      589,  590,  590,  572,  573,  590,  590,  590,  590,  590,
+      574,  590,  575,  590,  590,  576,  577,  578,  579,  580,
+      590,  581,  582,  583,  584,  585,  586,  587,  588,  589,
+
+       14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
+       59,   59,   59,   59,   59,   59,   59,   59,   59,   59,
+       60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
+       63,   63,   63,   63,   63,   63,   63,   63,   63,   63,
+       66,   66,   66,   66,   66,   66,   66,   66,   66,   66,
+       69,   69,   80,   80,   80,  590,   80,  157,  157,  157,
+      157,  590,  157,  158,  158,  158,  590,  158,  158,  158,
+      158,  158,  158,  160,  160,  160,  590,  160,  160,  160,
+      160,  590,  160,  161,  161,  161,  161,  161,  161,  161,
+      161,  161,  161,  171,  171,  590,  171,  171,  171,  171,
+
+      171,  171,  171,  173,  590,  173,  173,  173,  173,  173,
+      173,  173,  173,  272,  272,  366,  366,   13,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590
     } ;
 
-static const flex_int16_t yy_chk[1388] =
+static const flex_int16_t yy_chk[1390] =
     {   0,
         0,  155,    1,    2,    7,    8,   57,   57,   11,    7,
         8,   11,   12,   68,   18,   12,   18,   25,   25,   27,
@@ -1028,7 +1028,7 @@ static const flex_int16_t yy_chk[1388] =
         3,    3,    3,    3,    3,    3,    3,    5,    5,    5,
         5,    5,    5,    5,    5,    5,   36,   39,   40,    9,
        10,    5,    5,    5,    9,   10,  271,  271,   24,   26,
-       26,   26,  364,  364,   30,   20,   13,    0,    0,    0,
+       26,   26,  365,  365,   30,   20,   13,    0,    0,    0,
        26,    0,   30,    0,   30,   36,   39,   40,    0,   30,
         5,    5,    6,    6,    6,    6,    6,    6,    6,    6,
         6,    9,   10,   30,   34,   37,    6,    6,    6,   26,
@@ -1088,87 +1088,87 @@ static const flex_int16_t yy_chk[1388] =
       219,  244,  245,  220,  221,  222,  223,  225,  226,  227,
       228,  229,  230,  231,  233,  222,  235,  236,  237,  238,
       246,  247,  239,  240,  241,  242,  241,  248,  243,  249,
-      244,  245,  250,  252,  253,  254,  255,  248,  256,  257,
-
-      258,  259,  260,  261,  253,  261,  262,  263,  264,  246,
-      247,  265,  267,  266,  268,  269,  248,  266,  249,  273,
-      274,  250,  252,  253,  254,  255,  275,  256,  257,  258,
-      259,  260,  261,  253,  261,  262,  263,  264,  276,  277,
-      265,  267,  266,  268,  269,  278,  266,  279,  273,  274,
-      281,  282,  283,  284,  286,  275,  287,  288,  289,  290,
-      291,  292,  293,  294,  295,  298,  299,  276,  277,  300,
-      301,  302,  303,  304,  278,  307,  279,  309,  311,  281,
-      282,  283,  284,  286,  312,  287,  288,  289,  290,  291,
-      292,  293,  294,  295,  298,  299,  313,  314,  300,  301,
-
-      302,  303,  304,  320,  307,  322,  309,  311,  314,  323,
-      324,  325,  326,  312,  328,  329,  330,  331,  332,  334,
-      336,  337,  338,  340,  341,  313,  314,  342,  343,  344,
-      345,  346,  320,  347,  322,  349,  351,  314,  323,  324,
-      325,  326,  352,  328,  329,  330,  331,  332,  334,  336,
-      337,  338,  340,  341,  353,  354,  342,  343,  344,  345,
-      346,  355,  347,  356,  349,  351,  357,  358,  360,  361,
-      363,  352,  367,  368,  369,  370,  371,  372,  373,  371,
-      375,  376,  377,  353,  354,  378,  379,  380,  381,  382,
-      355,  383,  356,  384,  385,  357,  358,  360,  361,  363,
-
-      386,  367,  368,  369,  370,  371,  372,  373,  371,  375,
-      376,  377,  387,  388,  378,  379,  380,  381,  382,  392,
-      383,  393,  384,  385,  395,  398,  399,  400,  402,  386,
-      400,  407,  408,  409,  410,  411,  413,  414,  416,  417,
-      418,  387,  388,  419,  420,  421,  422,  424,  392,  425,
-      393,  426,  428,  395,  398,  399,  400,  402,  429,  400,
-      407,  408,  409,  410,  411,  413,  414,  416,  417,  418,
-      431,  432,  419,  420,  421,  422,  424,  434,  425,  435,
-      426,  428,  436,  437,  439,  440,  441,  429,  442,  443,
-      445,  447,  448,  449,  450,  451,  453,  454,  457,  431,
-
-      432,  458,  459,  462,  463,  464,  434,  466,  435,  467,
-      468,  436,  437,  439,  440,  441,  469,  442,  443,  445,
-      447,  448,  449,  450,  451,  453,  454,  457,  470,  471,
-      458,  459,  462,  463,  464,  473,  466,  476,  467,  468,
-      479,  480,  481,  482,  486,  469,  488,  489,  491,  492,
-      493,  494,  495,  496,  499,  502,  503,  470,  471,  505,
-      508,  509,  510,  512,  473,  514,  476,  515,  516,  479,
-      480,  481,  482,  486,  517,  488,  489,  491,  492,  493,
-      494,  495,  496,  499,  502,  503,  518,  519,  505,  508,
-      509,  510,  512,  520,  514,  521,  515,  516,  523,  524,
-
-      525,  526,  527,  517,  528,  529,  530,  532,  534,  535,
-      537,  538,  540,  541,  543,  518,  519,  544,  545,  546,
-      547,  549,  520,  550,  521,  551,  552,  523,  524,  525,
-      526,  527,  554,  528,  529,  530,  532,  534,  535,  537,
-      538,  540,  541,  543,  555,  558,  544,  545,  546,  547,
-      549,  560,  550,  561,  551,  552,  564,  568,  569,  570,
-      575,  554,  576,  577,  580,  582,  583,  584,  586,    0,
-        0,    0,    0,  555,  558,    0,    0,    0,    0,    0,
-      560,    0,  561,    0,    0,  564,  568,  569,  570,  575,
-        0,  576,  577,  580,  582,  583,  584,  586,  589,  589,
-
-      589,  589,  589,  589,  589,  589,  589,  589,  590,  590,
-      590,  590,  590,  590,  590,  590,  590,  590,  591,  591,
-      591,  591,  591,  591,  591,  591,  591,  591,  592,  592,
-      592,  592,  592,  592,  592,  592,  592,  592,  593,  593,
-      593,  593,  593,  593,  593,  593,  593,  593,  594,  594,
-      595,  595,  595,    0,  595,  596,  596,  596,  596,    0,
-      596,  597,  597,  597,    0,  597,  597,  597,  597,  597,
-      597,  598,  598,  598,    0,  598,  598,  598,  598,    0,
-      598,  599,  599,  599,  599,  599,  599,  599,  599,  599,
-      599,  600,  600,    0,  600,  600,  600,  600,  600,  600,
-
-      600,  601,    0,  601,  601,  601,  601,  601,  601,  601,
-      601,  602,  602,  603,  603,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588,  588,  588,  588,
-      588,  588,  588,  588,  588,  588,  588
+      244,  245,  250,  252,  253,  254,  255,  248,  253,  256,
+
+      257,  258,  259,  260,  253,  261,  262,  261,  263,  246,
+      247,  264,  265,  266,  267,  268,  248,  266,  249,  269,
+      273,  250,  252,  253,  254,  255,  274,  253,  256,  257,
+      258,  259,  260,  253,  261,  262,  261,  263,  275,  276,
+      264,  265,  266,  267,  268,  277,  266,  278,  269,  273,
+      279,  281,  282,  283,  284,  274,  286,  287,  288,  289,
+      290,  291,  292,  293,  294,  295,  298,  275,  276,  299,
+      300,  301,  302,  303,  277,  304,  278,  307,  309,  279,
+      281,  282,  283,  284,  311,  286,  287,  288,  289,  290,
+      291,  292,  293,  294,  295,  298,  312,  313,  299,  300,
+
+      301,  302,  303,  314,  304,  320,  307,  309,  322,  323,
+      324,  325,  326,  311,  314,  328,  329,  330,  331,  332,
+      334,  336,  337,  338,  340,  312,  313,  341,  342,  343,
+      344,  345,  314,  346,  320,  347,  348,  322,  323,  324,
+      325,  326,  350,  314,  328,  329,  330,  331,  332,  334,
+      336,  337,  338,  340,  352,  353,  341,  342,  343,  344,
+      345,  354,  346,  355,  347,  348,  356,  357,  358,  359,
+      361,  350,  362,  364,  368,  369,  370,  371,  372,  373,
+      374,  372,  376,  352,  353,  377,  378,  379,  380,  381,
+      354,  382,  355,  383,  384,  356,  357,  358,  359,  361,
+
+      385,  362,  364,  368,  369,  370,  371,  372,  373,  374,
+      372,  376,  386,  387,  377,  378,  379,  380,  381,  388,
+      382,  389,  383,  384,  393,  394,  396,  399,  400,  385,
+      401,  403,  408,  401,  409,  410,  411,  412,  414,  415,
+      417,  386,  387,  418,  419,  420,  421,  423,  388,  424,
+      389,  426,  427,  393,  394,  396,  399,  400,  428,  401,
+      403,  408,  401,  409,  410,  411,  412,  414,  415,  417,
+      430,  431,  418,  419,  420,  421,  423,  433,  424,  434,
+      426,  427,  436,  437,  438,  439,  441,  428,  442,  443,
+      444,  445,  447,  449,  450,  451,  452,  453,  455,  430,
+
+      431,  456,  459,  460,  461,  464,  433,  465,  434,  466,
+      468,  436,  437,  438,  439,  441,  469,  442,  443,  444,
+      445,  447,  449,  450,  451,  452,  453,  455,  470,  471,
+      456,  459,  460,  461,  464,  472,  465,  473,  466,  468,
+      475,  478,  481,  482,  483,  469,  484,  488,  490,  491,
+      493,  494,  495,  496,  497,  498,  501,  470,  471,  504,
+      505,  507,  510,  511,  472,  512,  473,  514,  516,  475,
+      478,  481,  482,  483,  517,  484,  488,  490,  491,  493,
+      494,  495,  496,  497,  498,  501,  518,  519,  504,  505,
+      507,  510,  511,  520,  512,  521,  514,  516,  522,  523,
+
+      525,  526,  527,  517,  528,  529,  530,  531,  532,  534,
+      536,  537,  539,  540,  542,  518,  519,  543,  545,  546,
+      547,  548,  520,  549,  521,  551,  552,  522,  523,  525,
+      526,  527,  553,  528,  529,  530,  531,  532,  534,  536,
+      537,  539,  540,  542,  554,  556,  543,  545,  546,  547,
+      548,  557,  549,  560,  551,  552,  562,  563,  566,  570,
+      571,  553,  572,  577,  578,  579,  582,  584,  585,  586,
+      588,    0,    0,  554,  556,    0,    0,    0,    0,    0,
+      557,    0,  560,    0,    0,  562,  563,  566,  570,  571,
+        0,  572,  577,  578,  579,  582,  584,  585,  586,  588,
+
+      591,  591,  591,  591,  591,  591,  591,  591,  591,  591,
+      592,  592,  592,  592,  592,  592,  592,  592,  592,  592,
+      593,  593,  593,  593,  593,  593,  593,  593,  593,  593,
+      594,  594,  594,  594,  594,  594,  594,  594,  594,  594,
+      595,  595,  595,  595,  595,  595,  595,  595,  595,  595,
+      596,  596,  597,  597,  597,    0,  597,  598,  598,  598,
+      598,    0,  598,  599,  599,  599,    0,  599,  599,  599,
+      599,  599,  599,  600,  600,  600,    0,  600,  600,  600,
+      600,    0,  600,  601,  601,  601,  601,  601,  601,  601,
+      601,  601,  601,  602,  602,    0,  602,  602,  602,  602,
+
+      602,  602,  602,  603,    0,  603,  603,  603,  603,  603,
+      603,  603,  603,  604,  604,  605,  605,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590,  590,
+      590,  590,  590,  590,  590,  590,  590,  590,  590
     } ;
 
 /* Table of booleans, true if rule could match eol. */
-static const flex_int32_t yy_rule_can_match_eol[165] =
+static const flex_int32_t yy_rule_can_match_eol[166] =
     {   0,
 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
@@ -1177,8 +1177,8 @@ static const flex_int32_t yy_rule_can_match_eol[165] =
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 
-    0, 1, 0, 0, 0,     };
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 
+    0, 0, 1, 0, 0, 0,     };
 
 /* The intent behind this definition is that it'll catch
  * any uses of REJECT which flex missed.
@@ -1613,13 +1613,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 589 )
+				if ( yy_current_state >= 591 )
 					yy_c = yy_meta[yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			}
-		while ( yy_current_state != 588 );
+		while ( yy_current_state != 590 );
 		yy_cp = yyg->yy_last_accepting_cpos;
 		yy_current_state = yyg->yy_last_accepting_state;
 
@@ -2213,122 +2213,122 @@ return TOKEN_STDERR;
 case 107:
 YY_RULE_SETUP
 #line 273 "../SqlLexer.lpp"
-return TOKEN_STDOUT;
+return TOKEN_STDIN;
 	YY_BREAK
 case 108:
 YY_RULE_SETUP
 #line 274 "../SqlLexer.lpp"
-return TOKEN_SUBSTRING;
+return TOKEN_STDOUT;
 	YY_BREAK
 case 109:
 YY_RULE_SETUP
 #line 275 "../SqlLexer.lpp"
-return TOKEN_TABLE;
+return TOKEN_SUBSTRING;
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
 #line 276 "../SqlLexer.lpp"
-return TOKEN_THEN;
+return TOKEN_TABLE;
 	YY_BREAK
 case 111:
 YY_RULE_SETUP
 #line 277 "../SqlLexer.lpp"
-return TOKEN_TIME;
+return TOKEN_THEN;
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
 #line 278 "../SqlLexer.lpp"
-return TOKEN_TIMESTAMP;
+return TOKEN_TIME;
 	YY_BREAK
 case 113:
 YY_RULE_SETUP
 #line 279 "../SqlLexer.lpp"
-return TOKEN_TO;
+return TOKEN_TIMESTAMP;
 	YY_BREAK
 case 114:
 YY_RULE_SETUP
 #line 280 "../SqlLexer.lpp"
-return TOKEN_TRUE;
+return TOKEN_TO;
 	YY_BREAK
 case 115:
 YY_RULE_SETUP
 #line 281 "../SqlLexer.lpp"
-return TOKEN_TUPLESAMPLE;
+return TOKEN_TRUE;
 	YY_BREAK
 case 116:
 YY_RULE_SETUP
 #line 282 "../SqlLexer.lpp"
-return TOKEN_UNBOUNDED;
+return TOKEN_TUPLESAMPLE;
 	YY_BREAK
 case 117:
 YY_RULE_SETUP
 #line 283 "../SqlLexer.lpp"
-return TOKEN_UNION;
+return TOKEN_UNBOUNDED;
 	YY_BREAK
 case 118:
 YY_RULE_SETUP
 #line 284 "../SqlLexer.lpp"
-return TOKEN_UNIQUE;
+return TOKEN_UNION;
 	YY_BREAK
 case 119:
 YY_RULE_SETUP
 #line 285 "../SqlLexer.lpp"
-return TOKEN_UPDATE;
+return TOKEN_UNIQUE;
 	YY_BREAK
 case 120:
 YY_RULE_SETUP
 #line 286 "../SqlLexer.lpp"
-return TOKEN_USING;
+return TOKEN_UPDATE;
 	YY_BREAK
 case 121:
 YY_RULE_SETUP
 #line 287 "../SqlLexer.lpp"
-return TOKEN_VALUES;
+return TOKEN_USING;
 	YY_BREAK
 case 122:
 YY_RULE_SETUP
 #line 288 "../SqlLexer.lpp"
-return TOKEN_VARCHAR;
+return TOKEN_VALUES;
 	YY_BREAK
 case 123:
 YY_RULE_SETUP
 #line 289 "../SqlLexer.lpp"
-return TOKEN_WHEN;
+return TOKEN_VARCHAR;
 	YY_BREAK
 case 124:
 YY_RULE_SETUP
 #line 290 "../SqlLexer.lpp"
-return TOKEN_WHERE;
+return TOKEN_WHEN;
 	YY_BREAK
 case 125:
 YY_RULE_SETUP
 #line 291 "../SqlLexer.lpp"
-return TOKEN_WINDOW;
+return TOKEN_WHERE;
 	YY_BREAK
 case 126:
 YY_RULE_SETUP
 #line 292 "../SqlLexer.lpp"
-return TOKEN_WITH;
+return TOKEN_WINDOW;
 	YY_BREAK
 case 127:
 YY_RULE_SETUP
 #line 293 "../SqlLexer.lpp"
-return TOKEN_YEAR;
+return TOKEN_WITH;
 	YY_BREAK
 case 128:
 YY_RULE_SETUP
 #line 294 "../SqlLexer.lpp"
-return TOKEN_YEARMONTH;
+return TOKEN_YEAR;
 	YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 296 "../SqlLexer.lpp"
-return TOKEN_EQ;
+#line 295 "../SqlLexer.lpp"
+return TOKEN_YEARMONTH;
 	YY_BREAK
 case 130:
 YY_RULE_SETUP
 #line 297 "../SqlLexer.lpp"
-return TOKEN_NEQ;
+return TOKEN_EQ;
 	YY_BREAK
 case 131:
 YY_RULE_SETUP
@@ -2338,56 +2338,61 @@ return TOKEN_NEQ;
 case 132:
 YY_RULE_SETUP
 #line 299 "../SqlLexer.lpp"
-return TOKEN_LT;
+return TOKEN_NEQ;
 	YY_BREAK
 case 133:
 YY_RULE_SETUP
 #line 300 "../SqlLexer.lpp"
-return TOKEN_GT;
+return TOKEN_LT;
 	YY_BREAK
 case 134:
 YY_RULE_SETUP
 #line 301 "../SqlLexer.lpp"
-return TOKEN_LEQ;
+return TOKEN_GT;
 	YY_BREAK
 case 135:
 YY_RULE_SETUP
 #line 302 "../SqlLexer.lpp"
-return TOKEN_GEQ;
+return TOKEN_LEQ;
 	YY_BREAK
 case 136:
 YY_RULE_SETUP
-#line 304 "../SqlLexer.lpp"
-return yytext[0];
+#line 303 "../SqlLexer.lpp"
+return TOKEN_GEQ;
 	YY_BREAK
 case 137:
 YY_RULE_SETUP
 #line 305 "../SqlLexer.lpp"
 return yytext[0];
 	YY_BREAK
+case 138:
+YY_RULE_SETUP
+#line 306 "../SqlLexer.lpp"
+return yytext[0];
+	YY_BREAK
 /**
     * Quoted strings. Prefacing a string with an 'e' or 'E' causes escape
     * sequences to be processed (as in PostgreSQL).
     **/
-case 138:
+case 139:
 YY_RULE_SETUP
-#line 311 "../SqlLexer.lpp"
+#line 312 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED_ESCAPED);
   }
 	YY_BREAK
-case 139:
+case 140:
 YY_RULE_SETUP
-#line 316 "../SqlLexer.lpp"
+#line 317 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED);
   }
 	YY_BREAK
-case 140:
+case 141:
 YY_RULE_SETUP
-#line 321 "../SqlLexer.lpp"
+#line 322 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_DOUBLE_QUOTED);
@@ -2399,7 +2404,7 @@ YY_RULE_SETUP
 case YY_STATE_EOF(CONDITION_STRING_SINGLE_QUOTED):
 case YY_STATE_EOF(CONDITION_STRING_SINGLE_QUOTED_ESCAPED):
 case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED):
-#line 330 "../SqlLexer.lpp"
+#line 331 "../SqlLexer.lpp"
 {
     delete yylval->string_value_;
     BEGIN(INITIAL);
@@ -2410,9 +2415,9 @@ case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED):
 
 /* Process escape sequences. */
 
-case 141:
+case 142:
 YY_RULE_SETUP
-#line 340 "../SqlLexer.lpp"
+#line 341 "../SqlLexer.lpp"
 {
     /* Octal code */
     unsigned int code;
@@ -2426,9 +2431,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 142:
+case 143:
 YY_RULE_SETUP
-#line 352 "../SqlLexer.lpp"
+#line 353 "../SqlLexer.lpp"
 {
     /* Hexadecimal code */
     unsigned int code;
@@ -2436,9 +2441,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 143:
+case 144:
 YY_RULE_SETUP
-#line 358 "../SqlLexer.lpp"
+#line 359 "../SqlLexer.lpp"
 {
     /* A numeric escape sequence that isn't correctly specified. */
     delete yylval->string_value_;
@@ -2447,58 +2452,58 @@ YY_RULE_SETUP
     return TOKEN_LEX_ERROR;
   }
 	YY_BREAK
-case 144:
+case 145:
 YY_RULE_SETUP
-#line 365 "../SqlLexer.lpp"
+#line 366 "../SqlLexer.lpp"
 {
     /* Backspace */
     yylval->string_value_->push_back('\b');
   }
 	YY_BREAK
-case 145:
+case 146:
 YY_RULE_SETUP
-#line 369 "../SqlLexer.lpp"
+#line 370 "../SqlLexer.lpp"
 {
     /* Form-feed */
     yylval->string_value_->push_back('\f');
   }
 	YY_BREAK
-case 146:
+case 147:
 YY_RULE_SETUP
-#line 373 "../SqlLexer.lpp"
+#line 374 "../SqlLexer.lpp"
 {
     /* Newline */
     yylval->string_value_->push_back('\n');
   }
 	YY_BREAK
-case 147:
+case 148:
 YY_RULE_SETUP
-#line 377 "../SqlLexer.lpp"
+#line 378 "../SqlLexer.lpp"
 {
     /* Carriage-return */
     yylval->string_value_->push_back('\r');
   }
 	YY_BREAK
-case 148:
+case 149:
 YY_RULE_SETUP
-#line 381 "../SqlLexer.lpp"
+#line 382 "../SqlLexer.lpp"
 {
     /* Horizontal Tab */
     yylval->string_value_->push_back('\t');
   }
 	YY_BREAK
-case 149:
-/* rule 149 can match eol */
+case 150:
+/* rule 150 can match eol */
 YY_RULE_SETUP
-#line 385 "../SqlLexer.lpp"
+#line 386 "../SqlLexer.lpp"
 {
     /* Any other character (including actual newline or carriage return) */
     yylval->string_value_->push_back(yytext[1]);
   }
 	YY_BREAK
-case 150:
+case 151:
 YY_RULE_SETUP
-#line 389 "../SqlLexer.lpp"
+#line 390 "../SqlLexer.lpp"
 {
     /* This should only be encountered right before an EOF. */
     delete yylval->string_value_;
@@ -2509,17 +2514,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 151:
+case 152:
 YY_RULE_SETUP
-#line 399 "../SqlLexer.lpp"
+#line 400 "../SqlLexer.lpp"
 {
     /* Two quotes in a row become a single quote (this is specified by the SQL standard). */
     yylval->string_value_->push_back('\'');
   }
 	YY_BREAK
-case 152:
+case 153:
 YY_RULE_SETUP
-#line 403 "../SqlLexer.lpp"
+#line 404 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2528,17 +2533,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 153:
+case 154:
 YY_RULE_SETUP
-#line 411 "../SqlLexer.lpp"
+#line 412 "../SqlLexer.lpp"
 {
     /* Two quotes in a row become a single quote (this is specified by the SQL standard). */
     yylval->string_value_->push_back('"');
   }
 	YY_BREAK
-case 154:
+case 155:
 YY_RULE_SETUP
-#line 415 "../SqlLexer.lpp"
+#line 416 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2546,94 +2551,94 @@ YY_RULE_SETUP
   }
 	YY_BREAK
 
-case 155:
-/* rule 155 can match eol */
+case 156:
+/* rule 156 can match eol */
 YY_RULE_SETUP
-#line 422 "../SqlLexer.lpp"
+#line 423 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
-case 156:
-/* rule 156 can match eol */
+case 157:
+/* rule 157 can match eol */
 YY_RULE_SETUP
-#line 427 "../SqlLexer.lpp"
+#line 428 "../SqlLexer.lpp"
 {
   /* Scan up to a quote or escape sequence. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
-case 157:
-/* rule 157 can match eol */
+case 158:
+/* rule 158 can match eol */
 YY_RULE_SETUP
-#line 432 "../SqlLexer.lpp"
+#line 433 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
 
-case 158:
+case 159:
 YY_RULE_SETUP
-#line 438 "../SqlLexer.lpp"
+#line 439 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(
         yylloc->first_line, yylloc->first_column, std::string(yytext, yyleng));
     return TOKEN_NAME;
   }
 	YY_BREAK
-case 159:
+case 160:
 YY_RULE_SETUP
-#line 444 "../SqlLexer.lpp"
+#line 445 "../SqlLexer.lpp"
 {
     yylval->numeric_literal_value_ = new quickstep::NumericParseLiteralValue(
         yylloc->first_line, yylloc->first_column, yytext);
     return TOKEN_UNSIGNED_NUMVAL;
   }
 	YY_BREAK
-case 160:
+case 161:
 YY_RULE_SETUP
-#line 450 "../SqlLexer.lpp"
+#line 451 "../SqlLexer.lpp"
 /* comment */
 	YY_BREAK
-case 161:
-/* rule 161 can match eol */
+case 162:
+/* rule 162 can match eol */
 YY_RULE_SETUP
-#line 452 "../SqlLexer.lpp"
+#line 453 "../SqlLexer.lpp"
 { yycolumn = 0; }
 	YY_BREAK
-case 162:
+case 163:
 YY_RULE_SETUP
-#line 454 "../SqlLexer.lpp"
+#line 455 "../SqlLexer.lpp"
 ; /* ignore white space */
 	YY_BREAK
 /* CONDITION_SQL */
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(CONDITION_COMMAND):
 case YY_STATE_EOF(CONDITION_SQL):
-#line 458 "../SqlLexer.lpp"
+#line 459 "../SqlLexer.lpp"
 {
   /* All conditions except for mutli-state string extracting conditions. */
   BEGIN(INITIAL);
   return TOKEN_EOF;
 }
 	YY_BREAK
-case 163:
+case 164:
 YY_RULE_SETUP
-#line 464 "../SqlLexer.lpp"
+#line 465 "../SqlLexer.lpp"
 {
   BEGIN(INITIAL);
   quickstep_yyerror(NULL, yyscanner, NULL, "illegal character");
   return TOKEN_LEX_ERROR;
 }
 	YY_BREAK
-case 164:
+case 165:
 YY_RULE_SETUP
-#line 470 "../SqlLexer.lpp"
+#line 471 "../SqlLexer.lpp"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 2636 "SqlLexer_gen.cpp"
+#line 2641 "SqlLexer_gen.cpp"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -2931,7 +2936,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 589 )
+			if ( yy_current_state >= 591 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -2960,11 +2965,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 589 )
+		if ( yy_current_state >= 591 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 588);
+	yy_is_jam = (yy_current_state == 590);
 
 	(void)yyg;
 	return yy_is_jam ? 0 : yy_current_state;
@@ -3794,6 +3799,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 470 "../SqlLexer.lpp"
+#line 471 "../SqlLexer.lpp"
 
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/preprocessed/SqlLexer_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.hpp b/parser/preprocessed/SqlLexer_gen.hpp
index 5fafae5..479b72d 100644
--- a/parser/preprocessed/SqlLexer_gen.hpp
+++ b/parser/preprocessed/SqlLexer_gen.hpp
@@ -733,7 +733,7 @@ extern int yylex \
 #undef yyTABLES_NAME
 #endif
 
-#line 470 "../SqlLexer.lpp"
+#line 471 "../SqlLexer.lpp"
 
 
 #line 739 "SqlLexer_gen.hpp"


[2/7] incubator-quickstep git commit: Quickstep for GRAIL

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index 9b77875..aca4c87 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -299,29 +299,30 @@ extern int quickstep_yydebug;
     TOKEN_SMA = 366,
     TOKEN_SMALLINT = 367,
     TOKEN_STDERR = 368,
-    TOKEN_STDOUT = 369,
-    TOKEN_SUBSTRING = 370,
-    TOKEN_TABLE = 371,
-    TOKEN_THEN = 372,
-    TOKEN_TIME = 373,
-    TOKEN_TIMESTAMP = 374,
-    TOKEN_TO = 375,
-    TOKEN_TRUE = 376,
-    TOKEN_TUPLESAMPLE = 377,
-    TOKEN_UNBOUNDED = 378,
-    TOKEN_UNIQUE = 379,
-    TOKEN_UPDATE = 380,
-    TOKEN_USING = 381,
-    TOKEN_VALUES = 382,
-    TOKEN_VARCHAR = 383,
-    TOKEN_WHEN = 384,
-    TOKEN_WHERE = 385,
-    TOKEN_WINDOW = 386,
-    TOKEN_WITH = 387,
-    TOKEN_YEAR = 388,
-    TOKEN_YEARMONTH = 389,
-    TOKEN_EOF = 390,
-    TOKEN_LEX_ERROR = 391
+    TOKEN_STDIN = 369,
+    TOKEN_STDOUT = 370,
+    TOKEN_SUBSTRING = 371,
+    TOKEN_TABLE = 372,
+    TOKEN_THEN = 373,
+    TOKEN_TIME = 374,
+    TOKEN_TIMESTAMP = 375,
+    TOKEN_TO = 376,
+    TOKEN_TRUE = 377,
+    TOKEN_TUPLESAMPLE = 378,
+    TOKEN_UNBOUNDED = 379,
+    TOKEN_UNIQUE = 380,
+    TOKEN_UPDATE = 381,
+    TOKEN_USING = 382,
+    TOKEN_VALUES = 383,
+    TOKEN_VARCHAR = 384,
+    TOKEN_WHEN = 385,
+    TOKEN_WHERE = 386,
+    TOKEN_WINDOW = 387,
+    TOKEN_WITH = 388,
+    TOKEN_YEAR = 389,
+    TOKEN_YEARMONTH = 390,
+    TOKEN_EOF = 391,
+    TOKEN_LEX_ERROR = 392
   };
 #endif
 
@@ -432,7 +433,7 @@ union YYSTYPE
 
   quickstep::ParsePriority *opt_priority_clause_;
 
-#line 436 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 437 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
 
 typedef union YYSTYPE YYSTYPE;
@@ -467,7 +468,7 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 471 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 472 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -711,21 +712,21 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  50
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1327
+#define YYLAST   1320
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  148
+#define YYNTOKENS  149
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  111
+#define YYNNTS  112
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  300
+#define YYNRULES  302
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  555
+#define YYNSTATES  557
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   391
+#define YYMAXUTOK   392
 
 #define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -735,11 +736,11 @@ union yyalloc
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     143,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     144,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,   147,     2,     2,
-     144,   145,    23,    21,   146,    22,    27,    24,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,   142,
+       2,     2,     2,     2,     2,     2,     2,   148,     2,     2,
+     145,   146,    23,    21,   147,    22,    27,    24,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,   143,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -773,44 +774,44 @@ static const yytype_uint8 yytranslate[] =
      110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
      120,   121,   122,   123,   124,   125,   126,   127,   128,   129,
      130,   131,   132,   133,   134,   135,   136,   137,   138,   139,
-     140,   141
+     140,   141,   142
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   644,   644,   648,   652,   656,   660,   663,   670,   673,
-     676,   679,   682,   685,   688,   691,   694,   697,   703,   709,
-     716,   722,   729,   738,   743,   752,   757,   762,   766,   772,
-     777,   780,   783,   788,   791,   794,   797,   800,   803,   806,
-     809,   812,   815,   827,   830,   833,   851,   871,   874,   877,
-     882,   887,   893,   899,   908,   912,   918,   921,   926,   931,
-     936,   943,   950,   954,   960,   963,   968,   971,   976,   979,
-     984,   987,  1006,  1009,  1014,  1018,  1024,  1027,  1030,  1033,
-    1038,  1041,  1044,  1051,  1056,  1067,  1072,  1077,  1081,  1085,
-    1091,  1094,  1100,  1108,  1111,  1114,  1120,  1125,  1130,  1134,
-    1140,  1144,  1147,  1152,  1155,  1160,  1165,  1170,  1174,  1180,
-    1189,  1192,  1197,  1200,  1219,  1224,  1228,  1234,  1240,  1249,
-    1254,  1262,  1268,  1274,  1277,  1280,  1285,  1288,  1293,  1297,
-    1303,  1306,  1309,  1314,  1319,  1324,  1327,  1330,  1335,  1338,
-    1341,  1344,  1347,  1350,  1353,  1356,  1361,  1364,  1369,  1373,
-    1377,  1380,  1384,  1387,  1392,  1395,  1400,  1403,  1408,  1412,
-    1418,  1421,  1426,  1429,  1434,  1437,  1442,  1445,  1464,  1467,
-    1472,  1476,  1482,  1488,  1493,  1496,  1501,  1504,  1509,  1512,
-    1517,  1520,  1525,  1526,  1529,  1534,  1535,  1538,  1543,  1547,
-    1553,  1560,  1563,  1566,  1571,  1574,  1577,  1583,  1586,  1591,
-    1596,  1605,  1610,  1619,  1624,  1627,  1632,  1635,  1640,  1646,
-    1652,  1655,  1658,  1661,  1664,  1667,  1673,  1682,  1685,  1690,
-    1693,  1698,  1701,  1706,  1709,  1712,  1715,  1719,  1723,  1726,
-    1729,  1732,  1735,  1740,  1744,  1748,  1751,  1756,  1761,  1765,
-    1771,  1774,  1779,  1783,  1789,  1794,  1798,  1804,  1809,  1812,
-    1817,  1821,  1827,  1830,  1833,  1836,  1848,  1852,  1871,  1884,
-    1899,  1902,  1905,  1908,  1911,  1914,  1919,  1923,  1929,  1933,
-    1939,  1942,  1947,  1951,  1958,  1961,  1964,  1967,  1970,  1973,
-    1976,  1979,  1982,  1985,  1990,  2001,  2004,  2009,  2012,  2015,
-    2021,  2025,  2031,  2034,  2042,  2045,  2048,  2051,  2057,  2062,
-    2067
+       0,   646,   646,   650,   654,   658,   662,   665,   672,   675,
+     678,   681,   684,   687,   690,   693,   696,   699,   705,   711,
+     718,   724,   731,   740,   745,   754,   759,   764,   768,   774,
+     779,   782,   785,   790,   793,   796,   799,   802,   805,   808,
+     811,   814,   817,   829,   832,   835,   853,   873,   876,   879,
+     884,   889,   895,   901,   910,   914,   920,   923,   928,   933,
+     938,   945,   952,   956,   962,   965,   970,   973,   978,   981,
+     986,   989,  1008,  1011,  1016,  1020,  1026,  1029,  1032,  1035,
+    1040,  1043,  1046,  1053,  1058,  1069,  1074,  1079,  1083,  1087,
+    1093,  1096,  1102,  1110,  1113,  1116,  1122,  1127,  1132,  1136,
+    1142,  1146,  1151,  1155,  1158,  1163,  1166,  1171,  1176,  1181,
+    1185,  1191,  1200,  1203,  1208,  1211,  1230,  1235,  1239,  1245,
+    1251,  1260,  1265,  1273,  1279,  1285,  1288,  1291,  1296,  1299,
+    1304,  1308,  1314,  1317,  1320,  1325,  1330,  1335,  1338,  1341,
+    1346,  1349,  1352,  1355,  1358,  1361,  1364,  1367,  1372,  1375,
+    1380,  1384,  1388,  1391,  1395,  1398,  1403,  1406,  1411,  1414,
+    1419,  1423,  1429,  1432,  1437,  1440,  1445,  1448,  1453,  1456,
+    1475,  1478,  1483,  1487,  1493,  1499,  1504,  1507,  1512,  1515,
+    1520,  1523,  1528,  1531,  1536,  1537,  1540,  1545,  1546,  1549,
+    1554,  1558,  1564,  1571,  1574,  1577,  1582,  1585,  1588,  1594,
+    1597,  1602,  1607,  1616,  1621,  1630,  1635,  1638,  1643,  1646,
+    1651,  1657,  1663,  1666,  1669,  1672,  1675,  1678,  1684,  1693,
+    1696,  1701,  1704,  1709,  1712,  1717,  1720,  1723,  1726,  1730,
+    1734,  1737,  1740,  1743,  1746,  1751,  1755,  1759,  1762,  1767,
+    1772,  1776,  1782,  1785,  1790,  1794,  1800,  1805,  1809,  1815,
+    1820,  1823,  1828,  1832,  1838,  1841,  1844,  1847,  1859,  1863,
+    1882,  1895,  1910,  1913,  1916,  1919,  1922,  1925,  1930,  1934,
+    1940,  1944,  1950,  1953,  1958,  1962,  1969,  1972,  1975,  1978,
+    1981,  1984,  1987,  1990,  1993,  1996,  2001,  2012,  2015,  2020,
+    2023,  2026,  2032,  2036,  2042,  2045,  2053,  2056,  2059,  2062,
+    2068,  2073,  2078
 };
 #endif
 
@@ -846,11 +847,11 @@ static const char *const yytname[] =
   "TOKEN_RANGE", "TOKEN_REAL", "TOKEN_REFERENCES", "TOKEN_RIGHT",
   "TOKEN_ROW", "TOKEN_ROW_DELIMITER", "TOKEN_ROWS", "TOKEN_SECOND",
   "TOKEN_SELECT", "TOKEN_SET", "TOKEN_SMA", "TOKEN_SMALLINT",
-  "TOKEN_STDERR", "TOKEN_STDOUT", "TOKEN_SUBSTRING", "TOKEN_TABLE",
-  "TOKEN_THEN", "TOKEN_TIME", "TOKEN_TIMESTAMP", "TOKEN_TO", "TOKEN_TRUE",
-  "TOKEN_TUPLESAMPLE", "TOKEN_UNBOUNDED", "TOKEN_UNIQUE", "TOKEN_UPDATE",
-  "TOKEN_USING", "TOKEN_VALUES", "TOKEN_VARCHAR", "TOKEN_WHEN",
-  "TOKEN_WHERE", "TOKEN_WINDOW", "TOKEN_WITH", "TOKEN_YEAR",
+  "TOKEN_STDERR", "TOKEN_STDIN", "TOKEN_STDOUT", "TOKEN_SUBSTRING",
+  "TOKEN_TABLE", "TOKEN_THEN", "TOKEN_TIME", "TOKEN_TIMESTAMP", "TOKEN_TO",
+  "TOKEN_TRUE", "TOKEN_TUPLESAMPLE", "TOKEN_UNBOUNDED", "TOKEN_UNIQUE",
+  "TOKEN_UPDATE", "TOKEN_USING", "TOKEN_VALUES", "TOKEN_VARCHAR",
+  "TOKEN_WHEN", "TOKEN_WHERE", "TOKEN_WINDOW", "TOKEN_WITH", "TOKEN_YEAR",
   "TOKEN_YEARMONTH", "TOKEN_EOF", "TOKEN_LEX_ERROR", "';'", "'\\n'", "'('",
   "')'", "','", "'%'", "$accept", "start", "sql_statement",
   "quit_statement", "alter_table_statement", "create_table_statement",
@@ -863,10 +864,10 @@ static const char *const yytname[] =
   "key_value_list", "key_value", "key_string_value", "key_string_list",
   "key_integer_value", "key_bool_value", "index_type",
   "opt_index_properties", "insert_statement", "copy_statement",
-  "copy_to_target", "opt_copy_params", "update_statement",
-  "delete_statement", "assignment_list", "assignment_item",
-  "set_operation_statement", "opt_priority_clause", "with_clause",
-  "with_list", "with_list_element", "set_operation_union",
+  "copy_from_target", "copy_to_target", "opt_copy_params",
+  "update_statement", "delete_statement", "assignment_list",
+  "assignment_item", "set_operation_statement", "opt_priority_clause",
+  "with_clause", "with_list", "with_list_element", "set_operation_union",
   "set_operation_intersect", "select_query", "opt_all_distinct",
   "selection", "selection_item_commalist", "selection_item", "from_clause",
   "subquery_expression", "opt_sample_clause", "join_type",
@@ -912,16 +913,16 @@ static const yytype_uint16 yytoknum[] =
      360,   361,   362,   363,   364,   365,   366,   367,   368,   369,
      370,   371,   372,   373,   374,   375,   376,   377,   378,   379,
      380,   381,   382,   383,   384,   385,   386,   387,   388,   389,
-     390,   391,    59,    10,    40,    41,    44,    37
+     390,   391,   392,    59,    10,    40,    41,    44,    37
 };
 # endif
 
-#define YYPACT_NINF -410
+#define YYPACT_NINF -404
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-410)))
+  (!!((Yystate) == (-404)))
 
-#define YYTABLE_NINF -139
+#define YYTABLE_NINF -141
 
 #define yytable_value_is_error(Yytable_value) \
   0
@@ -930,62 +931,62 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     405,  -410,  -410,   -52,    43,   -13,    34,   -38,   116,  -410,
-      48,   231,   231,  -410,   115,   119,  -410,  -410,  -410,  -410,
-    -410,  -410,  -410,  -410,  -410,  -410,   166,    46,    49,  -410,
-     -36,   205,   231,  -410,  -410,    38,   132,   231,   231,   231,
-     231,   231,  -410,  -410,   652,    97,    72,  -410,   203,    95,
-    -410,  -410,  -410,   130,   175,    46,    48,   158,  -410,   130,
-    -410,  -410,  -410,    25,    61,   128,   270,   128,   184,   142,
-     149,  -410,   106,  -410,  -410,   309,   313,  -410,  -410,  -410,
-     743,   153,  -410,   218,  -410,  -410,   189,  -410,  -410,   331,
-    -410,  -410,  -410,  -410,   199,  -410,  -410,   207,   272,   837,
-     347,   305,   211,  -410,  -410,   328,    19,  -410,  -410,   262,
-    -410,  -410,  -410,  -410,  -410,  1019,     5,   231,   231,   220,
-     231,    38,   231,  -410,   130,   373,  -410,   148,   243,  -410,
-    -410,  -410,   244,  -410,   128,  -410,   231,   231,   561,  -410,
-    -410,   245,   231,  -410,  -410,  -410,   561,    52,    17,  -410,
-     400,  -410,   140,   140,  1110,   402,  -410,     1,    29,  -410,
-      20,   149,  1110,  -410,  -410,   231,  1110,  -410,  -410,  -410,
-    -410,  1110,    21,   313,  -410,   231,   323,   -64,  -410,   416,
-    -410,   130,  -410,   167,  -410,   128,   130,    49,  -410,   231,
-     152,   231,   231,   231,  -410,   269,  -410,   169,  1177,   928,
-     220,   470,   426,   433,  -410,  -410,   407,   428,  1188,   303,
-     173,    23,  1110,    64,  -410,  1110,  -410,   388,   306,  -410,
-    -410,  -410,  -410,  -410,  -410,   381,  -410,    66,   310,  -410,
-    -410,     8,   209,   215,  -410,   311,   209,     9,   385,  -410,
-    -410,    19,  -410,   360,  -410,  -410,   315,  1110,  -410,   301,
-     180,   231,  -410,  1110,  -410,   231,  -410,  -410,  -410,   320,
-     384,   386,   329,  -410,  -410,  -410,   196,  -410,  -410,  -410,
-    -410,  -410,    16,   231,   341,   152,   231,  -410,   174,  -410,
-    -410,     2,    81,   561,   561,   206,  -410,  -410,  -410,  -410,
-    -410,  -410,  -410,  -410,  1110,   334,  1110,    58,  -410,   210,
-     335,   349,  1110,    68,  -410,   420,   301,  -410,  -410,  1110,
-     476,  -410,   162,   231,  -410,  -410,   389,  -410,   390,   391,
-     406,    20,  -410,   486,   487,   209,   453,   421,   455,   353,
-     403,  -410,   223,  -410,  1110,  -410,   301,  -410,   561,   357,
-     358,   231,  -410,   231,  -410,  -410,  -410,  -410,  -410,  -410,
-    -410,   231,  -410,  -410,  -410,   225,   477,    86,  -410,   361,
-     366,  -410,   417,   364,  1188,  -410,   430,   231,  -410,  -410,
-     174,  -410,  -410,   433,  -410,  -410,  -410,  1110,   367,   284,
-     837,  -410,   301,   424,  -410,  -410,  1188,  1188,   374,   301,
-    1110,  -410,    33,   -16,  -410,  -410,  -410,  -410,  -410,    20,
-     215,   419,   422,  -410,  1110,   561,   429,  1110,  -410,   475,
-      18,  -410,   301,    31,   231,   231,   227,  -410,   233,  -410,
-     231,  -410,  -410,  -410,  -410,   382,   152,   489,   432,  -410,
-     561,  -410,  -410,   392,  -410,   289,   837,  -410,  1110,   238,
-    -410,  -410,   240,  1188,   301,  -410,   521,  -410,   437,  -410,
-    -410,   393,   426,   498,   456,   393,  1110,  -410,  -410,  -410,
-     522,  -410,   246,   252,  -410,  -410,  -410,   231,  -410,  -410,
-     399,   504,  -410,    32,   231,  1110,   254,   301,  -410,  -410,
-     257,   404,   561,  1110,   540,   412,   408,  -410,   274,    11,
-     442,  -410,   286,   231,   127,  -410,   410,   301,  -410,  -410,
-    -410,   426,   408,  -410,   231,  -410,   412,  -410,  1110,  -410,
-    -410,   460,   454,   447,   458,   549,   231,  -410,   290,  -410,
-    -410,   425,  -410,   528,  -410,  -410,    -6,  -410,  -410,  -410,
-    -410,    12,   431,  -410,   231,   434,  -410,  -410,   495,   462,
-     496,  -410,   231,   293,   360,  -410,  -410,  -410,   299,   473,
-     435,  -410,   563,  -410,  -410
+     613,  -404,  -404,   -19,    63,   -26,    96,    -6,    41,  -404,
+      67,    74,    74,  -404,   194,    81,  -404,  -404,  -404,  -404,
+    -404,  -404,  -404,  -404,  -404,  -404,   148,   -12,   174,  -404,
+     -40,   223,    74,  -404,  -404,    -3,   -17,    74,    74,    74,
+      74,    74,  -404,  -404,   679,   122,   103,  -404,   207,   120,
+    -404,  -404,  -404,   169,   210,   -12,    67,   212,  -404,   169,
+    -404,  -404,  -404,    39,    93,   160,    38,   160,   160,   219,
+     159,   182,  -404,   170,  -404,  -404,   313,   315,  -404,  -404,
+    -404,   758,   181,  -404,   253,  -404,  -404,   197,  -404,  -404,
+     341,  -404,  -404,  -404,  -404,   203,  -404,  -404,   221,   301,
+     837,   368,   320,   248,  -404,  -404,   339,    -8,  -404,  -404,
+     298,  -404,  -404,  -404,  -404,  -404,  1022,     5,    74,    74,
+     259,    74,    -3,    74,  -404,   169,   409,  -404,   186,   201,
+    -404,  -404,  -404,   281,  -404,  -404,  -404,  -404,  -404,    74,
+      74,   600,  -404,  -404,   289,    74,  -404,  -404,  -404,   600,
+      19,    66,  -404,   426,  -404,   155,   155,  1101,   428,  -404,
+     -25,    26,  -404,     8,   182,  1101,  -404,  -404,    74,  1101,
+    -404,  -404,  -404,  -404,  1101,    21,   315,  -404,    74,   363,
+     -68,  -404,   425,  -404,   169,  -404,   109,  -404,   160,   169,
+     174,  -404,    74,   136,    74,    74,    74,   292,  -404,   111,
+     200,   943,   259,   494,   430,   431,  -404,  -404,   552,   419,
+    1180,   294,   141,    15,  1101,   151,  -404,  1101,  -404,   381,
+     300,  -404,  -404,  -404,  -404,  -404,  -404,   376,  -404,   258,
+     302,  -404,  -404,    18,   326,   249,  -404,   304,   326,    58,
+     380,  -404,  -404,    -8,  -404,   350,  -404,  -404,   308,  1101,
+    -404,   288,   206,    74,  -404,  1101,  -404,    74,  -404,  -404,
+    -404,   311,   372,   373,   314,  -404,  -404,  -404,   209,  -404,
+    -404,  -404,  -404,  -404,    53,    74,   328,   136,    74,  -404,
+      97,  -404,  -404,    12,    72,   600,   600,   198,  -404,  -404,
+    -404,  -404,  -404,  -404,  -404,  -404,  1101,   316,  1101,    45,
+    -404,   216,   317,   330,  1101,    55,  -404,   402,   288,  -404,
+    -404,  1101,   459,  -404,   218,    74,  -404,  -404,   370,  -404,
+     371,   374,   385,     8,  -404,   466,   467,   326,   434,   403,
+     435,   333,   386,  -404,   229,  -404,  1101,  -404,   288,  -404,
+     600,   336,   338,    74,  -404,    74,  -404,  -404,  -404,  -404,
+    -404,  -404,  -404,    74,  -404,  -404,  -404,   231,   458,    71,
+    -404,   342,   348,  -404,   398,   347,  1180,  -404,   408,    74,
+    -404,  -404,    97,  -404,  -404,   431,  -404,  -404,  -404,  1101,
+     349,   291,   837,  -404,   288,   404,  -404,  -404,  1180,  1180,
+     360,   288,  1101,  -404,    29,    51,  -404,  -404,  -404,  -404,
+    -404,     8,   249,   394,   405,  -404,  1101,   600,   411,  1101,
+    -404,   468,   113,  -404,   288,    23,    74,    74,   233,  -404,
+     235,  -404,    74,  -404,  -404,  -404,  -404,   366,   136,   474,
+     414,  -404,   600,  -404,  -404,   375,  -404,   329,   837,  -404,
+    1101,   241,  -404,  -404,   243,  1180,   288,  -404,   510,  -404,
+     423,  -404,  -404,   377,   430,   477,   433,   377,  1101,  -404,
+    -404,  -404,   503,  -404,   247,   255,  -404,  -404,  -404,    74,
+    -404,  -404,   378,   483,  -404,    30,    74,  1101,   262,   288,
+    -404,  -404,   264,   382,   600,  1101,   519,   390,   384,  -404,
+     274,    14,   427,  -404,   273,    74,     0,  -404,   387,   288,
+    -404,  -404,  -404,   430,   384,  -404,    74,  -404,   390,  -404,
+    1101,  -404,  -404,   441,   437,   432,   439,   527,    74,  -404,
+     278,  -404,  -404,   399,  -404,   514,  -404,  -404,    47,  -404,
+    -404,  -404,  -404,    22,   406,  -404,    74,   407,  -404,  -404,
+     475,   440,   481,  -404,    74,   282,   350,  -404,  -404,  -404,
+     285,   454,   410,  -404,   548,  -404,  -404
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -993,96 +994,96 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint16 yydefact[] =
 {
-       0,     6,   300,     0,     0,     0,     0,     0,     0,    18,
-     123,     0,     0,     7,     0,     0,    15,     8,    10,    11,
-      13,    14,     9,    17,    12,    16,     0,   112,   119,   121,
-       0,   298,     0,   292,   293,     0,     0,     0,     0,     0,
-       0,     0,   124,   125,     0,     0,   114,   115,     0,   156,
-       1,     3,     2,     0,     0,   112,   123,     0,   110,     0,
-       5,     4,   299,     0,     0,   103,     0,   103,     0,     0,
-     197,    25,     0,   256,   253,     0,   284,   126,    40,    29,
-       0,     0,    30,    31,    34,    36,     0,    37,    39,     0,
-      41,   252,    35,    38,     0,    32,    33,     0,     0,     0,
-       0,     0,   127,   128,   232,   132,   218,   220,   222,   225,
-     228,   229,   230,   224,   223,     0,   270,     0,     0,     0,
-       0,     0,     0,   111,     0,     0,   120,     0,     0,   100,
-     102,   101,     0,    98,   103,    97,     0,     0,     0,   106,
-     198,     0,     0,    94,   254,   255,     0,     0,   248,   245,
-       0,    43,     0,   257,     0,     0,    44,     0,     0,   259,
-       0,   197,     0,   285,   286,     0,     0,   131,   288,   289,
-     287,     0,     0,     0,   221,     0,     0,   197,   108,     0,
-     116,     0,   117,     0,   290,   103,     0,   118,   113,     0,
-       0,     0,     0,     0,    96,    66,    27,     0,     0,     0,
-       0,     0,   199,   201,   203,   205,     0,   223,     0,    93,
-       0,     0,     0,   248,   242,     0,   246,     0,     0,   262,
-     263,   264,   261,   265,   260,     0,   258,     0,     0,   134,
-     231,     0,     0,   158,   147,   133,   152,   135,   160,   129,
-     130,   217,   219,   174,   226,   271,     0,     0,   233,   250,
-       0,     0,   105,     0,   157,     0,    99,    95,    19,     0,
-       0,     0,     0,    20,    21,    22,     0,    74,    76,    77,
-      78,    79,     0,     0,     0,    64,     0,    42,    56,   204,
-     212,     0,     0,     0,     0,     0,   274,   276,   277,   278,
-     279,   275,   280,   282,     0,     0,     0,     0,   266,     0,
-       0,     0,     0,     0,   243,     0,   249,   241,    45,     0,
-       0,    46,   138,     0,   148,   154,   144,   139,   140,   142,
-       0,     0,   151,     0,     0,   150,     0,   162,     0,     0,
-     176,   234,     0,   235,     0,   107,   109,   291,     0,     0,
-       0,     0,   104,     0,    81,    84,    82,   296,   297,   295,
-     294,     0,    80,    85,   272,     0,   270,     0,    63,    65,
-      68,    28,     0,     0,     0,    47,     0,     0,    49,    55,
-      57,    26,   211,   200,   202,   281,   283,     0,     0,     0,
-       0,   213,   210,     0,   209,   268,     0,     0,     0,   247,
-       0,   240,     0,     0,   153,   155,   145,   141,   143,     0,
-     159,     0,     0,   149,     0,     0,   164,     0,   227,     0,
-     178,   236,   251,     0,     0,     0,     0,    75,     0,    67,
-       0,    86,    87,    88,    89,    90,     0,     0,    70,    48,
-       0,    51,    50,     0,    54,     0,     0,   215,     0,     0,
-     208,   267,     0,     0,   244,   237,     0,   238,     0,   136,
-     137,   161,   163,     0,   166,   175,     0,   181,   180,   173,
-       0,    61,     0,     0,    58,    83,   273,     0,    24,    62,
-       0,     0,    23,     0,     0,     0,     0,   206,   214,   269,
-       0,     0,     0,     0,     0,   168,   177,   188,   191,     0,
-       0,    59,     0,     0,     0,    52,     0,   207,   216,    92,
-     239,   146,   165,   167,     0,   122,   169,   170,     0,   192,
-     193,   194,     0,     0,     0,     0,     0,    91,     0,    72,
-      73,     0,    53,     0,   171,   189,     0,   190,   182,   184,
-     183,     0,     0,    69,     0,     0,   195,   196,     0,     0,
-       0,   179,     0,     0,   174,   185,   187,   186,     0,     0,
-       0,    60,     0,   172,    71
+       0,     6,   302,     0,     0,     0,     0,     0,     0,    18,
+     125,     0,     0,     7,     0,     0,    15,     8,    10,    11,
+      13,    14,     9,    17,    12,    16,     0,   114,   121,   123,
+       0,   300,     0,   294,   295,     0,     0,     0,     0,     0,
+       0,     0,   126,   127,     0,     0,   116,   117,     0,   158,
+       1,     3,     2,     0,     0,   114,   125,     0,   112,     0,
+       5,     4,   301,     0,     0,   105,     0,   105,   105,     0,
+       0,   199,    25,     0,   258,   255,     0,   286,   128,    40,
+      29,     0,     0,    30,    31,    34,    36,     0,    37,    39,
+       0,    41,   254,    35,    38,     0,    32,    33,     0,     0,
+       0,     0,     0,   129,   130,   234,   134,   220,   222,   224,
+     227,   230,   231,   232,   226,   225,     0,   272,     0,     0,
+       0,     0,     0,     0,   113,     0,     0,   122,     0,     0,
+     102,   104,   103,     0,    98,   100,   101,    96,    97,     0,
+       0,     0,   108,   200,     0,     0,    94,   256,   257,     0,
+       0,   250,   247,     0,    43,     0,   259,     0,     0,    44,
+       0,     0,   261,     0,   199,     0,   287,   288,     0,     0,
+     133,   290,   291,   289,     0,     0,     0,   223,     0,     0,
+     199,   110,     0,   118,     0,   119,     0,   292,   105,     0,
+     120,   115,     0,     0,     0,     0,     0,    66,    27,     0,
+       0,     0,     0,     0,   201,   203,   205,   207,     0,   225,
+       0,    93,     0,     0,     0,   250,   244,     0,   248,     0,
+       0,   264,   265,   266,   263,   267,   262,     0,   260,     0,
+       0,   136,   233,     0,     0,   160,   149,   135,   154,   137,
+     162,   131,   132,   219,   221,   176,   228,   273,     0,     0,
+     235,   252,     0,     0,   107,     0,   159,     0,    99,    95,
+      19,     0,     0,     0,     0,    20,    21,    22,     0,    74,
+      76,    77,    78,    79,     0,     0,     0,    64,     0,    42,
+      56,   206,   214,     0,     0,     0,     0,     0,   276,   278,
+     279,   280,   281,   277,   282,   284,     0,     0,     0,     0,
+     268,     0,     0,     0,     0,     0,   245,     0,   251,   243,
+      45,     0,     0,    46,   140,     0,   150,   156,   146,   141,
+     142,   144,     0,     0,   153,     0,     0,   152,     0,   164,
+       0,     0,   178,   236,     0,   237,     0,   109,   111,   293,
+       0,     0,     0,     0,   106,     0,    81,    84,    82,   298,
+     299,   297,   296,     0,    80,    85,   274,     0,   272,     0,
+      63,    65,    68,    28,     0,     0,     0,    47,     0,     0,
+      49,    55,    57,    26,   213,   202,   204,   283,   285,     0,
+       0,     0,     0,   215,   212,     0,   211,   270,     0,     0,
+       0,   249,     0,   242,     0,     0,   155,   157,   147,   143,
+     145,     0,   161,     0,     0,   151,     0,     0,   166,     0,
+     229,     0,   180,   238,   253,     0,     0,     0,     0,    75,
+       0,    67,     0,    86,    87,    88,    89,    90,     0,     0,
+      70,    48,     0,    51,    50,     0,    54,     0,     0,   217,
+       0,     0,   210,   269,     0,     0,   246,   239,     0,   240,
+       0,   138,   139,   163,   165,     0,   168,   177,     0,   183,
+     182,   175,     0,    61,     0,     0,    58,    83,   275,     0,
+      24,    62,     0,     0,    23,     0,     0,     0,     0,   208,
+     216,   271,     0,     0,     0,     0,     0,   170,   179,   190,
+     193,     0,     0,    59,     0,     0,     0,    52,     0,   209,
+     218,    92,   241,   148,   167,   169,     0,   124,   171,   172,
+       0,   194,   195,   196,     0,     0,     0,     0,     0,    91,
+       0,    72,    73,     0,    53,     0,   173,   191,     0,   192,
+     184,   186,   185,     0,     0,    69,     0,     0,   197,   198,
+       0,     0,     0,   181,     0,     0,   176,   187,   189,   188,
+       0,     0,     0,    60,     0,   174,    71
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -410,  -410,  -410,  -410,  -410,  -410,  -410,  -410,  -148,  -410,
-     376,   216,  -410,  -410,  -264,  -410,  -410,  -410,  -410,  -410,
-    -410,  -409,   236,  -410,  -410,  -410,  -410,  -410,  -410,  -410,
-    -410,    85,    -3,  -410,  -410,  -410,   325,  -410,   526,  -410,
-    -410,   467,   217,   464,   -43,   533,  -410,  -410,   436,  -410,
-    -114,  -410,  -410,  -186,   192,  -184,    -9,  -410,  -410,  -410,
-    -410,  -410,  -410,  -410,    89,    55,  -410,  -410,  -410,  -410,
-    -410,  -410,   109,    92,  -410,  -410,    79,  -410,  -142,   318,
-     322,   409,   -42,   441,   439,   501,  -154,  -410,  -410,  -410,
-    -410,   398,  -410,   469,   413,  -232,  -195,   449,  -324,  -410,
-    -129,  -410,  -410,  -410,  -410,  -410,  -141,    -4,  -410,  -410,
-    -410
+    -404,  -404,  -404,  -404,  -404,  -404,  -404,  -404,  -150,  -404,
+     359,   188,  -404,  -404,  -267,  -404,  -404,  -404,  -404,  -404,
+    -404,  -403,   227,  -404,  -404,  -404,  -404,  -404,  -404,  -404,
+    -404,  -404,    17,    -5,  -404,  -404,  -404,   324,  -404,   523,
+    -404,  -404,   460,   238,   455,   -29,   525,  -404,  -404,   417,
+    -404,  -102,  -404,  -404,  -194,   183,  -193,    -9,  -404,  -404,
+    -404,  -404,  -404,  -404,  -404,    77,    42,  -404,  -404,  -404,
+    -404,  -404,  -404,   102,    79,  -404,  -404,    43,  -404,  -147,
+     305,   306,   392,   -35,   422,   420,   479,  -158,  -404,  -404,
+    -404,  -404,   383,  -404,   445,   388,  -236,  -204,   443,  -340,
+    -404,  -130,  -404,  -404,  -404,  -404,  -404,  -144,    -4,  -404,
+    -404,  -404
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-      -1,    14,    15,    16,    17,    18,    19,    20,   196,   197,
-     100,   369,   370,   371,   263,   359,   360,   274,   428,   472,
-     521,   266,   267,   268,   269,   270,   271,   425,   468,    21,
-      22,    65,   133,    23,    24,   177,   178,    25,    58,    26,
-      46,    47,   157,    28,    29,    44,   101,   102,   103,   161,
-     104,   325,   320,   233,   234,   314,   315,   235,   327,   406,
-     454,   485,   505,   506,   507,   329,   330,   410,   459,   460,
-     515,   541,   486,   487,   511,   527,   139,   140,   202,   203,
-     204,   205,   206,   106,   107,   108,   109,   110,   111,   112,
-     213,   214,   148,   149,   217,   250,   113,   225,   299,   209,
-     114,   355,   296,   115,   166,   171,   183,   116,   353,    30,
-      31
+      -1,    14,    15,    16,    17,    18,    19,    20,   198,   199,
+     101,   371,   372,   373,   265,   361,   362,   276,   430,   474,
+     523,   268,   269,   270,   271,   272,   273,   427,   470,    21,
+      22,    67,    65,   134,    23,    24,   180,   181,    25,    58,
+      26,    46,    47,   160,    28,    29,    44,   102,   103,   104,
+     164,   105,   327,   322,   235,   236,   316,   317,   237,   329,
+     408,   456,   487,   507,   508,   509,   331,   332,   412,   461,
+     462,   517,   543,   488,   489,   513,   529,   142,   143,   204,
+     205,   206,   207,   208,   107,   108,   109,   110,   111,   112,
+     113,   215,   216,   151,   152,   219,   252,   114,   227,   301,
+     211,   115,   357,   298,   116,   169,   174,   186,   117,   355,
+      30,    31
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -1090,276 +1091,276 @@ static const yytype_int16 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int16 yytable[] =
 {
-      36,   210,   105,    48,   211,   182,   236,    45,    49,   207,
-     283,   358,    33,   298,    34,   332,   126,   207,   512,   538,
-      33,   344,    34,   345,    33,    33,    34,    34,    63,   143,
-      56,   283,   175,    68,    69,    70,    71,    72,   147,   283,
-     283,   258,   168,   169,   346,   312,   232,    33,   323,    34,
-     163,   164,   322,   446,   163,   164,   127,   158,   492,   281,
-     536,   513,   539,   442,   135,    37,   129,    56,   383,    32,
-     207,   138,   207,   163,   164,    56,    42,   236,   215,    59,
-     537,   347,   251,    40,   518,   128,   280,   163,   164,   163,
-     164,   285,   286,   287,   288,   289,   290,   291,   292,   293,
-     294,   167,   163,   164,    60,    39,    43,    61,    38,    48,
-     348,   349,   227,   179,    49,    50,   184,   232,   186,   480,
-     105,    67,    10,   421,   457,   215,   422,   423,   361,   447,
-     458,   194,   195,   198,   249,   400,   324,   310,   184,   514,
-     540,   403,   350,   257,   354,   302,   229,   372,   439,   176,
-     384,   146,   231,   176,   207,   207,   237,    10,   295,   282,
-     351,   240,   469,    64,   231,   243,   170,   236,   244,   431,
-     303,   245,   451,   306,   230,   455,   461,   495,   445,   130,
-     131,   381,   256,    57,   362,   198,   212,   264,   265,   272,
-     390,   441,   298,   219,   189,   190,   413,   259,   212,    41,
-     416,   519,   424,    66,   476,   249,   185,   232,    62,   207,
-     418,   336,   117,    33,    53,    34,   220,    27,   118,   363,
-      10,    35,   260,   375,   376,   377,   230,   237,    49,   364,
-     221,   222,    49,   520,   316,    33,   119,    34,   141,   120,
-     238,   317,   313,    55,    10,   236,    54,   179,   298,   318,
-     142,   337,   379,   223,   382,   261,   252,    64,   122,    51,
-     389,    52,   125,   452,   437,   132,   365,   392,   352,   356,
-     121,   319,   198,   462,   463,   134,   207,   366,   224,   136,
-      10,   262,   367,   378,   138,   232,   137,   316,   473,   191,
-     192,   466,   412,   438,   317,   163,   164,   150,   475,  -138,
-     151,   207,   318,   368,   395,   163,   164,   394,   509,    49,
-     163,   164,   254,   255,   275,   276,   144,   237,   301,   255,
-     145,    49,   163,   164,   319,   333,   334,    33,    73,    34,
-      74,   510,    33,   152,    34,   435,   153,   184,   249,   272,
-     501,   342,   343,   154,    75,    76,   246,   184,   444,   163,
-     164,   155,   159,   207,   156,   385,   386,   162,    78,    79,
-     172,   165,   249,   433,   181,   249,    80,    81,   411,   334,
-     419,   420,   464,   255,    82,    83,   160,    84,   465,   255,
-     188,   247,    85,   478,   334,   479,   386,    86,   193,   208,
-      87,   490,   255,   543,   249,   237,   477,   491,   255,   498,
-     334,   548,   499,   386,    88,    89,     1,   218,     2,   228,
-     184,   184,    90,   273,   488,    91,   356,   285,   286,   287,
-     288,   289,   290,   291,   292,   293,   294,   253,   163,   164,
-      92,   517,   343,   497,   283,   533,   343,     3,   549,   255,
-      93,   488,   284,    94,   551,   255,    95,    96,   297,   300,
-     307,   308,   309,     4,     5,   311,    97,   321,   326,   328,
-     331,     6,    98,   272,   338,     7,   488,    99,   248,   339,
-     496,   340,   357,   341,    33,    73,    34,    74,   380,   387,
-     199,   388,   391,   393,   295,     8,   396,   397,   398,   272,
-     399,    75,    76,   401,   402,   404,   405,   407,   408,   409,
-     523,   414,   415,   427,   175,    78,    79,   426,   430,   429,
-       9,   436,   532,    80,    81,   432,   440,   456,   443,    10,
-     449,    82,    83,   450,    84,   453,   467,   470,   481,    85,
-     184,   471,   482,   200,    86,    11,   474,    87,   184,   334,
-     483,   489,    12,   493,   484,    13,   494,   503,   504,   500,
-     516,    88,    89,   526,   508,   522,   528,   529,   531,    90,
-     530,   535,    91,   545,   547,    33,    73,    34,    74,   534,
-     554,   199,   546,   552,   278,   542,   335,    92,   544,   417,
-     553,   123,    75,    76,    10,   180,   434,    93,   187,   124,
-      94,   448,   502,    95,    96,   524,    78,    79,   239,   550,
-     525,   373,   226,    97,    80,    81,   374,   241,   279,    98,
-     242,   304,    82,    83,   201,    84,   174,   216,     0,     0,
-      85,     0,     0,     0,   200,    86,   305,     0,    87,     0,
+      36,   212,   213,    48,    56,   238,   300,    45,    49,   106,
+     360,   209,    33,   334,    34,   171,   172,    56,   185,   209,
+     285,   514,    33,   285,    34,    33,    56,    34,    63,   540,
+     127,   285,   178,    69,    70,    71,    72,    73,   285,   314,
+     166,   167,   260,   135,   146,   324,   150,   166,   167,   444,
+     166,   167,    37,    68,    66,   385,   283,    33,   346,    34,
+     347,   234,   137,   138,   515,   161,   494,    33,   141,    34,
+     128,   209,   541,   209,   521,   238,   166,   167,    33,   253,
+      34,   348,   287,   288,   289,   290,   291,   292,   293,   294,
+     295,   296,   520,   166,   167,    42,    38,   325,   130,   129,
+     282,    60,   170,    32,    61,   482,   522,   364,   423,    64,
+      48,   424,   425,   538,   182,    49,    40,   187,   349,   189,
+     448,   231,   229,    64,    41,    43,    57,   217,   363,   402,
+     106,   234,    10,   539,   405,   197,   200,   386,   304,   188,
+     173,   187,   365,   516,   251,   356,   441,   350,   351,   297,
+     179,   542,   366,   233,   214,   209,   209,   136,   374,   239,
+     259,   471,   433,   233,   242,   238,   245,    39,   284,   463,
+     453,   246,   232,   457,   247,   447,   497,    10,   392,   305,
+     352,   261,   308,   258,   443,   300,   326,   426,   200,   367,
+     266,   267,   274,   415,    50,   383,    53,   449,   353,   418,
+     368,   149,   478,   179,    59,   369,   262,   240,   221,   420,
+     209,   131,   217,   132,   251,   377,   378,   379,   232,   459,
+     338,   234,    51,   254,    52,   460,    62,   370,    54,   239,
+      49,   222,   192,   193,    49,    79,    80,   118,    27,   263,
+     120,   300,    35,   238,    82,   223,   224,   194,   195,   182,
+     119,    83,    84,   339,    85,   256,   257,   277,   278,    86,
+     454,   381,    10,   384,    55,   121,   264,    88,   225,   391,
+     354,   358,   464,   465,   200,   380,   394,   209,   439,   166,
+     167,    89,   279,    10,    10,   475,   214,   303,   257,    91,
+     318,   122,   468,   123,   226,   166,   167,   319,   133,   234,
+     440,   414,   209,   144,   140,   320,   397,    93,   511,   166,
+     167,    49,   166,   167,   139,   145,   126,    94,   141,   239,
+     147,   318,   148,    49,    96,    97,   153,   321,   319,   312,
+      33,   512,    34,  -140,    98,   154,   320,   503,   477,   187,
+      99,   274,   155,    33,   437,    34,   156,   251,   157,   187,
+     166,   167,   335,   336,   209,   344,   345,   446,   321,   315,
+     166,   167,   387,   388,   396,   435,   158,    33,    74,    34,
+      75,   251,   168,   162,   251,   413,   336,   421,   422,   466,
+     257,   467,   257,   159,    76,    77,   248,   480,   336,   481,
+     388,   163,   545,   492,   257,   165,   175,   239,    79,    80,
+     550,   493,   257,   251,   184,   479,    81,    82,   500,   336,
+     501,   388,   187,   187,    83,    84,   191,    85,   358,   519,
+     345,   249,    86,   490,   535,   345,   196,    87,   551,   257,
+      88,   553,   257,   220,   210,   230,   255,   275,   285,   299,
+     286,   302,   499,   309,    89,    90,   310,   311,   313,   330,
+     490,   323,    91,   328,   333,    92,   340,   341,   342,   343,
+     359,   382,   389,   390,   393,   274,   395,   398,   399,   401,
+      93,   400,   498,   403,   404,   490,   406,   409,   407,   410,
+      94,   416,   411,   417,    95,   178,   429,    96,    97,   428,
+     431,   274,   432,   434,   438,   451,   442,    98,    33,    74,
+      34,    75,   525,    99,   201,   445,   452,   455,   100,   250,
+     458,   469,   472,   473,   534,    76,    77,   483,   484,   485,
+     476,   486,   491,   495,   336,   496,   505,   506,   502,    79,
+      80,   510,   187,   524,   528,   518,   533,    81,    82,   530,
+     187,   532,   531,   547,   536,    83,    84,   537,    85,   549,
+     548,   544,   546,    86,   554,   556,   555,   202,    87,   280,
+     436,    88,   287,   288,   289,   290,   291,   292,   293,   294,
+     295,   296,   419,   166,   167,    89,    90,   337,   124,   183,
+     190,   125,   241,    91,   450,   526,    92,   504,   552,   527,
+     375,   243,   376,   281,   244,   177,   218,     0,   306,   228,
+       0,    93,     0,   307,    33,    74,    34,    75,    10,     0,
+     201,    94,     0,     0,     1,    95,     2,     0,    96,    97,
+       0,    76,    77,     0,     0,     0,     0,     0,    98,   297,
+       0,     0,     0,     0,    99,    79,    80,     0,     0,   203,
+       0,     0,     0,    81,    82,     3,     0,     0,     0,     0,
+       0,    83,    84,     0,    85,     0,     0,     0,     0,    86,
+       0,     4,     5,   202,    87,     0,     0,    88,     0,     6,
+       0,     0,     0,     7,     0,     0,     0,     0,     0,     0,
+       0,    89,    90,    33,    74,    34,    75,     0,     0,    91,
+       0,     0,    92,     8,     0,     0,     0,     0,     0,     0,
+      76,    77,    78,     0,     0,     0,     0,    93,     0,     0,
+       0,     0,     0,     0,    79,    80,     0,    94,     9,     0,
+       0,    95,    81,    82,    96,    97,     0,    10,     0,     0,
+      83,    84,     0,    85,    98,     0,     0,     0,    86,     0,
+      99,     0,     0,    87,    11,   203,    88,     0,     0,     0,
+       0,    12,     0,     0,    13,     0,     0,     0,     0,     0,
+      89,    90,    33,    74,    34,    75,     0,     0,    91,     0,
+       0,    92,     0,     0,     0,     0,     0,     0,     0,    76,
+      77,     0,     0,     0,     0,     0,    93,     0,     0,     0,
+       0,     0,     0,    79,    80,     0,    94,     0,     0,     0,
+      95,    81,    82,    96,    97,     0,     0,     0,     0,    83,
+      84,     0,    85,    98,     0,     0,     0,    86,     0,    99,
+       0,     0,    87,     0,   100,    88,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    89,
+      90,    33,    74,    34,    75,     0,     0,    91,     0,     0,
+      92,     0,     0,     0,     0,     0,     0,     0,    76,    77,
+       0,     0,     0,     0,     0,    93,     0,     0,     0,     0,
+       0,     0,    79,    80,     0,    94,     0,     0,     0,    95,
+      81,    82,    96,    97,     0,     0,     0,     0,    83,    84,
+       0,    85,    98,   149,     0,     0,    86,     0,    99,     0,
+       0,    87,     0,   100,    88,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    89,    90,
+       0,     0,     0,     0,     0,     0,    91,     0,     0,    92,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    88,    89,     0,     0,     0,     0,     0,     0,
-      90,     0,     0,    91,     0,     0,    33,    73,    34,    74,
-       0,     0,     0,     0,     0,     0,     0,     0,    92,     0,
-       0,     0,     0,    75,    76,    77,     0,     0,    93,     0,
-       0,    94,     0,     0,    95,    96,     0,    78,    79,     0,
-       0,     0,     0,     0,    97,    80,    81,     0,     0,     0,
-      98,     0,     0,    82,    83,   201,    84,     0,     0,     0,
-       0,    85,     0,     0,     0,     0,    86,     0,     0,    87,
+       0,     0,     0,     0,    93,     0,     0,    33,    74,    34,
+      75,    10,     0,     0,    94,     0,     0,     0,    95,     0,
+       0,    96,    97,     0,    76,    77,     0,     0,     0,     0,
+       0,    98,     0,     0,     0,     0,     0,    99,    79,    80,
+       0,     0,   100,     0,     0,     0,    81,    82,     0,     0,
+       0,     0,     0,     0,    83,    84,     0,    85,     0,     0,
+       0,     0,    86,     0,     0,     0,   202,    87,     0,     0,
+      88,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,    89,    90,    33,    74,    34,    75,
+       0,     0,    91,     0,     0,    92,     0,     0,     0,     0,
+       0,     0,     0,    76,   176,     0,     0,     0,     0,     0,
+      93,     0,     0,     0,     0,     0,     0,    79,    80,     0,
+      94,     0,     0,     0,    95,    81,    82,    96,    97,     0,
+       0,     0,     0,    83,    84,     0,    85,    98,     0,     0,
+       0,    86,     0,    99,     0,     0,    87,     0,   203,    88,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,    88,    89,     0,     0,     0,     0,     0,
-       0,    90,     0,     0,    91,     0,     0,    33,    73,    34,
-      74,     0,     0,     0,     0,     0,     0,     0,     0,    92,
-       0,     0,     0,     0,    75,    76,     0,     0,     0,    93,
-       0,     0,    94,     0,     0,    95,    96,     0,    78,    79,
-       0,     0,     0,     0,     0,    97,    80,    81,     0,     0,
-       0,    98,     0,     0,    82,    83,    99,    84,     0,     0,
-       0,     0,    85,     0,     0,     0,     0,    86,     0,     0,
-      87,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    88,    89,     0,     0,     0,     0,
-       0,     0,    90,     0,     0,    91,     0,     0,     0,     0,
-       0,    33,    73,    34,    74,     0,     0,     0,     0,     0,
-      92,     0,     0,     0,     0,     0,     0,     0,    75,    76,
-      93,     0,     0,    94,     0,     0,    95,    96,     0,     0,
-       0,     0,    78,    79,     0,     0,    97,   146,     0,     0,
-      80,    81,    98,     0,     0,     0,     0,    99,    82,    83,
-       0,    84,     0,     0,     0,     0,    85,     0,     0,     0,
-       0,    86,     0,     0,    87,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    88,    89,
-       0,     0,     0,     0,     0,     0,    90,     0,     0,    91,
-       0,     0,    33,    73,    34,    74,     0,     0,     0,     0,
-       0,     0,     0,     0,    92,     0,     0,     0,     0,    75,
-      76,    10,     0,     0,    93,     0,     0,    94,     0,     0,
-      95,    96,     0,    78,    79,     0,     0,     0,     0,     0,
-      97,    80,    81,     0,     0,     0,    98,     0,     0,    82,
-      83,    99,    84,     0,     0,     0,     0,    85,     0,     0,
-       0,   200,    86,     0,     0,    87,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    88,
-      89,     0,     0,     0,     0,     0,     0,    90,     0,     0,
-      91,     0,     0,    33,    73,    34,    74,     0,     0,     0,
-       0,     0,     0,     0,     0,    92,     0,     0,     0,     0,
-      75,   173,     0,     0,     0,    93,     0,     0,    94,     0,
-       0,    95,    96,     0,    78,    79,     0,     0,     0,     0,
-       0,    97,    80,    81,     0,     0,     0,    98,     0,     0,
-      82,    83,   201,    84,     0,     0,     0,     0,    85,     0,
-       0,     0,     0,    86,     0,     0,    87,     0,     0,     0,
+       0,     0,     0,    89,    90,    33,    74,    34,    75,     0,
+       0,    91,     0,     0,    92,     0,     0,     0,     0,     0,
+       0,     0,    76,    77,     0,     0,     0,     0,     0,    93,
+       0,     0,     0,     0,     0,     0,    79,    80,     0,    94,
+       0,     0,     0,    95,    81,    82,    96,    97,     0,     0,
+       0,     0,    83,    84,     0,    85,    98,     0,     0,     0,
+      86,     0,    99,     0,     0,    87,     0,   100,    88,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      88,    89,     0,     0,     0,     0,     0,     0,    90,     0,
-       0,    91,     0,     0,    33,    73,    34,    74,     0,     0,
-       0,     0,     0,     0,     0,     0,    92,     0,     0,     0,
-       0,    75,    76,     0,     0,     0,    93,     0,     0,    94,
-       0,     0,    95,    96,     0,    78,    79,     0,     0,     0,
-       0,     0,    97,    80,    81,     0,     0,     0,    98,     0,
-       0,    82,    83,    99,    84,     0,     0,     0,     0,    85,
-       0,     0,     0,     0,    86,     0,     0,    87,     0,     0,
+       0,     0,    89,    90,     0,    74,     0,    75,     0,     0,
+      91,     0,     0,    92,     0,     0,     0,     0,     0,     0,
+       0,    76,   176,     0,     0,     0,     0,     0,    93,     0,
+       0,     0,     0,     0,     0,    79,    80,     0,    94,     0,
+       0,     0,    95,     0,    82,    96,    97,     0,     0,     0,
+       0,    83,    84,     0,    85,    98,     0,     0,     0,    86,
+       0,    99,     0,     0,     0,     0,   100,    88,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,    88,    89,    73,     0,    74,     0,     0,     0,    90,
-       0,     0,    91,     0,     0,     0,     0,     0,     0,    75,
-     173,     0,    78,    79,     0,     0,     0,    92,     0,     0,
-       0,    81,     0,    78,    79,     0,     0,    93,    82,    83,
-      94,    84,    81,    95,    96,     0,    85,     0,     0,    82,
-      83,     0,    84,    97,    87,     0,     0,    85,     0,    98,
-       0,     0,     0,     0,    99,    87,     0,     0,    88,   277,
-       0,     0,     0,     0,     0,     0,    90,     0,     0,    88,
-      89,     0,     0,     0,     0,     0,     0,    90,     0,     0,
-      91,     0,     0,     0,    92,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    93,    92,     0,     0,     0,     0,
-      95,    96,     0,     0,     0,    93,     0,     0,     0,     0,
-      97,    95,    96,     0,     0,     0,    98,     0,     0,     0,
-       0,    97,     0,     0,     0,     0,     0,    98
+       0,    89,    90,     0,     0,     0,     0,     0,     0,    91,
+       0,     0,    92,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    93,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    94,     0,     0,
+       0,     0,     0,     0,    96,    97,     0,     0,     0,     0,
+       0,     0,     0,     0,    98,     0,     0,     0,     0,     0,
+      99
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,   142,    44,    12,   146,   119,   160,    11,    12,   138,
-       8,   275,     4,   208,     6,   247,    59,   146,     7,     7,
-       4,     5,     6,     7,     4,     4,     6,     6,    32,    72,
-      29,     8,    27,    37,    38,    39,    40,    41,    80,     8,
-       8,   189,    23,    24,    28,   231,   160,     4,    39,     6,
-      21,    22,   236,    69,    21,    22,    31,    99,   467,   201,
-      66,    50,    50,   387,    67,    78,     5,    29,    10,   121,
-     199,   135,   201,    21,    22,    29,    28,   231,    61,    30,
-      86,    65,   146,   121,   493,    60,   200,    21,    22,    21,
-      22,    10,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,   105,    21,    22,   140,    71,    58,   143,   121,   118,
-      94,    95,   154,   117,   118,     0,   120,   231,   122,   443,
-     162,    36,   114,    37,   106,    61,    40,    41,   276,   145,
-     112,   134,   136,   137,   176,   321,   127,    71,   142,   128,
-     128,   325,   126,   186,   273,   122,   145,   145,   380,   144,
-      92,   134,   144,   144,   283,   284,   160,   114,    77,   201,
-     144,   165,   426,   125,   144,   144,   147,   321,   172,   364,
-     212,   175,   404,   215,   145,   407,   145,   145,   145,   118,
-     119,   295,   185,   137,    10,   189,   134,   191,   192,   193,
-     122,   386,   387,    53,    46,    47,   338,    45,   134,    83,
-     341,    74,   116,    71,   436,   247,   121,   321,     3,   338,
-     351,   253,   115,     4,    48,     6,    76,     0,   146,    45,
-     114,     4,    70,    17,    18,    19,   145,   231,   232,    55,
-      90,    91,   236,   106,    72,     4,    33,     6,   132,   144,
-     161,    79,    33,    26,   114,   399,    80,   251,   443,    87,
-     144,   255,   294,   113,   296,   103,   177,   125,    83,   140,
-     302,   142,   104,   405,   378,   137,    92,   309,   272,   273,
-      53,   109,   276,   414,   415,     5,   405,   103,   138,    95,
-     114,   129,   108,    77,   135,   399,   144,    72,   430,    46,
-      47,   420,   334,     9,    79,    21,    22,   144,     9,    84,
-      82,   430,    87,   129,   313,    21,    22,   145,    34,   313,
-      21,    22,   145,   146,   145,   146,     7,   321,   145,   146,
-       7,   325,    21,    22,   109,   145,   146,     4,     5,     6,
-       7,    57,     4,   144,     6,   377,     5,   341,   380,   343,
-     482,   145,   146,   144,    21,    22,    23,   351,   390,    21,
-      22,   144,     5,   482,    82,   145,   146,   146,    35,    36,
-      98,    33,   404,   367,   144,   407,    43,    44,   145,   146,
-     145,   146,   145,   146,    51,    52,    71,    54,   145,   146,
-       7,    58,    59,   145,   146,   145,   146,    64,   144,   144,
-      67,   145,   146,   534,   436,   399,   438,   145,   146,   145,
-     146,   542,   145,   146,    81,    82,     1,     7,     3,     7,
-     414,   415,    89,   144,   456,    92,   420,    10,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    11,    21,    22,
-     107,   145,   146,   475,     8,   145,   146,    32,   145,   146,
-     117,   483,     9,   120,   145,   146,   123,   124,    20,   146,
-      62,   145,    71,    48,    49,   145,   133,   146,    73,    99,
-     145,    56,   139,   467,   144,    60,   508,   144,   145,    85,
-     474,    85,   131,   144,     4,     5,     6,     7,   144,   144,
-      10,   132,    62,     7,    77,    80,    97,    97,    97,   493,
-      84,    21,    22,     7,     7,    42,    75,    42,   145,    96,
-     504,   144,   144,   137,    27,    35,    36,   146,   144,    92,
-     105,   144,   516,    43,    44,    85,    92,    42,   144,   114,
-     101,    51,    52,   101,    54,    96,   144,    38,     7,    59,
-     534,    99,    95,    63,    64,   130,   144,    67,   542,   146,
-      42,    19,   137,   144,    88,   140,    42,     7,   136,   145,
-     108,    81,    82,    93,   146,   145,   102,   110,     9,    89,
-     102,    33,    92,    68,    68,     4,     5,     6,     7,   144,
-       7,    10,   110,   100,   198,   144,   251,   107,   144,   343,
-     145,    55,    21,    22,   114,   118,   370,   117,   124,    56,
-     120,   399,   483,   123,   124,   506,    35,    36,   162,   544,
-     508,   283,   153,   133,    43,    44,   284,   166,   199,   139,
-     171,   213,    51,    52,   144,    54,   115,   148,    -1,    -1,
-      59,    -1,    -1,    -1,    63,    64,   213,    -1,    67,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,    -1,
-      89,    -1,    -1,    92,    -1,    -1,     4,     5,     6,     7,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   107,    -1,
-      -1,    -1,    -1,    21,    22,    23,    -1,    -1,   117,    -1,
-      -1,   120,    -1,    -1,   123,   124,    -1,    35,    36,    -1,
-      -1,    -1,    -1,    -1,   133,    43,    44,    -1,    -1,    -1,
-     139,    -1,    -1,    51,    52,   144,    54,    -1,    -1,    -1,
-      -1,    59,    -1,    -1,    -1,    -1,    64,    -1,    -1,    67,
+       4,   145,   149,    12,    29,   163,   210,    11,    12,    44,
+     277,   141,     4,   249,     6,    23,    24,    29,   120,   149,
+       8,     7,     4,     8,     6,     4,    29,     6,    32,     7,
+      59,     8,    27,    37,    38,    39,    40,    41,     8,   233,
+      21,    22,   192,     5,    73,   238,    81,    21,    22,   389,
+      21,    22,    78,    36,    71,    10,   203,     4,     5,     6,
+       7,   163,    67,    68,    50,   100,   469,     4,   136,     6,
+      31,   201,    50,   203,    74,   233,    21,    22,     4,   147,
+       6,    28,    10,    11,    12,    13,    14,    15,    16,    17,
+      18,    19,   495,    21,    22,    28,   122,    39,     5,    60,
+     202,   141,   106,   122,   144,   445,   106,    10,    37,   126,
+     119,    40,    41,    66,   118,   119,   122,   121,    65,   123,
+      69,   146,   157,   126,    83,    58,   138,    61,   278,   323,
+     165,   233,   114,    86,   327,   139,   140,    92,   123,   122,
+     148,   145,    45,   129,   179,   275,   382,    94,    95,    77,
+     145,   129,    55,   145,   135,   285,   286,   119,   146,   163,
+     189,   428,   366,   145,   168,   323,   145,    71,   203,   146,
+     406,   175,   146,   409,   178,   146,   146,   114,   123,   214,
+     127,    45,   217,   188,   388,   389,   128,   116,   192,    92,
+     194,   195,   196,   340,     0,   297,    48,   146,   145,   343,
+     103,   135,   438,   145,    30,   108,    70,   164,    53,   353,
+     340,   118,    61,   120,   249,    17,    18,    19,   146,   106,
+     255,   323,   141,   180,   143,   112,     3,   130,    80,   233,
+     234,    76,    46,    47,   238,    35,    36,   115,     0,   103,
+      33,   445,     4,   401,    44,    90,    91,    46,    47,   253,
+     147,    51,    52,   257,    54,   146,   147,   146,   147,    59,
+     407,   296,   114,   298,    26,   145,   130,    67,   113,   304,
+     274,   275,   416,   417,   278,    77,   311,   407,   380,    21,
+      22,    81,    82,   114,   114,   432,   135,   146,   147,    89,
+      72,    53,   422,    83,   139,    21,    22,    79,   138,   401,
+       9,   336,   432,   133,   145,    87,   315,   107,    34,    21,
+      22,   315,    21,    22,    95,   145,   104,   117,   136,   323,
+       7,    72,     7,   327,   124,   125,   145,   109,    79,    71,
+       4,    57,     6,    84,   134,    82,    87,   484,     9,   343,
+     140,   345,   145,     4,   379,     6,     5,   382,   145,   353,
+      21,    22,   146,   147,   484,   146,   147,   392,   109,    33,
+      21,    22,   146,   147,   146,   369,   145,     4,     5,     6,
+       7,   406,    33,     5,   409,   146,   147,   146,   147,   146,
+     147,   146,   147,    82,    21,    22,    23,   146,   147,   146,
+     147,    71,   536,   146,   147,   147,    98,   401,    35,    36,
+     544,   146,   147,   438,   145,   440,    43,    44,   146,   147,
+     146,   147,   416,   417,    51,    52,     7,    54,   422,   146,
+     147,    58,    59,   458,   146,   147,   145,    64,   146,   147,
+      67,   146,   147,     7,   145,     7,    11,   145,     8,    20,
+       9,   147,   477,    62,    81,    82,   146,    71,   146,    99,
+     485,   147,    89,    73,   146,    92,   145,    85,    85,   145,
+     132,   145,   145,   133,    62,   469,     7,    97,    97,    84,
+     107,    97,   476,     7,     7,   510,    42,    42,    75,   146,
+     117,   145,    96,   145,   121,    27,   138,   124,   125,   147,
+      92,   495,   145,    85,   145,   101,    92,   134,     4,     5,
+       6,     7,   506,   140,    10,   145,   101,    96,   145,   146,
+      42,   145,    38,    99,   518,    21,    22,     7,    95,    42,
+     145,    88,    19,   145,   147,    42,     7,   137,   146,    35,
+      36,   147,   536,   146,    93,   108,     9,    43,    44,   102,
+     544,   102,   110,    68,   145,    51,    52,    33,    54,    68,
+     110,   145,   145,    59,   100,     7,   146,    63,    64,   200,
+     372,    67,    10,    11,    12,    13,    14,    15,    16,    17,
+      18,    19,   345,    21,    22,    81,    82,   253,    55,   119,
+     125,    56,   165,    89,   401,   508,    92,   485,   546,   510,
+     285,   169,   286,   201,   174,   116,   151,    -1,   215,   156,
+      -1,   107,    -1,   215,     4,     5,     6,     7,   114,    -1,
+      10,   117,    -1,    -1,     1,   121,     3,    -1,   124,   125,
+      -1,    21,    22,    -1,    -1,    -1,    -1,    -1,   134,    77,
+      -1,    -1,    -1,    -1,   140,    35,    36,    -1,    -1,   145,
+      -1,    -1,    -1,    43,    44,    32,    -1,    -1,    -1,    -1,
+      -1,    51,    52,    -1,    54,    -1,    -1,    -1,    -1,    59,
+      -1,    48,    49,    63,    64,    -1,    -1,    67,    -1,    56,
+      -1,    -1,    -1,    60,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    81,    82,     4,     5,     6,     7,    -1,    -1,    89,
+      -1,    -1,    92,    80,    -1,    -1,    -1,    -1,    -1,    -1,
+      21,    22,    23,    -1,    -1,    -1,    -1,   107,    -1,    -1,
+      -1,    -1,    -1,    -1,    35,    36,    -1,   117,   105,    -1,
+      -1,   121,    43,    44,   124,   125,    -1,   114,    -1,    -1,
+      51,    52,    -1,    54,   134,    -1,    -1,    -1,    59,    -1,
+     140,    -1,    -1,    64,   131,   145,    67,    -1,    -1,    -1,
+      -1,   138,    -1,    -1,   141,    -1,    -1,    -1,    -1,    -1,
+      81,    82,     4,     5,     6,     7,    -1,    -1,    89,    -1,
+      -1,    92,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,
+      22,    -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,
+      -1,    -1,    -1,    35,    36,    -1,   117,    -1,    -1,    -1,
+     121,    43,    44,   124,   125,    -1,    -1,    -1,    -1,    51,
+      52,    -1,    54,   134,    -1,    -1,    -1,    59,    -1,   140,
+      -1,    -1,    64,    -1,   145,    67,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,
+      82,     4,     5,     6,     7,    -1,    -1,    89,    -1,    -1,
+      92,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
+      -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,
+      -1,    -1,    35,    36,    -1,   117,    -1,    -1,    -1,   121,
+      43,    44,   124,   125,    -1,    -1,    -1,    -1,    51,    52,
+      -1,    54,   134,   135,    -1,    -1,    59,    -1,   140,    -1,
+      -1,    64,    -1,   145,    67,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    82,
+      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    92,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,
-      -1,    89,    -1,    -1,    92,    -1,    -1,     4,     5,     6,
-       7,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   107,
-      -1,    -1,    -1,    -1,    21,    22,    -1,    -1,    -1,   117,
-      -1,    -1,   120,    -1,    -1,   123,   124,    -1,    35,    36,
-      -1,    -1,    -1,    -1,    -1,   133,    43,    44,    -1,    -1,
-      -1,   139,    -1,    -1,    51,    52,   144,    54,    -1,    -1,
-      -1,    -1,    59,    -1,    -1,    -1,    -1,    64,    -1,    -1,
+      -1,    -1,    -1,    -1,   107,    -1,    -1,     4,     5,     6,
+       7,   114,    -1,    -1,   117,    -1,    -1,    -1,   121,    -1,
+      -1,   124,   125,    -1,    21,    22,    -1,    -1,    -1,    -1,
+      -1,   134,    -1,    -1,    -1,    -1,    -1,   140,    35,    36,
+      -1,    -1,   145,    -1,    -1,    -1,    43,    44,    -1,    -1,
+      -1,    -1,    -1,    -1,    51,    52,    -1,    54,    -1,    -1,
+      -1,    -1,    59,    -1,    -1,    -1,    63,    64,    -1,    -1,
       67,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    81,    82,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    81,    82,     4,     5,     6,     7,
       -1,    -1,    89,    -1,    -1,    92,    -1,    -1,    -1,    -1,
-      -1,     4,     5,     6,     7,    -1,    -1,    -1,    -1,    -1,
-     107,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
-     117,    -1,    -1,   120,    -1,    -1,   123,   124,    -1,    -1,
-      -1,    -1,    35,    36,    -1,    -1,   133,   134,    -1,    -1,
-      43,    44,   139,    -1,    -1,    -1,    -1,   144,    51,    52,
-      -1,    54,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,
-      -1,    64,    -1,    -1,    67,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    82,
-      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    92,
-      -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    21,
-      22,   114,    -1,    -1,   117,    -1,    -1,   120,    -1,    -1,
-     123,   124,    -1,    35,    36,    -1,    -1,    -1,    -1,    -1,
-     133,    43,    44,    -1,    -1,    -1,   139,    -1,    -1,    51,
-      52,   144,    54,    -1,    -1,    -1,    -1,    59,    -1,    -1,
-      -1,    63,    64,    -1,    -1,    67,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,
-      82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,
-      92,    -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,
-      21,    22,    -1,    -1,    -1,   117,    -1,    -1,   120,    -1,
-      -1,   123,   124,    -1,    35,    36,    -1,    -1,    -1,    -1,
-      -1,   133,    43,    44,    -1,    -1,    -1,   139,    -1,    -1,
-      51,    52,   144,    54,    -1,    -1,    -1,    -1,    59,    -1,
-      -1,    -1,    -1,    64,    -1,    -1,    67,    -1,    -1,    -1,
+      -1,    -1,    -1,    21,    22,    -1,    -1,    -1,    -1,    -1,
+     107,    -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    -1,
+     117,    -1,    -1,    -1,   121,    43,    44,   124,   125,    -1,
+      -1,    -1,    -1,    51,    52,    -1,    54,   134,    -1,    -1,
+      -1,    59,    -1,   140,    -1,    -1,    64,    -1,   145,    67,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    81,    82,     4,     5,     6,     7,    -1,
+      -1,    89,    -1,    -1,    92,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    21,    22,    -1,    -1,    -1,    -1,    -1,   107,
+      -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    -1,   117,
+      -1,    -1,    -1,   121,    43,    44,   124,   125,    -1,    -1,
+      -1,    -1,    51,    52,    -1,    54,   134,    -1,    -1,    -1,
+      59,    -1,   140,    -1,    -1,    64,    -1,   145,    67,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      81,    82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,
-      -1,    92,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,
-      -1,    21,    22,    -1,    -1,    -1,   117,    -1,    -1,   120,
-      -1,    -1,   123,   124,    -1,    35,    36,    -1,    -1,    -1,
-      -1,    -1,   133,    43,    44,    -1,    -1,    -1,   139,    -1,
-      -1,    51,    52,   144,    54,    -1,    -1,    -1,    -1,    59,
-      -1,    -1,    -1,    -1,    64,    -1,    -1,    67,    -1,    -1,
+      -1,    -1,    81,    82,    -1,     5,    -1,     7,    -1,    -1,
+      89,    -1,    -1,    92,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    21,    22,    -1,    -1,    -1,    -1,    -1,   107,    -1,
+      -1,    -1,    -1,    -1,    -1,    35,    36,    -1,   117,    -1,
+      -1,    -1,   121,    -1,    44,   124,   125,    -1,    -1,    -1,
+      -1,    51,    52,    -1,    54,   134,    -1,    -1,    -1,    59,
+      -1,   140,    -1,    -1,    -1,    -1,   145,    67,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    81,    82,     5,    -1,     7,    -1,    -1,    -1,    89,
-      -1,    -1,    92,    -1,    -1,    -1,    -1,    -1,    -1,    21,
-      22,    -1,    35,    36,    -1,    -1,    -1,   107,    -1,    -1,
-      -1,    44,    -1,    35,    36,    -1,    -1,   117,    51,    52,
-     120,    54,    44,   123,   124,    -1,    59,    -1,    -1,    51,
-      52,    -1,    54,   133,    67,    -1,    -1,    59,    -1,   139,
-      -1,    -1,    -1,    -1,   144,    67,    -1,    -1,    81,    82,
-      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    81,
-      82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,
-      92,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,   117,   107,    -1,    -1,    -1,    -1,
-     123,   124,    -1,    -1,    -1,   117,    -1,    -1,    -1,    -1,
-     133,   123,   124,    -1,    -1,    -1,   139,    -1,    -1,    -1,
-      -1,   133,    -1,    -1,    -1,    -1,    -1,   139
+      -1,    81,    82,    -1,    -1,    -1,    -1,    -1,    -1,    89,
+      -1,    -1,    92,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,   117,    -1,    -1,
+      -1,    -1,    -1,    -1,   124,   125,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   134,    -1,    -1,    -1,    -1,    -1,
+     140
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1367,97 +1368,97 @@ static const yytype_int16 yycheck[] =
 static const yytype_uint16 yystos[] =
 {
        0,     1,     3,    32,    48,    49,    56,    60,    80,   105,
-     114,   130,   137,   140,   149,   150,   151,   152,   153,   154,
-     155,   177,   178,   181,   182,   185,   187,   190,   191,   192,
-     257,   258,   121,     4,     6,   190,   255,    78,   121,    71,
-     121,    83,    28,    58,   193,   255,   188,   189,   204,   255,
-       0,   140,   142,    48,    80,   190,    29,   137,   186,    30,
-     140,   143,     3,   255,   125,   179,    71,   179,   255,   255,
-     255,   255,   255,     5,     7,    21,    22,    23,    35,    36,
-      43,    44,    51,    52,    54,    59,    64,    67,    81,    82,
-      89,    92,   107,   117,   120,   123,   124,   133,   139,   144,
-     158,   194,   195,   196,   198,   230,   231,   232,   233,   234,
-     235,   236,   237,   244,   248,   251,   255,   115,   146,    33,
-     144,   190,    83,   186,   193,   104,   192,    31,    60,     5,
-     118,   119,   137,   180,     5,   180,    95,   144,   135,   224,
-     225,   132,   144,   192,     7,     7,   134,   230,   240,   241,
-     144,    82,   144,     5,   144,   144,    82,   190,   230,     5,
-      71,   197,   146,    21,    22,    33,   252,   255,    23,    24,
-     147,   253,    98,    22,   233,    27,   144,   183,   184,   255,
-     189,   144,   198,   254,   255,   179,   255,   191,     7,    46,
-      47,    46,    47,   144,   180,   255,   156,   157,   255,    10,
-      63,   144,   226,   227,   228,   229,   230,   248,   144,   247,
-     254,   226,   134,   238,   239,    61,   241,   242,     7,    53,
-      76,    90,    91,   113,   138,   245,   245,   230,     7,   145,
-     145,   144,   198,   201,   202,   205,   234,   255,   224,   196,
-     255,   231,   232,   144,   255,   255,    23,    58,   145,   230,
-     243,   146,   224,    11,   145,   146,   180,   192,   156,    45,
-      70,   103,   129,   162,   255,   255,   169,   170,   171,   172,
-     173,   174,   255,   144,   165,   145,   146,    82,   158,   229,
-     198,   226,   230,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    77,   250,    20,   244,   246,
-     146,   145,   122,   230,   239,   242,   230,    62,   145,    71,
-      71,   145,   201,    33,   203,   204,    72,    79,    87,   109,
-     200,   146,   203,    39,   127,   199,    73,   206,    99,   213,
-     214,   145,   243,   145,   146,   184,   230,   255,   144,    85,
-      85,   144,   145,   146,     5,     7,    28,    65,    94,    95,
-     126,   144,   255,   256,   248,   249,   255,   131,   162,   163,
-     164,   156,    10,    45,    55,    92,   103,   108,   129,   159,
-     160,   161,   145,   227,   228,    17,    18,    19,    77,   230,
-     144,   198,   230,    10,    92,   145,   146,   144,   132,   230,
-     122,    62,   230,     7,   145,   204,    97,    97,    97,    84,
-     201,     7,     7,   203,    42,    75,   207,    42,   145,    96,
-     215,   145,   230,   226,   144,   144,   254,   170,   254,   145,
-     146,    37,    40,    41,   116,   175,   146,   137,   166,    92,
-     144,   244,    85,   255,   159,   230,   144,   198,     9,   243,
-      92,   244,   246,   144,   230,   145,    69,   145,   202,   101,
-     101,   243,   226,    96,   208,   243,    42,   106,   112,   216,
-     217,   145,   254,   254,   145,   145,   248,   144,   176,   162,
-      38,    99,   167,   226,   144,     9,   243,   230,   145,   145,
-     246,     7,    95,    42,    88,   209,   220,   221,   230,    19,
-     145,   145,   169,   144,    42,   145,   255,   230,   145,   145,
-     145,   226,   220,     7,   136,   210,   211,   212,   146,    34,
-      57,   222,     7,    50,   128,   218,   108,   145,   169,    74,
-     106,   168,   145,   255,   212,   221,    93,   223,   102,   110,
-     102,     9,   255,   145,   144,    33,    66,    86,     7,    50,
-     128,   219,   144,   254,   144,    68,   110,    68,   254,   145,
-     213,   145,   100,   145,     7
+     114,   131,   138,   141,   150,   151,   152,   153,   154,   155,
+     156,   178,   179,   183,   184,   187,   189,   192,   193,   194,
+     259,   260,   122,     4,     6,   192,   257,    78,   122,    71,
+     122,    83,    28,    58,   195,   257,   190,   191,   206,   257,
+       0,   141,   143,    48,    80,   192,    29,   138,   188,    30,
+     141,   144,     3,   257,   126,   181,    71,   180,   181,   257,
+     257,   257,   257,   257,     5,     7,    21,    22,    23,    35,
+      36,    43,    44,    51,    52,    54,    59,    64,    67,    81,
+      82,    89,    92,   107,   117,   121,   124,   125,   134,   140,
+     145,   159,   196,   197,   198,   200,   232,   233,   234,   235,
+     236,   237,   238,   239,   246,   250,   253,   257,   115,   147,
+      33,   145,   192,    83,   188,   195,   104,   194,    31,    60,
+       5,   118,   120,   138,   182,     5,   119,   182,   182,    95,
+     145,   136,   226,   227,   133,   145,   194,     7,     7,   135,
+     232,   242,   243,   145,    82,   145,     5,   145,   145,    82,
+     192,   232,     5,    71,   199,   147,    21,    22,    33,   254,
+     257,    23,    24,   148,   255,    98,    22,   235,    27,   145,
+     185,   186,   257,   191,   145,   200,   256,   257,   181,   257,
+     193,     7,    46,    47,    46,    47,   145,   257,   157,   158,
+     257,    10,    63,   145,   228,   229,   230,   231,   232,   250,
+     145,   249,   256,   228,   135,   240,   241,    61,   243,   244,
+       7,    53,    76,    90,    91,   113,   139,   247,   247,   232,
+       7,   146,   146,   145,   200,   203,   204,   207,   236,   257,
+     226,   198,   257,   233,   234,   145,   257,   257,    23,    58,
+     146,   232,   245,   147,   226,    11,   146,   147,   182,   194,
+     157,    45,    70,   103,   130,   163,   257,   257,   170,   171,
+     172,   173,   174,   175,   257,   145,   166,   146,   147,    82,
+     159,   231,   200,   228,   232,     8,     9,    10,    11,    12,
+      13,    14,    15,    16,    17,    18,    19,    77,   252,    20,
+     246,   248,   147,   146,   123,   232,   241,   244,   232,    62,
+     146,    71,    71,   146,   203,    33,   205,   206,    72,    79,
+      87,   109,   202,   147,   205,    39,   128,   201,    73,   208,
+      99,   215,   216,   146,   245,   146,   147,   186,   232,   257,
+     145,    85,    85,   145,   146,   147,     5,     7,    28,    65,
+      94,    95,   127,   145,   257,   258,   250,   251,   257,   132,
+     163,   164,   165,   157,    10,    45,    55,    92,   103,   108,
+     130,   160,   161,   162,   146,   229,   230,    17,    18,    19,
+      77,   232,   145,   200,   232,    10,    92,   146,   147,   145,
+     133,   232,   123,    62,   232,     7,   146,   206,    97,    97,
+      97,    84,   203,     7,     7,   205,    42,    75,   209,    42,
+     146,    96,   217,   146,   232,   228,   145,   145,   256,   171,
+     256,   146,   147,    37,    40,    41,   116,   176,   147,   138,
+     167,    92,   145,   246,    85,   257,   160,   232,   145,   200,
+       9,   245,    92,   246,   248,   145,   232,   146,    69,   146,
+     204,   101,   101,   245,   228,    96,   210,   245,    42,   106,
+     112,   218,   219,   146,   256,   256,   146,   146,   250,   145,
+     177,   163,    38,    99,   168,   228,   145,     9,   245,   232,
+     146,   146,   248,     7,    95,    42,    88,   211,   222,   223,
+     232,    19,   146,   146,   170,   145,    42,   146,   257,   232,
+     146,   146,   146,   228,   222,     7,   137,   212,   213,   214,
+     147,    34,    57,   224,     7,    50,   129,   220,   108,   146,
+     170,    74,   106,   169,   146,   257,   214,   223,    93,   225,
+     102,   110,   102,     9,   257,   146,   145,    33,    66,    86,
+       7,    50,   129,   221,   145,   256,   145,    68,   110,    68,
+     256,   146,   215,   146,   100,   146,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint16 yyr1[] =
 {
-       0,   148,   149,   149,   149,   149,   149,   149,   150,   150,
-     150,   150,   150,   150,   150,   150,   150,   150,   151,   152,
-     152,   152,   152,   153,   154,   155,   156,   157,   157,   158,
-     158,   158,   158,   158,   158,   158,   158,   158,   158,   158,
-     158,   158,   158,   158,   158,   158,   158,   159,   159,   159,
-     159,   159,   159,   159,   160,   160,   161,   161,   162,   162,
-     162,   162,   163,   163,   164,   164,   165,   165,   166,   166,
-     167,   167,   168,   168,   169,   169,   170,   170,   170,   170,
-     171,   171,   171,   172,   173,   174,   175,   175,   175,   175,
-     176,   176,   177,   177,   177,   177,   178,   178,   178,   178,
-     179,   179,   179,   180,   180,   181,   182,   183,   183,   184,
-     185,   185,   186,   186,   187,   188,   188,   189,   190,   190,
-     191,   191,   192,   193,   193,   193,   194,   194,   195,   195,
-     196,   196,   196,   197,   198,   199,   199,   199,   200,   200,
-     200,   200,   200,   200,   200,   200,   201,   201,   202,   202,
-     202,   202,   202,   202,   203,   203,   204,   204,   205,   205,
-     206,   206,   207,   207,   208,   208,   209,   209,   210,   210,
-     211,   211,   212,   213,   214,   214,   215,   215,   216,   216,
-     217,   217,   218,   218,   218,   219,   219,   219,   220,   220,
-     221,   222,   222,   222,   223,   223,   223,   224,   224,   225,
-     226,   226,   227,   227,   228,   228,   229,   229,   229,   229,
-     229,   229,   229,   229,   229,   229,   229,   230,   230,   231,
-     231,   232,   232,   233,   233,   233,   233,   233,   233,   233,
-     233,   233,   233,   234,   234,   234,   234,   235,   236,   236,
-     237,   237,   238,   238,   239,   240,   240,   241,   242,   242,
-     243,   243,   244,   244,   244,   244,   244,   244,   244,   244,
-     245,   245,   245,   245,   245,   245,   246,   246,   247,   247,
-     248,   248,   249,   249,   250,   250,   250,   250,   250,   250,
-     250,   250,   250,   250,   251,   252,   252,   253,   253,   253,
-     254,   254,   255,   255,   256,   256,   256,   256,   257,   258,
-     258
+       0,   149,   150,   150,   150,   150,   150,   150,   151,   151,
+     151,   151,   151,   151,   151,   151,   151,   151,   152,   153,
+     153,   153,   153,   154,   155,   156,   157,   158,   158,   159,
+     159,   159,   159,   159,   159,   159,   159,   159,   159,   159,
+     159,   159,   159,   159,   159,   159,   159,   160,   160,   160,
+     160,   160,   160,   160,   161,   161,   162,   162,   163,   163,
+     163,   163,   164,   164,   165,   165,   166,   166,   167,   167,
+     168,   168,   169,   169,   170,   170,   171,   171,   171,   171,
+     172,   172,   172,   173,   174,   175,   176,   176,   176,   176,
+     177,   177,   178,   178,   178,   178,   179,   179,   179,   179,
+     180,   180,   181,   181,   181,   182,   182,   183,   184,   185,
+     185,   186,   187,   187,   188,   188,   189,   190,   190,   191,
+     192,   192,   193,   193,   194,   195,   195,   195,   196,   196,
+     197,   197,   198,   198,   198,   199,   200,   201,   201,   201,
+     202,   202,   202,   202,   202,   202,   202,   202,   203,   203,
+     204,   204,   204,   204,   204,   204,   205,   205,   206,   206,
+     207,   207,   208,   208,   209,   209,   210,   210,   211,   211,
+     212,   212,   213,   213,   214,   215,   216,   216,   217,   217,
+     218,   218,   219,   219,   220,   220,   220,   221,   221,   221,
+     222,   222,   223,   224,   224,   224,   225,   225,   225,   226,
+     226,   227,   228,   228,   229,   229,   230,   230,   231,   231,
+     231,   231,   231,   231,   231,   231,   231,   231,   231,   232,
+     232,   233,   233,   234,   234,   235,   235,   235,   235,   235,
+     235,   235,   235,   235,   235,   236,   236,   236,   236,   237,
+     238,   238,   239,   239,   240,   240,   241,   242,   242,   243,
+     244,   244,   245,   245,   246,   246,   246,   246,   246,   246,
+     246,   246,   247,   247,   247,   247,   247,   247,   248,   248,
+     249,   249,   250,   250,   251,   251,   252,   252,   252,   252,
+     252,   252,   252,   252,   252,   252,   253,   254,   254,   255,
+     255,   255,   256,   256,   257,   257,   258,   258,   258,   258,
+     259,   260,   260
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1472,28 +1473,28 @@ static const yytype_uint8 yyr2[] =
       10,     4,     3,     1,     0,     1,     0,     3,     0,     5,
        0,     8,     1,     1,     1,     3,     1,     1,     1,     1,
        2,     2,     2,     4,     2,     2,     1,     1,     1,     1,
-       0,     3,    10,     5,     4,     5,     5,     4,     4,     5,
-       2,     2,     2,     0,     4,     5,     4,     3,     1,     3,
-       2,     3,     0,     3,     2,     1,     3,     3,     4,     1,
-       3,     1,    10,     0,     1,     1,     1,     1,     1,     3,
-       3,     2,     1,     2,     3,     0,     3,     3,     0,     1,
-       1,     2,     1,     2,     1,     2,     6,     1,     2,     3,
-       2,     2,     1,     3,     1,     2,     1,     4,     1,     3,
-       0,     3,     0,     2,     0,     3,     0,     2,     0,     1,
-       1,     2,     6,     3,     0,     3,     0,     3,     0,     5,
-       1,     1,     2,     2,     2,     2,     2,     2,     1,     3,
-       3,     0,     1,     1,     0,     2,     2,     0,     1,     2,
-       3,     1,     3,     1,     2,     1,     5,     6,     4,     3,
-       3,     3,     2,     3,     5,     4,     6,     3,     1,     3,
-       1,     2,     1,     1,     1,     1,     3,     5,     1,     1,
-       1,     3,     1,     3,     4,     4,     5,     6,     6,     8,
-       5,     4,     1,     2,     4,     1,     2,     4,     0,     2,
-       1,     3,     1,     1,     2,     2,     1,     2,     3,     2,
-       1,     1,     1,     1,     1,     1,     1,     3,     3,     5,
-       1,     3,     1,     3,     1,     1,     1,     1,     1,     1,
-       1,     2,     1,     2,     1,     1,     1,     1,     1,     1,
-       1,     3,     1,     1,     1,     1,     1,     1,     2,     2,
-       0
+       0,     3,    10,     5,     4,     5,     4,     4,     4,     5,
+       2,     2,     2,     2,     2,     0,     4,     5,     4,     3,
+       1,     3,     2,     3,     0,     3,     2,     1,     3,     3,
+       4,     1,     3,     1,    10,     0,     1,     1,     1,     1,
+       1,     3,     3,     2,     1,     2,     3,     0,     3,     3,
+       0,     1,     1,     2,     1,     2,     1,     2,     6,     1,
+       2,     3,     2,     2,     1,     3,     1,     2,     1,     4,
+       1,     3,     0,     3,     0,     2,     0,     3,     0,     2,
+       0,     1,     1,     2,     6,     3,     0,     3,     0,     3,
+       0,     5,     1,     1,     2,     2,     2,     2,     2,     2,
+       1,     3,     3,     0,     1,     1,     0,     2,     2,     0,
+       1,     2,     3,     1,     3,     1,     2,     1,     5,     6,
+       4,     3,     3,     3,     2,     3,     5,     4,     6,     3,
+       1,     3,     1,     2,     1,     1,     1,     1,     3,     5,
+       1,     1,     1,     3,     1,     3,     4,     4,     5,     6,
+       6,     8,     5,     4,     1,     2,     4,     1,     2,     4,
+       0,     2,     1,     3,     1,     1,     2,     2,     1,     2,
+       3,     2,     1,     1,     1,     1,     1,     1,     1,     3,
+       3,     5,     1,     3,     1,     3,     1,     1,     1,     1,
+       1,     1,     1,     2,     1,     2,     1,     1,     1,     1,
+       1,     1,     1,     3,     1,     1,     1,     1,     1,     1,
+       2,     2,     0
 };
 
 
@@ -1990,1081 +1991,1091 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 637 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2000 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2001 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 637 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2010 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2011 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 637 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2020 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2021 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 637 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2030 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2031 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 637 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 2040 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 

<TRUNCATED>


[4/7] incubator-quickstep git commit: Quickstep for GRAIL

Posted by ji...@apache.org.
Quickstep 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/b75dba28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/b75dba28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/b75dba28

Branch: refs/heads/trace
Commit: b75dba2834df330cdc80d0acc2c576954e169048
Parents: 0fe838d
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Sat Sep 2 23:06:37 2017 -0500
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Fri Dec 22 21:50:44 2017 -0600

----------------------------------------------------------------------
 CMakeLists.txt                                  |    4 +-
 catalog/CatalogRelationStatistics.hpp           |    9 +
 cli/CommandExecutor.cpp                         |  249 +-
 cli/Constants.hpp                               |    2 +
 cli/IOInterface.hpp                             |    9 +-
 cli/LocalIO.hpp                                 |    4 +
 cli/NetworkCli.proto                            |    1 +
 cli/NetworkCliClient.hpp                        |    7 +-
 cli/NetworkCliClientMain.cpp                    |   30 +-
 cli/NetworkIO.cpp                               |    5 +
 cli/NetworkIO.hpp                               |   33 +-
 cli/QuickstepCli.cpp                            |    3 +-
 cli/quickstep/NetworkCliOuterClass.java         | 1388 +++++++
 cli/tests/NetworkIO_unittest.cpp                |    2 +-
 .../aggregation/AggregateFunctionMax.cpp        |    4 +-
 .../aggregation/AggregateFunctionMin.cpp        |    4 +-
 parser/SqlLexer.lpp                             |    1 +
 parser/SqlParser.ypp                            |   15 +-
 parser/preprocessed/SqlLexer_gen.cpp            |  861 ++---
 parser/preprocessed/SqlLexer_gen.hpp            |    2 +-
 parser/preprocessed/SqlParser_gen.cpp           | 3436 +++++++++---------
 parser/preprocessed/SqlParser_gen.hpp           |   49 +-
 query_optimizer/ExecutionGenerator.cpp          |   12 +-
 .../cost_model/StarSchemaSimpleCostModel.cpp    |    4 +-
 query_optimizer/resolver/Resolver.cpp           |    9 +-
 relational_operators/TableExportOperator.cpp    |    2 +
 relational_operators/TextScanOperator.cpp       |  104 +-
 relational_operators/TextScanOperator.hpp       |    2 +
 storage/AggregationOperationState.cpp           |    3 +-
 utility/ExecutionDAGVisualizer.cpp              |    6 +-
 30 files changed, 4009 insertions(+), 2251 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 071f8fc..cb8e9f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -291,7 +291,7 @@ else()
   # Treat warnings as errors, 'cause we hardcore.
   CHECK_CXX_COMPILER_FLAG("-Werror" COMPILER_HAS_WERROR)
   if (COMPILER_HAS_WERROR)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+    # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
   endif()
 
   # Clang reports such warning when using Protoc 3.0 beta.
@@ -585,7 +585,7 @@ if(USE_TCMALLOC)
   CHECK_CXX_COMPILER_FLAG("-Wno-return-type-c-linkage"
                           COMPILER_HAS_WNO_RETURN_TYPE_C_LINKAGE)
   if (COMPILER_HAS_WNO_RETURN_TYPE_C_LINKAGE)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
+    # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
   endif()
 endif()
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/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/b75dba28/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<ParseString> &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<std::int64_t>());
+
+    // 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<ParseString> &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<ParseString> &arguments,
                                    storage_manager,
                                    query_processor,
                                    parser_wrapper.get());
-
-      auto results_it = results.begin();
-      DCHECK_EQ(TypeID::kLong, results_it->getTypeID());
+      DCHECK_EQ(2u, results.size());
 
       const attribute_id attr_id = attribute.getID();
-      mutable_stat->setNumDistinctValues(attr_id,
-                                         results_it->getLiteral<std::int64_t>());
-      if (is_min_applicable) {
-        ++results_it;
-        mutable_stat->setMinValue(attr_id, *results_it);
+      mutable_stat->setMinValue(attr_id, results[0]);
+      mutable_stat->setMaxValue(attr_id, results[1]);
+    }
+
+    // Get the number of distinct values for each column.
+    for (const CatalogAttribute &attribute : relation) {
+      const std::string attr_name = EscapeQuotes(attribute.getName(), '"');
+
+      std::string query_string = "SELECT COUNT(*) FROM (SELECT \"";
+      query_string.append(attr_name);
+      query_string.append("\" FROM \"");
+      query_string.append(rel_name);
+      query_string.append("\" GROUP BY \"");
+      query_string.append(attr_name);
+      query_string.append("\") t;");
+
+      TypedValue num_distinct_values =
+          ExecuteQueryForSingleResult(main_thread_client_id,
+                                      foreman_client_id,
+                                      query_string,
+                                      bus,
+                                      storage_manager,
+                                      query_processor,
+                                      parser_wrapper.get());
+
+      DCHECK_EQ(TypeID::kLong, num_distinct_values.getTypeID());
+      mutable_stat->setNumDistinctValues(
+          attribute.getID(), num_distinct_values.getLiteral<std::int64_t>());
+    }
+
+    fprintf(out, "done\n");
+    fflush(out);
+  }
+  query_processor->markCatalogAltered();
+  query_processor->saveCatalog();
+}
+
+void ExecuteAnalyzeRange(const PtrVector<ParseString> &arguments,
+                         const tmb::client_id main_thread_client_id,
+                         const tmb::client_id foreman_client_id,
+                         MessageBus *bus,
+                         StorageManager *storage_manager,
+                         QueryProcessor *query_processor,
+                         FILE *out) {
+  const CatalogDatabase &database = *query_processor->getDefaultDatabase();
+
+  std::unique_ptr<SqlParserWrapper> parser_wrapper(new SqlParserWrapper());
+  std::vector<std::reference_wrapper<const CatalogRelation>> relations;
+  if (arguments.empty()) {
+    relations.insert(relations.begin(), database.begin(), database.end());
+  } else {
+    for (const auto &rel_name : arguments) {
+      const CatalogRelation *rel = database.getRelationByName(rel_name.value());
+      if (rel == nullptr) {
+        THROW_SQL_ERROR_AT(&rel_name) << "Table does not exist";
+      } else {
+        relations.emplace_back(*rel);
+      }
+    }
+  }
+
+  // Analyze each relation in the database.
+  for (const CatalogRelation &relation : relations) {
+    fprintf(out, "Analyzing %s ... ", relation.getName().c_str());
+    fflush(out);
+
+    CatalogRelation *mutable_relation =
+        query_processor->getDefaultDatabase()->getRelationByIdMutable(relation.getID());
+    CatalogRelationStatistics *mutable_stat =
+        mutable_relation->getStatisticsMutable();
+
+    if (!mutable_stat->isExact()) {
+      mutable_stat->clear();
+
+      const std::string rel_name = EscapeQuotes(relation.getName(), '"');
+
+      for (const CatalogAttribute &attribute : relation) {
+        const std::string attr_name = EscapeQuotes(attribute.getName(), '"');
+        const Type &attr_type = attribute.getType();
+        bool is_min_applicable =
+            AggregateFunctionMin::Instance().canApplyToTypes({&attr_type});
+        bool is_max_applicable =
+            AggregateFunctionMax::Instance().canApplyToTypes({&attr_type});
+        if (!is_min_applicable || !is_max_applicable) {
+          continue;
+        }
+
+        std::string query_string = "SELECT MIN(\"";
+        query_string.append(attr_name);
+        query_string.append("\"), MAX(\"");
+        query_string.append(attr_name);
+        query_string.append("\") FROM \"");
+        query_string.append(rel_name);
+        query_string.append("\";");
+
+        std::vector<TypedValue> results =
+            ExecuteQueryForSingleRow(main_thread_client_id,
+                                     foreman_client_id,
+                                     query_string,
+                                     bus,
+                                     storage_manager,
+                                     query_processor,
+                                     parser_wrapper.get());
+        DCHECK_EQ(2u, results.size());
+
+        const attribute_id attr_id = attribute.getID();
+        mutable_stat->setMinValue(attr_id, results[0]);
+        mutable_stat->setMaxValue(attr_id, results[1]);
       }
-      if (is_max_applicable) {
-        ++results_it;
-        mutable_stat->setMaxValue(attr_id, *results_it);
+    }
+    fprintf(out, "done\n");
+    fflush(out);
+  }
+  query_processor->markCatalogAltered();
+  query_processor->saveCatalog();
+}
+
+void ExecuteAnalyzeCount(const PtrVector<ParseString> &arguments,
+                         const tmb::client_id main_thread_client_id,
+                         const tmb::client_id foreman_client_id,
+                         MessageBus *bus,
+                         StorageManager *storage_manager,
+                         QueryProcessor *query_processor,
+                         FILE *out) {
+  const CatalogDatabase &database = *query_processor->getDefaultDatabase();
+
+  std::unique_ptr<SqlParserWrapper> parser_wrapper(new SqlParserWrapper());
+  std::vector<std::reference_wrapper<const CatalogRelation>> relations;
+  if (arguments.empty()) {
+    relations.insert(relations.begin(), database.begin(), database.end());
+  } else {
+    for (const auto &rel_name : arguments) {
+      const CatalogRelation *rel = database.getRelationByName(rel_name.value());
+      if (rel == nullptr) {
+        THROW_SQL_ERROR_AT(&rel_name) << "Table does not exist";
+      } else {
+        relations.emplace_back(*rel);
       }
     }
+  }
 
-    // Get the number of tuples for the relation.
-    std::string query_string = "SELECT COUNT(*) FROM \"";
-    query_string.append(rel_name);
-    query_string.append("\";");
+  // Analyze each relation in the database.
+  for (const CatalogRelation &relation : relations) {
+    fprintf(out, "Analyzing %s ... ", relation.getName().c_str());
+    fflush(out);
 
-    TypedValue num_tuples =
-        ExecuteQueryForSingleResult(main_thread_client_id,
-                                    foreman_client_id,
-                                    query_string,
-                                    bus,
-                                    storage_manager,
-                                    query_processor,
-                                    parser_wrapper.get());
+    CatalogRelation *mutable_relation =
+        query_processor->getDefaultDatabase()->getRelationByIdMutable(relation.getID());
+    CatalogRelationStatistics *mutable_stat =
+        mutable_relation->getStatisticsMutable();
 
-    DCHECK_EQ(TypeID::kLong, num_tuples.getTypeID());
-    mutable_stat->setNumTuples(num_tuples.getLiteral<std::int64_t>());
+    if (!mutable_stat->isExact()) {
+      mutable_stat->clear();
 
-    mutable_stat->setExactness(true);
+      // Get the number of tuples for the relation.
+      std::string query_string = "SELECT COUNT(*) FROM \"";
+      query_string.append(EscapeQuotes(relation.getName(), '"'));
+      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<std::int64_t>());
+
+    }
     fprintf(out, "done\n");
     fflush(out);
   }
@@ -314,6 +463,20 @@ void executeCommand(const ParseStatement &statement,
                    bus,
                    storage_manager,
                    query_processor, out);
+  } else if (command_str == kAnalyzeRangeCommand) {
+    ExecuteAnalyzeRange(arguments,
+                        main_thread_client_id,
+                        foreman_client_id,
+                        bus,
+                        storage_manager,
+                        query_processor, out);
+  } else if (command_str == kAnalyzeCountCommand) {
+    ExecuteAnalyzeCount(arguments,
+                        main_thread_client_id,
+                        foreman_client_id,
+                        bus,
+                        storage_manager,
+                        query_processor, out);
   } else {
     THROW_SQL_ERROR_AT(command.command()) << "Invalid Command";
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/Constants.hpp
----------------------------------------------------------------------
diff --git a/cli/Constants.hpp b/cli/Constants.hpp
index 0b4a37b..8934b03 100644
--- a/cli/Constants.hpp
+++ b/cli/Constants.hpp
@@ -30,6 +30,8 @@ namespace cli {
 constexpr char kDescribeDatabaseCommand[] = "\\dt";
 constexpr char kDescribeTableCommand[] = "\\d";
 constexpr char kAnalyzeCommand[] = "\\analyze";
+constexpr char kAnalyzeRangeCommand[] = "\\analyzerange";
+constexpr char kAnalyzeCountCommand[] = "\\analyzecount";
 
 /** @} */
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/IOInterface.hpp
----------------------------------------------------------------------
diff --git a/cli/IOInterface.hpp b/cli/IOInterface.hpp
index dc0d5b2..ec125f9 100644
--- a/cli/IOInterface.hpp
+++ b/cli/IOInterface.hpp
@@ -40,14 +40,19 @@ class IOHandle {
   virtual ~IOHandle() {}
 
   /**
+   * @return A file handle for standard input.
+   */
+  virtual FILE* in() = 0;
+
+  /**
    * @return A file handle for standard output.
    */
-  virtual FILE *out() = 0;
+  virtual FILE* out() = 0;
 
   /**
    * @return A file handle for error output.
    */
-  virtual FILE *err() = 0;
+  virtual FILE* err() = 0;
 
   virtual std::string getCommand() const = 0;
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/LocalIO.hpp
----------------------------------------------------------------------
diff --git a/cli/LocalIO.hpp b/cli/LocalIO.hpp
index 4dc3b3f..42501d2 100644
--- a/cli/LocalIO.hpp
+++ b/cli/LocalIO.hpp
@@ -46,6 +46,10 @@ class LocalIOHandle final : public IOHandle {
 
   ~LocalIOHandle() override {}
 
+  FILE *in() override {
+    return stdin;
+  }
+
   FILE *out() override {
     return stdout;
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/NetworkCli.proto
----------------------------------------------------------------------
diff --git a/cli/NetworkCli.proto b/cli/NetworkCli.proto
index e065c7c..1558d01 100644
--- a/cli/NetworkCli.proto
+++ b/cli/NetworkCli.proto
@@ -25,6 +25,7 @@ service NetworkCli {
 
 message QueryRequest {
   string query = 1;
+  string data = 2;
 }
 
 message QueryResponse {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/NetworkCliClient.hpp
----------------------------------------------------------------------
diff --git a/cli/NetworkCliClient.hpp b/cli/NetworkCliClient.hpp
index 7affeff..5c11cb2 100644
--- a/cli/NetworkCliClient.hpp
+++ b/cli/NetworkCliClient.hpp
@@ -53,9 +53,10 @@ class NetworkCliClient {
    * @param user_query A SQL statement or command to be executed on the server.
    * @return The text of the server's response.
    */
-  std::string Query(const std::string &user_query) {
+  std::string Query(const std::string &user_query, const std::string &data) {
     QueryRequest request;
     request.set_query(user_query);
+    request.set_data(data);
     QueryResponse response;
 
     Status status = SendQuery(request, &response);
@@ -63,8 +64,8 @@ class NetworkCliClient {
     if (status.ok()) {
       return HandleQueryResponse(response);
     } else {
-      LOG(WARNING) << "RPC call failed with code " << status.error_code()
-                   << " and message: " << status.error_message();
+      std::cout << "RPC call failed with code " << status.error_code()
+                << " and message: " << status.error_message() << "\n";
       return "RPC failed";
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/NetworkCliClientMain.cpp
----------------------------------------------------------------------
diff --git a/cli/NetworkCliClientMain.cpp b/cli/NetworkCliClientMain.cpp
index c55819b..164d81e 100644
--- a/cli/NetworkCliClientMain.cpp
+++ b/cli/NetworkCliClientMain.cpp
@@ -38,22 +38,42 @@ int main(int argc, char **argv) {
   gflags::ParseCommandLineFlags(&argc, &argv, true);
   grpc_init();
 
+  grpc::ChannelArguments grpc_args;
+  grpc_args.SetMaxSendMessageSize(quickstep::FLAGS_cli_network_max_message_length);
+  grpc_args.SetMaxReceiveMessageSize(quickstep::FLAGS_cli_network_max_message_length);
+
   // Attempts to send a single query retrieved from stdin to the Quickstep Server.
   NetworkCliClient qs_client(
-    grpc::CreateChannel(quickstep::NetworkIO::GetAddress(),
-                        grpc::InsecureChannelCredentials()));
+    grpc::CreateCustomChannel(quickstep::NetworkIO::GetAddress(),
+                              grpc::InsecureChannelCredentials(),
+                              grpc_args));
 
   // Read stdin until EOF, then we use a Line reader to divide query into parts.
   std::cin >> std::noskipws;
   std::istream_iterator<char> it(std::cin), end;
-  std::string user_queries(it, end);
+  std::string input(it, end);
+
+  if (input.empty()) {
+    return 0;
+  }
+
+  // Temporary hack for transmitting data in a separate channel ...
+  std::string queries;
+  std::string data;
+  if (input.front() == 0) {
+    const std::size_t r = input.find(static_cast<char>(0), 1);
+    queries = input.substr(1, r - 1);
+    data = input.substr(r + 1);
+  } else {
+    queries = std::move(input);
+  }
 
   LineReaderBuffered linereader;
-  linereader.setBuffer(user_queries);
+  linereader.setBuffer(queries);
   while (!linereader.bufferEmpty()) {
     std::string query = linereader.getNextCommand();
     if (!query.empty()) {
-      std::cout << qs_client.Query(query) << std::endl;
+      std::cout << qs_client.Query(query, data) << std::endl;
     }
   }
   return 0;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/NetworkIO.cpp
----------------------------------------------------------------------
diff --git a/cli/NetworkIO.cpp b/cli/NetworkIO.cpp
index f0acc65..cbc815e 100644
--- a/cli/NetworkIO.cpp
+++ b/cli/NetworkIO.cpp
@@ -47,10 +47,15 @@ DEFINE_string(cli_network_ip, "0.0.0.0",
                 "if the cli is set to use the network mode (--mode=network). Defaults to "
                 "the address of localhost.");
 
+DEFINE_int32(cli_network_max_message_length, 1073741824,
+             "The maximum message length transferred through grpc");
+
 NetworkIO::NetworkIO() {
   grpc::ServerBuilder builder;
   builder.AddListeningPort(GetAddress(), grpc::InsecureServerCredentials());
   builder.RegisterService(&service_);
+  builder.SetMaxReceiveMessageSize(FLAGS_cli_network_max_message_length);
+  builder.SetMaxSendMessageSize(FLAGS_cli_network_max_message_length);
   server_ = builder.BuildAndStart();
   LOG(INFO) << "Listening on " << GetAddress();
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/NetworkIO.hpp
----------------------------------------------------------------------
diff --git a/cli/NetworkIO.hpp b/cli/NetworkIO.hpp
index 3693f88..e55c206 100644
--- a/cli/NetworkIO.hpp
+++ b/cli/NetworkIO.hpp
@@ -47,6 +47,7 @@ using grpc::Status;
 namespace quickstep {
 DECLARE_int32(cli_network_port);
 DECLARE_string(cli_network_ip);
+DECLARE_int32(cli_network_max_message_length);
 namespace networkio_internal {
 
 /**
@@ -80,8 +81,9 @@ class RequestState {
    * @note Quickstep may either produce a query response or cancel. Both these actions must notify the condition.
    */
   void waitForResponse() {
-    while (!response_ready_)
+    while (!response_ready_) {
       condition_->await();
+    }
   }
 
   /**
@@ -95,16 +97,16 @@ class RequestState {
   }
 
   /**
-   * @return The producer's query for Quickstep to process.
+   * @return The producer's request for Quickstep to process.
    */
-  std::string getRequest() const {
-    return request_.query();
+  const QueryRequest& getRequest() const {
+    return request_;
   }
 
   /**
    * @return The response message from Quickstep.
    */
-  QueryResponse getResponse() const {
+  const QueryResponse& getResponse() const {
     DCHECK(response_ready_);
     return response_message_;
   }
@@ -212,12 +214,21 @@ class NetworkCliServiceImpl final : public NetworkCli::Service {
 class NetworkIOHandle final : public IOHandle {
  public:
   explicit NetworkIOHandle(RequestState* state)
-      : request_state_(state) {}
+      : request_state_(state) {
+    const std::string &data = request_state_->getRequest().data();
+    if (!data.empty()) {
+      std::fwrite(data.c_str(), 1, data.length(), in_stream_.file());
+    }
+  }
 
   ~NetworkIOHandle() override {
-      // All the commands from the last network interaction have completed, return our response.
-      // This signals to the producer thread that the interaction is complete.
-      request_state_->responseReady(out_stream_.str(), err_stream_.str());
+    // All the commands from the last network interaction have completed, return our response.
+    // This signals to the producer thread that the interaction is complete.
+    request_state_->responseReady(out_stream_.str(), err_stream_.str());
+  }
+
+  FILE* in() override {
+    return in_stream_.file();
   }
 
   FILE* out() override {
@@ -229,11 +240,11 @@ class NetworkIOHandle final : public IOHandle {
   }
 
   std::string getCommand() const override {
-    return request_state_->getRequest();
+    return request_state_->getRequest().query();
   }
 
  private:
-  MemStream out_stream_, err_stream_;
+  MemStream in_stream_, out_stream_, err_stream_;
   RequestState *request_state_;
 
   DISALLOW_COPY_AND_ASSIGN(NetworkIOHandle);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/QuickstepCli.cpp
----------------------------------------------------------------------
diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp
index e8ca56c..5db5dfc 100644
--- a/cli/QuickstepCli.cpp
+++ b/cli/QuickstepCli.cpp
@@ -305,8 +305,9 @@ int main(int argc, char* argv[]) {
   for (;;) {
     string *command_string = new string();
     std::unique_ptr<quickstep::IOHandle> io_handle(io->getNextIOHandle());
+    ScopedReassignment<FILE*> reassign_stdin(&stdin, io_handle->in());
     ScopedReassignment<FILE*> reassign_stdout(&stdout, io_handle->out());
-    ScopedReassignment<FILE*> reassign_stderr(&stderr, io_handle->err());
+//    ScopedReassignment<FILE*> reassign_stderr(&stderr, io_handle->err());
 
     *command_string = io_handle->getCommand();
     LOG(INFO) << "Command received: " << *command_string;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/quickstep/NetworkCliOuterClass.java
----------------------------------------------------------------------
diff --git a/cli/quickstep/NetworkCliOuterClass.java b/cli/quickstep/NetworkCliOuterClass.java
new file mode 100644
index 0000000..6f4e833
--- /dev/null
+++ b/cli/quickstep/NetworkCliOuterClass.java
@@ -0,0 +1,1388 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: NetworkCli.proto
+
+package quickstep;
+
+public final class NetworkCliOuterClass {
+  private NetworkCliOuterClass() {}
+  public static void registerAllExtensions(
+      com.google.protobuf.ExtensionRegistryLite registry) {
+  }
+
+  public static void registerAllExtensions(
+      com.google.protobuf.ExtensionRegistry registry) {
+    registerAllExtensions(
+        (com.google.protobuf.ExtensionRegistryLite) registry);
+  }
+  public interface QueryRequestOrBuilder extends
+      // @@protoc_insertion_point(interface_extends:quickstep.QueryRequest)
+      com.google.protobuf.MessageOrBuilder {
+
+    /**
+     * <code>string query = 1;</code>
+     */
+    java.lang.String getQuery();
+    /**
+     * <code>string query = 1;</code>
+     */
+    com.google.protobuf.ByteString
+        getQueryBytes();
+
+    /**
+     * <code>string data = 2;</code>
+     */
+    java.lang.String getData();
+    /**
+     * <code>string data = 2;</code>
+     */
+    com.google.protobuf.ByteString
+        getDataBytes();
+  }
+  /**
+   * Protobuf type {@code quickstep.QueryRequest}
+   */
+  public  static final class QueryRequest extends
+      com.google.protobuf.GeneratedMessageV3 implements
+      // @@protoc_insertion_point(message_implements:quickstep.QueryRequest)
+      QueryRequestOrBuilder {
+  private static final long serialVersionUID = 0L;
+    // Use QueryRequest.newBuilder() to construct.
+    private QueryRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
+      super(builder);
+    }
+    private QueryRequest() {
+      query_ = "";
+      data_ = "";
+    }
+
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+    getUnknownFields() {
+      return this.unknownFields;
+    }
+    private QueryRequest(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      this();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownFieldProto3(
+                  input, unknownFields, extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 10: {
+              java.lang.String s = input.readStringRequireUtf8();
+
+              query_ = s;
+              break;
+            }
+            case 18: {
+              java.lang.String s = input.readStringRequireUtf8();
+
+              data_ = s;
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw e.setUnfinishedMessage(this);
+      } catch (java.io.IOException e) {
+        throw new com.google.protobuf.InvalidProtocolBufferException(
+            e).setUnfinishedMessage(this);
+      } finally {
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryRequest_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryRequest_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              quickstep.NetworkCliOuterClass.QueryRequest.class, quickstep.NetworkCliOuterClass.QueryRequest.Builder.class);
+    }
+
+    public static final int QUERY_FIELD_NUMBER = 1;
+    private volatile java.lang.Object query_;
+    /**
+     * <code>string query = 1;</code>
+     */
+    public java.lang.String getQuery() {
+      java.lang.Object ref = query_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        query_ = s;
+        return s;
+      }
+    }
+    /**
+     * <code>string query = 1;</code>
+     */
+    public com.google.protobuf.ByteString
+        getQueryBytes() {
+      java.lang.Object ref = query_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        query_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    public static final int DATA_FIELD_NUMBER = 2;
+    private volatile java.lang.Object data_;
+    /**
+     * <code>string data = 2;</code>
+     */
+    public java.lang.String getData() {
+      java.lang.Object ref = data_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        data_ = s;
+        return s;
+      }
+    }
+    /**
+     * <code>string data = 2;</code>
+     */
+    public com.google.protobuf.ByteString
+        getDataBytes() {
+      java.lang.Object ref = data_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        data_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized == 1) return true;
+      if (isInitialized == 0) return false;
+
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      if (!getQueryBytes().isEmpty()) {
+        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, query_);
+      }
+      if (!getDataBytes().isEmpty()) {
+        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, data_);
+      }
+      unknownFields.writeTo(output);
+    }
+
+    public int getSerializedSize() {
+      int size = memoizedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      if (!getQueryBytes().isEmpty()) {
+        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, query_);
+      }
+      if (!getDataBytes().isEmpty()) {
+        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, data_);
+      }
+      size += unknownFields.getSerializedSize();
+      memoizedSize = size;
+      return size;
+    }
+
+    @java.lang.Override
+    public boolean equals(final java.lang.Object obj) {
+      if (obj == this) {
+       return true;
+      }
+      if (!(obj instanceof quickstep.NetworkCliOuterClass.QueryRequest)) {
+        return super.equals(obj);
+      }
+      quickstep.NetworkCliOuterClass.QueryRequest other = (quickstep.NetworkCliOuterClass.QueryRequest) obj;
+
+      boolean result = true;
+      result = result && getQuery()
+          .equals(other.getQuery());
+      result = result && getData()
+          .equals(other.getData());
+      result = result && unknownFields.equals(other.unknownFields);
+      return result;
+    }
+
+    @java.lang.Override
+    public int hashCode() {
+      if (memoizedHashCode != 0) {
+        return memoizedHashCode;
+      }
+      int hash = 41;
+      hash = (19 * hash) + getDescriptor().hashCode();
+      hash = (37 * hash) + QUERY_FIELD_NUMBER;
+      hash = (53 * hash) + getQuery().hashCode();
+      hash = (37 * hash) + DATA_FIELD_NUMBER;
+      hash = (53 * hash) + getData().hashCode();
+      hash = (29 * hash) + unknownFields.hashCode();
+      memoizedHashCode = hash;
+      return hash;
+    }
+
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        java.nio.ByteBuffer data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        java.nio.ByteBuffer data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseDelimitedWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryRequest parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input, extensionRegistry);
+    }
+
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder() {
+      return DEFAULT_INSTANCE.toBuilder();
+    }
+    public static Builder newBuilder(quickstep.NetworkCliOuterClass.QueryRequest prototype) {
+      return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() {
+      return this == DEFAULT_INSTANCE
+          ? new Builder() : new Builder().mergeFrom(this);
+    }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code quickstep.QueryRequest}
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+        // @@protoc_insertion_point(builder_implements:quickstep.QueryRequest)
+        quickstep.NetworkCliOuterClass.QueryRequestOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryRequest_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryRequest_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                quickstep.NetworkCliOuterClass.QueryRequest.class, quickstep.NetworkCliOuterClass.QueryRequest.Builder.class);
+      }
+
+      // Construct using quickstep.NetworkCliOuterClass.QueryRequest.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessageV3
+                .alwaysUseFieldBuilders) {
+        }
+      }
+      public Builder clear() {
+        super.clear();
+        query_ = "";
+
+        data_ = "";
+
+        return this;
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryRequest_descriptor;
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryRequest getDefaultInstanceForType() {
+        return quickstep.NetworkCliOuterClass.QueryRequest.getDefaultInstance();
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryRequest build() {
+        quickstep.NetworkCliOuterClass.QueryRequest result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryRequest buildPartial() {
+        quickstep.NetworkCliOuterClass.QueryRequest result = new quickstep.NetworkCliOuterClass.QueryRequest(this);
+        result.query_ = query_;
+        result.data_ = data_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder clone() {
+        return (Builder) super.clone();
+      }
+      public Builder setField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          java.lang.Object value) {
+        return (Builder) super.setField(field, value);
+      }
+      public Builder clearField(
+          com.google.protobuf.Descriptors.FieldDescriptor field) {
+        return (Builder) super.clearField(field);
+      }
+      public Builder clearOneof(
+          com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+        return (Builder) super.clearOneof(oneof);
+      }
+      public Builder setRepeatedField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          int index, java.lang.Object value) {
+        return (Builder) super.setRepeatedField(field, index, value);
+      }
+      public Builder addRepeatedField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          java.lang.Object value) {
+        return (Builder) super.addRepeatedField(field, value);
+      }
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof quickstep.NetworkCliOuterClass.QueryRequest) {
+          return mergeFrom((quickstep.NetworkCliOuterClass.QueryRequest)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+
+      public Builder mergeFrom(quickstep.NetworkCliOuterClass.QueryRequest other) {
+        if (other == quickstep.NetworkCliOuterClass.QueryRequest.getDefaultInstance()) return this;
+        if (!other.getQuery().isEmpty()) {
+          query_ = other.query_;
+          onChanged();
+        }
+        if (!other.getData().isEmpty()) {
+          data_ = other.data_;
+          onChanged();
+        }
+        this.mergeUnknownFields(other.unknownFields);
+        onChanged();
+        return this;
+      }
+
+      public final boolean isInitialized() {
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        quickstep.NetworkCliOuterClass.QueryRequest parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (quickstep.NetworkCliOuterClass.QueryRequest) e.getUnfinishedMessage();
+          throw e.unwrapIOException();
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
+        }
+        return this;
+      }
+
+      private java.lang.Object query_ = "";
+      /**
+       * <code>string query = 1;</code>
+       */
+      public java.lang.String getQuery() {
+        java.lang.Object ref = query_;
+        if (!(ref instanceof java.lang.String)) {
+          com.google.protobuf.ByteString bs =
+              (com.google.protobuf.ByteString) ref;
+          java.lang.String s = bs.toStringUtf8();
+          query_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>string query = 1;</code>
+       */
+      public com.google.protobuf.ByteString
+          getQueryBytes() {
+        java.lang.Object ref = query_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          query_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>string query = 1;</code>
+       */
+      public Builder setQuery(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  
+        query_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string query = 1;</code>
+       */
+      public Builder clearQuery() {
+        
+        query_ = getDefaultInstance().getQuery();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string query = 1;</code>
+       */
+      public Builder setQueryBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+        
+        query_ = value;
+        onChanged();
+        return this;
+      }
+
+      private java.lang.Object data_ = "";
+      /**
+       * <code>string data = 2;</code>
+       */
+      public java.lang.String getData() {
+        java.lang.Object ref = data_;
+        if (!(ref instanceof java.lang.String)) {
+          com.google.protobuf.ByteString bs =
+              (com.google.protobuf.ByteString) ref;
+          java.lang.String s = bs.toStringUtf8();
+          data_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>string data = 2;</code>
+       */
+      public com.google.protobuf.ByteString
+          getDataBytes() {
+        java.lang.Object ref = data_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          data_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>string data = 2;</code>
+       */
+      public Builder setData(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  
+        data_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string data = 2;</code>
+       */
+      public Builder clearData() {
+        
+        data_ = getDefaultInstance().getData();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string data = 2;</code>
+       */
+      public Builder setDataBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+        
+        data_ = value;
+        onChanged();
+        return this;
+      }
+      public final Builder setUnknownFields(
+          final com.google.protobuf.UnknownFieldSet unknownFields) {
+        return super.setUnknownFieldsProto3(unknownFields);
+      }
+
+      public final Builder mergeUnknownFields(
+          final com.google.protobuf.UnknownFieldSet unknownFields) {
+        return super.mergeUnknownFields(unknownFields);
+      }
+
+
+      // @@protoc_insertion_point(builder_scope:quickstep.QueryRequest)
+    }
+
+    // @@protoc_insertion_point(class_scope:quickstep.QueryRequest)
+    private static final quickstep.NetworkCliOuterClass.QueryRequest DEFAULT_INSTANCE;
+    static {
+      DEFAULT_INSTANCE = new quickstep.NetworkCliOuterClass.QueryRequest();
+    }
+
+    public static quickstep.NetworkCliOuterClass.QueryRequest getDefaultInstance() {
+      return DEFAULT_INSTANCE;
+    }
+
+    private static final com.google.protobuf.Parser<QueryRequest>
+        PARSER = new com.google.protobuf.AbstractParser<QueryRequest>() {
+      public QueryRequest parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+          return new QueryRequest(input, extensionRegistry);
+      }
+    };
+
+    public static com.google.protobuf.Parser<QueryRequest> parser() {
+      return PARSER;
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<QueryRequest> getParserForType() {
+      return PARSER;
+    }
+
+    public quickstep.NetworkCliOuterClass.QueryRequest getDefaultInstanceForType() {
+      return DEFAULT_INSTANCE;
+    }
+
+  }
+
+  public interface QueryResponseOrBuilder extends
+      // @@protoc_insertion_point(interface_extends:quickstep.QueryResponse)
+      com.google.protobuf.MessageOrBuilder {
+
+    /**
+     * <code>string query_result = 1;</code>
+     */
+    java.lang.String getQueryResult();
+    /**
+     * <code>string query_result = 1;</code>
+     */
+    com.google.protobuf.ByteString
+        getQueryResultBytes();
+
+    /**
+     * <code>string error_result = 2;</code>
+     */
+    java.lang.String getErrorResult();
+    /**
+     * <code>string error_result = 2;</code>
+     */
+    com.google.protobuf.ByteString
+        getErrorResultBytes();
+  }
+  /**
+   * Protobuf type {@code quickstep.QueryResponse}
+   */
+  public  static final class QueryResponse extends
+      com.google.protobuf.GeneratedMessageV3 implements
+      // @@protoc_insertion_point(message_implements:quickstep.QueryResponse)
+      QueryResponseOrBuilder {
+  private static final long serialVersionUID = 0L;
+    // Use QueryResponse.newBuilder() to construct.
+    private QueryResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
+      super(builder);
+    }
+    private QueryResponse() {
+      queryResult_ = "";
+      errorResult_ = "";
+    }
+
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+    getUnknownFields() {
+      return this.unknownFields;
+    }
+    private QueryResponse(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      this();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownFieldProto3(
+                  input, unknownFields, extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 10: {
+              java.lang.String s = input.readStringRequireUtf8();
+
+              queryResult_ = s;
+              break;
+            }
+            case 18: {
+              java.lang.String s = input.readStringRequireUtf8();
+
+              errorResult_ = s;
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw e.setUnfinishedMessage(this);
+      } catch (java.io.IOException e) {
+        throw new com.google.protobuf.InvalidProtocolBufferException(
+            e).setUnfinishedMessage(this);
+      } finally {
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryResponse_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryResponse_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              quickstep.NetworkCliOuterClass.QueryResponse.class, quickstep.NetworkCliOuterClass.QueryResponse.Builder.class);
+    }
+
+    public static final int QUERY_RESULT_FIELD_NUMBER = 1;
+    private volatile java.lang.Object queryResult_;
+    /**
+     * <code>string query_result = 1;</code>
+     */
+    public java.lang.String getQueryResult() {
+      java.lang.Object ref = queryResult_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        queryResult_ = s;
+        return s;
+      }
+    }
+    /**
+     * <code>string query_result = 1;</code>
+     */
+    public com.google.protobuf.ByteString
+        getQueryResultBytes() {
+      java.lang.Object ref = queryResult_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        queryResult_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    public static final int ERROR_RESULT_FIELD_NUMBER = 2;
+    private volatile java.lang.Object errorResult_;
+    /**
+     * <code>string error_result = 2;</code>
+     */
+    public java.lang.String getErrorResult() {
+      java.lang.Object ref = errorResult_;
+      if (ref instanceof java.lang.String) {
+        return (java.lang.String) ref;
+      } else {
+        com.google.protobuf.ByteString bs = 
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        errorResult_ = s;
+        return s;
+      }
+    }
+    /**
+     * <code>string error_result = 2;</code>
+     */
+    public com.google.protobuf.ByteString
+        getErrorResultBytes() {
+      java.lang.Object ref = errorResult_;
+      if (ref instanceof java.lang.String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        errorResult_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized == 1) return true;
+      if (isInitialized == 0) return false;
+
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      if (!getQueryResultBytes().isEmpty()) {
+        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, queryResult_);
+      }
+      if (!getErrorResultBytes().isEmpty()) {
+        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, errorResult_);
+      }
+      unknownFields.writeTo(output);
+    }
+
+    public int getSerializedSize() {
+      int size = memoizedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      if (!getQueryResultBytes().isEmpty()) {
+        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, queryResult_);
+      }
+      if (!getErrorResultBytes().isEmpty()) {
+        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, errorResult_);
+      }
+      size += unknownFields.getSerializedSize();
+      memoizedSize = size;
+      return size;
+    }
+
+    @java.lang.Override
+    public boolean equals(final java.lang.Object obj) {
+      if (obj == this) {
+       return true;
+      }
+      if (!(obj instanceof quickstep.NetworkCliOuterClass.QueryResponse)) {
+        return super.equals(obj);
+      }
+      quickstep.NetworkCliOuterClass.QueryResponse other = (quickstep.NetworkCliOuterClass.QueryResponse) obj;
+
+      boolean result = true;
+      result = result && getQueryResult()
+          .equals(other.getQueryResult());
+      result = result && getErrorResult()
+          .equals(other.getErrorResult());
+      result = result && unknownFields.equals(other.unknownFields);
+      return result;
+    }
+
+    @java.lang.Override
+    public int hashCode() {
+      if (memoizedHashCode != 0) {
+        return memoizedHashCode;
+      }
+      int hash = 41;
+      hash = (19 * hash) + getDescriptor().hashCode();
+      hash = (37 * hash) + QUERY_RESULT_FIELD_NUMBER;
+      hash = (53 * hash) + getQueryResult().hashCode();
+      hash = (37 * hash) + ERROR_RESULT_FIELD_NUMBER;
+      hash = (53 * hash) + getErrorResult().hashCode();
+      hash = (29 * hash) + unknownFields.hashCode();
+      memoizedHashCode = hash;
+      return hash;
+    }
+
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        java.nio.ByteBuffer data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        java.nio.ByteBuffer data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseDelimitedWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input);
+    }
+    public static quickstep.NetworkCliOuterClass.QueryResponse parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return com.google.protobuf.GeneratedMessageV3
+          .parseWithIOException(PARSER, input, extensionRegistry);
+    }
+
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder() {
+      return DEFAULT_INSTANCE.toBuilder();
+    }
+    public static Builder newBuilder(quickstep.NetworkCliOuterClass.QueryResponse prototype) {
+      return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() {
+      return this == DEFAULT_INSTANCE
+          ? new Builder() : new Builder().mergeFrom(this);
+    }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code quickstep.QueryResponse}
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+        // @@protoc_insertion_point(builder_implements:quickstep.QueryResponse)
+        quickstep.NetworkCliOuterClass.QueryResponseOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryResponse_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryResponse_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                quickstep.NetworkCliOuterClass.QueryResponse.class, quickstep.NetworkCliOuterClass.QueryResponse.Builder.class);
+      }
+
+      // Construct using quickstep.NetworkCliOuterClass.QueryResponse.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessageV3
+                .alwaysUseFieldBuilders) {
+        }
+      }
+      public Builder clear() {
+        super.clear();
+        queryResult_ = "";
+
+        errorResult_ = "";
+
+        return this;
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return quickstep.NetworkCliOuterClass.internal_static_quickstep_QueryResponse_descriptor;
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryResponse getDefaultInstanceForType() {
+        return quickstep.NetworkCliOuterClass.QueryResponse.getDefaultInstance();
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryResponse build() {
+        quickstep.NetworkCliOuterClass.QueryResponse result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public quickstep.NetworkCliOuterClass.QueryResponse buildPartial() {
+        quickstep.NetworkCliOuterClass.QueryResponse result = new quickstep.NetworkCliOuterClass.QueryResponse(this);
+        result.queryResult_ = queryResult_;
+        result.errorResult_ = errorResult_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder clone() {
+        return (Builder) super.clone();
+      }
+      public Builder setField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          java.lang.Object value) {
+        return (Builder) super.setField(field, value);
+      }
+      public Builder clearField(
+          com.google.protobuf.Descriptors.FieldDescriptor field) {
+        return (Builder) super.clearField(field);
+      }
+      public Builder clearOneof(
+          com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+        return (Builder) super.clearOneof(oneof);
+      }
+      public Builder setRepeatedField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          int index, java.lang.Object value) {
+        return (Builder) super.setRepeatedField(field, index, value);
+      }
+      public Builder addRepeatedField(
+          com.google.protobuf.Descriptors.FieldDescriptor field,
+          java.lang.Object value) {
+        return (Builder) super.addRepeatedField(field, value);
+      }
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof quickstep.NetworkCliOuterClass.QueryResponse) {
+          return mergeFrom((quickstep.NetworkCliOuterClass.QueryResponse)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+
+      public Builder mergeFrom(quickstep.NetworkCliOuterClass.QueryResponse other) {
+        if (other == quickstep.NetworkCliOuterClass.QueryResponse.getDefaultInstance()) return this;
+        if (!other.getQueryResult().isEmpty()) {
+          queryResult_ = other.queryResult_;
+          onChanged();
+        }
+        if (!other.getErrorResult().isEmpty()) {
+          errorResult_ = other.errorResult_;
+          onChanged();
+        }
+        this.mergeUnknownFields(other.unknownFields);
+        onChanged();
+        return this;
+      }
+
+      public final boolean isInitialized() {
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        quickstep.NetworkCliOuterClass.QueryResponse parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (quickstep.NetworkCliOuterClass.QueryResponse) e.getUnfinishedMessage();
+          throw e.unwrapIOException();
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
+        }
+        return this;
+      }
+
+      private java.lang.Object queryResult_ = "";
+      /**
+       * <code>string query_result = 1;</code>
+       */
+      public java.lang.String getQueryResult() {
+        java.lang.Object ref = queryResult_;
+        if (!(ref instanceof java.lang.String)) {
+          com.google.protobuf.ByteString bs =
+              (com.google.protobuf.ByteString) ref;
+          java.lang.String s = bs.toStringUtf8();
+          queryResult_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>string query_result = 1;</code>
+       */
+      public com.google.protobuf.ByteString
+          getQueryResultBytes() {
+        java.lang.Object ref = queryResult_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          queryResult_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>string query_result = 1;</code>
+       */
+      public Builder setQueryResult(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  
+        queryResult_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string query_result = 1;</code>
+       */
+      public Builder clearQueryResult() {
+        
+        queryResult_ = getDefaultInstance().getQueryResult();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string query_result = 1;</code>
+       */
+      public Builder setQueryResultBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+        
+        queryResult_ = value;
+        onChanged();
+        return this;
+      }
+
+      private java.lang.Object errorResult_ = "";
+      /**
+       * <code>string error_result = 2;</code>
+       */
+      public java.lang.String getErrorResult() {
+        java.lang.Object ref = errorResult_;
+        if (!(ref instanceof java.lang.String)) {
+          com.google.protobuf.ByteString bs =
+              (com.google.protobuf.ByteString) ref;
+          java.lang.String s = bs.toStringUtf8();
+          errorResult_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>string error_result = 2;</code>
+       */
+      public com.google.protobuf.ByteString
+          getErrorResultBytes() {
+        java.lang.Object ref = errorResult_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          errorResult_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>string error_result = 2;</code>
+       */
+      public Builder setErrorResult(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  
+        errorResult_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string error_result = 2;</code>
+       */
+      public Builder clearErrorResult() {
+        
+        errorResult_ = getDefaultInstance().getErrorResult();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>string error_result = 2;</code>
+       */
+      public Builder setErrorResultBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+        
+        errorResult_ = value;
+        onChanged();
+        return this;
+      }
+      public final Builder setUnknownFields(
+          final com.google.protobuf.UnknownFieldSet unknownFields) {
+        return super.setUnknownFieldsProto3(unknownFields);
+      }
+
+      public final Builder mergeUnknownFields(
+          final com.google.protobuf.UnknownFieldSet unknownFields) {
+        return super.mergeUnknownFields(unknownFields);
+      }
+
+
+      // @@protoc_insertion_point(builder_scope:quickstep.QueryResponse)
+    }
+
+    // @@protoc_insertion_point(class_scope:quickstep.QueryResponse)
+    private static final quickstep.NetworkCliOuterClass.QueryResponse DEFAULT_INSTANCE;
+    static {
+      DEFAULT_INSTANCE = new quickstep.NetworkCliOuterClass.QueryResponse();
+    }
+
+    public static quickstep.NetworkCliOuterClass.QueryResponse getDefaultInstance() {
+      return DEFAULT_INSTANCE;
+    }
+
+    private static final com.google.protobuf.Parser<QueryResponse>
+        PARSER = new com.google.protobuf.AbstractParser<QueryResponse>() {
+      public QueryResponse parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+          return new QueryResponse(input, extensionRegistry);
+      }
+    };
+
+    public static com.google.protobuf.Parser<QueryResponse> parser() {
+      return PARSER;
+    }
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<QueryResponse> getParserForType() {
+      return PARSER;
+    }
+
+    public quickstep.NetworkCliOuterClass.QueryResponse getDefaultInstanceForType() {
+      return DEFAULT_INSTANCE;
+    }
+
+  }
+
+  private static final com.google.protobuf.Descriptors.Descriptor
+    internal_static_quickstep_QueryRequest_descriptor;
+  private static final 
+    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      internal_static_quickstep_QueryRequest_fieldAccessorTable;
+  private static final com.google.protobuf.Descriptors.Descriptor
+    internal_static_quickstep_QueryResponse_descriptor;
+  private static final 
+    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      internal_static_quickstep_QueryResponse_fieldAccessorTable;
+
+  public static com.google.protobuf.Descriptors.FileDescriptor
+      getDescriptor() {
+    return descriptor;
+  }
+  private static  com.google.protobuf.Descriptors.FileDescriptor
+      descriptor;
+  static {
+    java.lang.String[] descriptorData = {
+      "\n\020NetworkCli.proto\022\tquickstep\"+\n\014QueryRe" +
+      "quest\022\r\n\005query\030\001 \001(\t\022\014\n\004data\030\002 \001(\t\";\n\rQu" +
+      "eryResponse\022\024\n\014query_result\030\001 \001(\t\022\024\n\014err" +
+      "or_result\030\002 \001(\t2N\n\nNetworkCli\022@\n\tSendQue" +
+      "ry\022\027.quickstep.QueryRequest\032\030.quickstep." +
+      "QueryResponse\"\000b\006proto3"
+    };
+    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+        new com.google.protobuf.Descriptors.FileDescriptor.    InternalDescriptorAssigner() {
+          public com.google.protobuf.ExtensionRegistry assignDescriptors(
+              com.google.protobuf.Descriptors.FileDescriptor root) {
+            descriptor = root;
+            return null;
+          }
+        };
+    com.google.protobuf.Descriptors.FileDescriptor
+      .internalBuildGeneratedFileFrom(descriptorData,
+        new com.google.protobuf.Descriptors.FileDescriptor[] {
+        }, assigner);
+    internal_static_quickstep_QueryRequest_descriptor =
+      getDescriptor().getMessageTypes().get(0);
+    internal_static_quickstep_QueryRequest_fieldAccessorTable = new
+      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+        internal_static_quickstep_QueryRequest_descriptor,
+        new java.lang.String[] { "Query", "Data", });
+    internal_static_quickstep_QueryResponse_descriptor =
+      getDescriptor().getMessageTypes().get(1);
+    internal_static_quickstep_QueryResponse_fieldAccessorTable = new
+      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+        internal_static_quickstep_QueryResponse_descriptor,
+        new java.lang.String[] { "QueryResult", "ErrorResult", });
+  }
+
+  // @@protoc_insertion_point(outer_class_scope)
+}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/cli/tests/NetworkIO_unittest.cpp
----------------------------------------------------------------------
diff --git a/cli/tests/NetworkIO_unittest.cpp b/cli/tests/NetworkIO_unittest.cpp
index 9dbd63e..9c4bfc4 100644
--- a/cli/tests/NetworkIO_unittest.cpp
+++ b/cli/tests/NetworkIO_unittest.cpp
@@ -68,7 +68,7 @@ class TestNetworkIO {
     CHECK(current_request_ == nullptr);
     current_request_ = service_.waitForRequest();
     EXPECT_EQ(current_request_->getCanceled(), false);
-    return current_request_->getRequest();
+    return current_request_->getRequest().query();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/expressions/aggregation/AggregateFunctionMax.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregateFunctionMax.cpp b/expressions/aggregation/AggregateFunctionMax.cpp
index cc04bf4..6ceacc9 100644
--- a/expressions/aggregation/AggregateFunctionMax.cpp
+++ b/expressions/aggregation/AggregateFunctionMax.cpp
@@ -50,7 +50,9 @@ const Type* AggregateFunctionMax::resultTypeForArgumentTypes(
     return nullptr;
   }
 
-  return &(argument_types.front()->getNullableVersion());
+  // FIXME(jianqiao): The result type can be nullable when it is NOT a group-by
+  // aggregation.
+  return argument_types.front();
 }
 
 AggregationHandle* AggregateFunctionMax::createHandle(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/expressions/aggregation/AggregateFunctionMin.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregateFunctionMin.cpp b/expressions/aggregation/AggregateFunctionMin.cpp
index 9fa93de..d88169f 100644
--- a/expressions/aggregation/AggregateFunctionMin.cpp
+++ b/expressions/aggregation/AggregateFunctionMin.cpp
@@ -50,7 +50,9 @@ const Type* AggregateFunctionMin::resultTypeForArgumentTypes(
     return nullptr;
   }
 
-  return &(argument_types.front()->getNullableVersion());
+  // FIXME(jianqiao): The result type can be nullable when it is NOT a group-by
+  // aggregation.
+  return argument_types.front();
 }
 
 AggregationHandle* AggregateFunctionMin::createHandle(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/SqlLexer.lpp
----------------------------------------------------------------------
diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp
index d818d0b..d6b57bf 100644
--- a/parser/SqlLexer.lpp
+++ b/parser/SqlLexer.lpp
@@ -270,6 +270,7 @@ unsigned_numeric_literal {exact_numeric_literal}|{approximate_numeric_literal}
   "sma"              return TOKEN_SMA;
   "smallint"         return TOKEN_SMALLINT;
   "stderr"           return TOKEN_STDERR;
+  "stdin"            return TOKEN_STDIN;
   "stdout"           return TOKEN_STDOUT;
   "substring"        return TOKEN_SUBSTRING;
   "table"            return TOKEN_TABLE;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b75dba28/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index ba69b3d..1a12512 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -341,6 +341,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %token TOKEN_SMA;
 %token TOKEN_SMALLINT;
 %token TOKEN_STDERR;
+%token TOKEN_STDIN;
 %token TOKEN_STDOUT;
 %token TOKEN_SUBSTRING;
 %token TOKEN_TABLE;
@@ -371,6 +372,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
   datetime_unit
   index_type
   partition_type
+  copy_from_target
   copy_to_target
 
 %type <boolean_value_>
@@ -1117,10 +1119,10 @@ insert_statement:
   ;
 
 copy_statement:
-  TOKEN_COPY any_name TOKEN_FROM TOKEN_STRING_SINGLE_QUOTED opt_copy_params {
+  TOKEN_COPY any_name copy_from_target opt_copy_params {
     $$ = new quickstep::ParseStatementCopy(@1.first_line, @1.first_column,
                                            quickstep::ParseStatementCopy::kFrom,
-                                           $2, $4, $5);
+                                           $2, $3, $4);
   }
   | TOKEN_COPY any_name copy_to_target opt_copy_params {
     $$ = new quickstep::ParseStatementCopy(@1.first_line, @1.first_column,
@@ -1136,6 +1138,15 @@ copy_statement:
                                            $3, $1, $4, $5);
   };
 
+copy_from_target:
+  TOKEN_FROM TOKEN_STRING_SINGLE_QUOTED {
+    $$ = new quickstep::ParseString($2->line_number(), $2->column_number(), "@" + $2->value());
+    delete $2;
+  }
+  | TOKEN_FROM TOKEN_STDIN {
+    $$ = new quickstep::ParseString(@2.first_line, @2.first_column, "$stdin");
+  };
+
 copy_to_target:
   TOKEN_TO TOKEN_STRING_SINGLE_QUOTED {
     $$ = new quickstep::ParseString($2->line_number(), $2->column_number(), "@" + $2->value());


[7/7] incubator-quickstep git commit: Parallel loading of in memory data

Posted by ji...@apache.org.
Parallel loading of in memory data


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

Branch: refs/heads/trace
Commit: 0bb163a7e4983797fada68ba538ea17147c29ae5
Parents: fff2fab
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Tue Dec 19 17:00:46 2017 -0600
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Fri Dec 22 21:50:48 2017 -0600

----------------------------------------------------------------------
 cli/IOInterface.hpp                             |   4 +-
 cli/LocalIO.hpp                                 |   4 +-
 cli/NetworkIO.hpp                               |  10 +-
 cli/QuickstepCli.cpp                            |   2 +-
 query_optimizer/ExecutionGenerator.cpp          |   1 +
 query_optimizer/QueryHandle.hpp                 |  14 +-
 relational_operators/TextScanOperator.cpp       | 294 ++++++++++++++-----
 relational_operators/TextScanOperator.hpp       |  64 ++++
 relational_operators/WorkOrderFactory.cpp       |   4 +
 .../tests/TextScanOperator_unittest.cpp         |   1 +
 10 files changed, 317 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/cli/IOInterface.hpp
----------------------------------------------------------------------
diff --git a/cli/IOInterface.hpp b/cli/IOInterface.hpp
index ec125f9..b9b36e1 100644
--- a/cli/IOInterface.hpp
+++ b/cli/IOInterface.hpp
@@ -40,9 +40,9 @@ class IOHandle {
   virtual ~IOHandle() {}
 
   /**
-   * @return A file handle for standard input.
+   * @return Input data.
    */
-  virtual FILE* in() = 0;
+  virtual const std::string* data() const = 0;
 
   /**
    * @return A file handle for standard output.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/cli/LocalIO.hpp
----------------------------------------------------------------------
diff --git a/cli/LocalIO.hpp b/cli/LocalIO.hpp
index 42501d2..06fa014 100644
--- a/cli/LocalIO.hpp
+++ b/cli/LocalIO.hpp
@@ -46,8 +46,8 @@ class LocalIOHandle final : public IOHandle {
 
   ~LocalIOHandle() override {}
 
-  FILE *in() override {
-    return stdin;
+  const std::string* data() const override {
+    return nullptr;
   }
 
   FILE *out() override {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/cli/NetworkIO.hpp
----------------------------------------------------------------------
diff --git a/cli/NetworkIO.hpp b/cli/NetworkIO.hpp
index e55c206..f8129b5 100644
--- a/cli/NetworkIO.hpp
+++ b/cli/NetworkIO.hpp
@@ -215,10 +215,6 @@ class NetworkIOHandle final : public IOHandle {
  public:
   explicit NetworkIOHandle(RequestState* state)
       : request_state_(state) {
-    const std::string &data = request_state_->getRequest().data();
-    if (!data.empty()) {
-      std::fwrite(data.c_str(), 1, data.length(), in_stream_.file());
-    }
   }
 
   ~NetworkIOHandle() override {
@@ -227,8 +223,8 @@ class NetworkIOHandle final : public IOHandle {
     request_state_->responseReady(out_stream_.str(), err_stream_.str());
   }
 
-  FILE* in() override {
-    return in_stream_.file();
+  const std::string* data() const override {
+    return &request_state_->getRequest().data();
   }
 
   FILE* out() override {
@@ -244,7 +240,7 @@ class NetworkIOHandle final : public IOHandle {
   }
 
  private:
-  MemStream in_stream_, out_stream_, err_stream_;
+  MemStream out_stream_, err_stream_;
   RequestState *request_state_;
 
   DISALLOW_COPY_AND_ASSIGN(NetworkIOHandle);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/cli/QuickstepCli.cpp
----------------------------------------------------------------------
diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp
index b84b13b..37e366a 100644
--- a/cli/QuickstepCli.cpp
+++ b/cli/QuickstepCli.cpp
@@ -305,7 +305,6 @@ int main(int argc, char* argv[]) {
   for (;;) {
     string *command_string = new string();
     std::unique_ptr<quickstep::IOHandle> io_handle(io->getNextIOHandle());
-    ScopedReassignment<FILE*> reassign_stdin(&stdin, io_handle->in());
     ScopedReassignment<FILE*> reassign_stdout(&stdout, io_handle->out());
 //    ScopedReassignment<FILE*> reassign_stderr(&stderr, io_handle->err());
 
@@ -361,6 +360,7 @@ int main(int argc, char* argv[]) {
           auto query_handle = std::make_unique<QueryHandle>(query_id,
                                                             main_thread_client_id,
                                                             statement.getPriority());
+          query_handle->setMemData(io_handle->data());
           query_processor->generateQueryHandle(statement, query_handle.get());
           DCHECK(query_handle->getQueryPlanMutable() != nullptr);
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index dd6efd4..dede95d 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -1169,6 +1169,7 @@ void ExecutionGenerator::convertCopyFrom(
           new TextScanOperator(
               query_handle_->query_id(),
               physical_plan->file_name(),
+              query_handle_->getMemData(),
               physical_plan->options(),
               *output_relation,
               insert_destination_index));

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/query_optimizer/QueryHandle.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryHandle.hpp b/query_optimizer/QueryHandle.hpp
index 6feeb4c..9b83074 100644
--- a/query_optimizer/QueryHandle.hpp
+++ b/query_optimizer/QueryHandle.hpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <string>
 
 #include "catalog/Catalog.pb.h"
 #include "catalog/CatalogTypedefs.hpp"
@@ -88,7 +89,8 @@ class QueryHandle {
         query_priority_(query_priority),
         analyze_query_info_(analyze_query_info),
         query_plan_(new QueryPlan()),
-        query_result_relation_(nullptr) {}
+        query_result_relation_(nullptr),
+        mem_data_(nullptr) {}
 
   ~QueryHandle() {}
 
@@ -178,6 +180,14 @@ class QueryHandle {
     query_result_relation_ = relation;
   }
 
+  const std::string* getMemData() const {
+    return mem_data_;
+  }
+
+  void setMemData(const std::string *mem_data) {
+    mem_data_ = mem_data;
+  }
+
 #ifdef QUICKSTEP_DISTRIBUTED
   /**
    * @brief Whether the query will be executed in the single node.
@@ -214,6 +224,8 @@ class QueryHandle {
   //             and deleted by the Cli shell.
   const CatalogRelation *query_result_relation_;
 
+  const std::string *mem_data_;
+
 #ifdef QUICKSTEP_DISTRIBUTED
   // Indicate whether the query should be executed on the default Shiftboss for
   // correctness purpose.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index 88b7214..86712aa 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -113,76 +113,117 @@ bool TextScanOperator::getAllWorkOrders(
   DCHECK(query_context != nullptr);
   DCHECK(!file_pattern_.empty());
 
-  if (work_generated_) {
+  if (work_generated_ && (!serial_bulk_insert_ || num_remaining_chunks_ == 0)) {
     return true;
   }
 
   InsertDestination *output_destination =
       query_context->getInsertDestination(output_destination_index_);
 
-  if (file_pattern_ == "$stdin") {
-    container->addNormalWorkOrder(
-        new TextScanWorkOrder(query_id_,
-                              file_pattern_,
-                              0,
-                              -1 /* text_segment_size */,
-                              options_->getDelimiter(),
-                              options_->escapeStrings(),
-                              output_destination),
-        op_index_);
+  if (!work_generated_) {
+    std::vector<std::string> files;
+    std::vector<std::size_t> file_sizes;
+
+    if (file_pattern_ == "$stdin") {
+      if (mem_data_ == nullptr) {
+        container->addNormalWorkOrder(
+            new TextScanWorkOrder(query_id_,
+                                  file_pattern_,
+                                  nullptr /* mem_data */,
+                                  0,
+                                  -1 /* text_segment_size */,
+                                  options_->getDelimiter(),
+                                  options_->escapeStrings(),
+                                  op_index_,
+                                  scheduler_client_id,
+                                  bus,
+                                  output_destination),
+            op_index_);
+        work_generated_ = true;
+        return true;
+      }
+      files.emplace_back(file_pattern_);
+      file_sizes.emplace_back(mem_data_->size());
+    } else {
+      DCHECK_EQ('@', file_pattern_.front());
+      files = utility::file::GlobExpand(file_pattern_.substr(1));
+
+      CHECK_NE(files.size(), 0u)
+          << "No files matched '" << file_pattern_ << "'. Exiting.";
+
+      for (const std::string &file : files) {
+  #ifdef QUICKSTEP_HAVE_UNISTD
+        // Check file permissions before trying to open it.
+        const int access_result = access(file.c_str(), R_OK);
+        CHECK_EQ(0, access_result)
+            << "File " << file << " is not readable due to permission issues.";
+  #endif  // QUICKSTEP_HAVE_UNISTD
+        file_sizes.emplace_back(GetFileSize(file));
+      }
+    }
+
+    for (std::size_t i = 0; i < files.size(); ++i) {
+      const std::string &file = files[i];
+      const std::size_t file_size = file_sizes[i];
+      for (std::size_t text_offset = 0;
+           text_offset < file_size;
+           text_offset += FLAGS_textscan_text_segment_size) {
+        const std::size_t test_size =
+            std::min(static_cast<std::size_t>(FLAGS_textscan_text_segment_size),
+                     file_size - text_offset);
+        container->addNormalWorkOrder(
+            new TextScanWorkOrder(query_id_,
+                                  file,
+                                  mem_data_,
+                                  text_offset,
+                                  test_size,
+                                  options_->getDelimiter(),
+                                  options_->escapeStrings(),
+                                  op_index_,
+                                  scheduler_client_id,
+                                  bus,
+                                  output_destination),
+            op_index_);
+        ++num_remaining_chunks_;
+      }
+    }
     work_generated_ = true;
-    return true;
   }
 
-  DCHECK_EQ('@', file_pattern_.front());
-  const std::vector<std::string> files =
-      utility::file::GlobExpand(file_pattern_.substr(1));
-
-  CHECK_NE(files.size(), 0u)
-      << "No files matched '" << file_pattern_ << "'. Exiting.";
+  // Temporary solution to the problem that there are too many blocks created
+  // for small batch bulk-insert with compressed column store.
+  if (serial_bulk_insert_ && !chunks_.empty() && serial_worker_ready_) {
+    DCHECK_LE(chunks_.size(), num_remaining_chunks_);
+    num_remaining_chunks_ -= chunks_.size();
 
-  for (const std::string &file : files) {
-#ifdef QUICKSTEP_HAVE_UNISTD
-    // Check file permissions before trying to open it.
-    const int access_result = access(file.c_str(), R_OK);
-    CHECK_EQ(0, access_result)
-        << "File " << file << " is not readable due to permission issues.";
-#endif  // QUICKSTEP_HAVE_UNISTD
+    container->addNormalWorkOrder(
+        new BulkInsertWorkOrder(query_id_,
+                                op_index_,
+                                scheduler_client_id,
+                                bus,
+                                std::move(chunks_),
+                                output_destination),
+        op_index_);
 
-    const std::size_t file_size = GetFileSize(file);
+    chunks_.clear();
+    serial_worker_ready_ = false;
+  }
 
-    std::size_t text_offset = 0;
-    for (size_t num_full_segments = file_size / FLAGS_textscan_text_segment_size;
-         num_full_segments > 0;
-         --num_full_segments, text_offset += FLAGS_textscan_text_segment_size) {
-      container->addNormalWorkOrder(
-          new TextScanWorkOrder(query_id_,
-                                file,
-                                text_offset,
-                                FLAGS_textscan_text_segment_size,
-                                options_->getDelimiter(),
-                                options_->escapeStrings(),
-                                output_destination),
-          op_index_);
-    }
+  return work_generated_ && (!serial_bulk_insert_ || num_remaining_chunks_ == 0);
+}
 
-    // Deal with the residual partial segment whose size is less than
-    // 'FLAGS_textscan_text_segment_size'.
-    if (text_offset < file_size) {
-      container->addNormalWorkOrder(
-          new TextScanWorkOrder(query_id_,
-                                file,
-                                text_offset,
-                                file_size - text_offset,
-                                options_->getDelimiter(),
-                                options_->escapeStrings(),
-                                output_destination),
-          op_index_);
-    }
+void TextScanOperator::receiveFeedbackMessage(
+    const WorkOrder::FeedbackMessage &msg) {
+  if (msg.type() == kBulkInsertCompletionMessage) {
+    serial_worker_ready_ = true;
+    return;
   }
 
-  work_generated_ = true;
-  return true;
+  DCHECK(kTextScanCompletionMessage == msg.type());
+  DCHECK(msg.payload_size() == sizeof(ColumnVectorsValueAccessor*));
+
+  chunks_.emplace_back(
+      *static_cast<ColumnVectorsValueAccessor* const*>(msg.payload()));
 }
 
 bool TextScanOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container) {
@@ -241,7 +282,11 @@ serialization::WorkOrder* TextScanOperator::createWorkOrderProto(
 void TextScanWorkOrder::execute() {
   DCHECK(!filename_.empty());
   if (filename_ == "$stdin") {
-    executeInputStream();
+    if (mem_data_ == nullptr) {
+      executeInputStream();
+    } else {
+      executeMemData();
+    }
     return;
   }
 
@@ -460,21 +505,120 @@ void TextScanWorkOrder::execute() {
   output_destination_->bulkInsertTuples(&column_vectors);
 }
 
-void TextScanWorkOrder::executeInputStream() {
-  std::string data;
-  const int len = std::ftell(stdin);
-  if (len >= 0) {
-    ScopedBuffer buffer(len, false);
-    std::rewind(stdin);
-    std::fread(buffer.get(), 1, len, stdin);
-    data = std::string(static_cast<char*>(buffer.get()), len);
+void TextScanWorkOrder::executeMemData() {
+  const CatalogRelationSchema &relation = output_destination_->getRelation();
+  std::vector<Tuple> tuples;
+  std::vector<TypedValue> row_tuple;
+  bool is_faulty;
+
+  // Locate the first newline character.
+  const char *row_ptr = mem_data_->c_str() + text_offset_;
+  const char *segment_end = row_ptr + text_segment_size_;
+  if (text_offset_ != 0) {
+    while (row_ptr < segment_end && *row_ptr != '\n') {
+      ++row_ptr;
+    }
   } else {
-    std::unique_ptr<std::ostringstream> oss = std::make_unique<std::ostringstream>();
-    *oss << std::cin.rdbuf();
-    data = oss->str();
-    oss.reset();
+    --row_ptr;
+  }
+  if (row_ptr >= segment_end) {
+    // This block does not even contain a newline character.
+    return;
+  }
+
+  // Locate the last newline character.
+  const char *end_ptr = segment_end - 1;
+  while (end_ptr > row_ptr && *end_ptr != '\n') {
+    --end_ptr;
+  }
+
+  // Advance both row_ptr and end_ptr by 1.
+  ++row_ptr;
+  ++end_ptr;
+  // Now row_ptr is pointing to the first character RIGHT AFTER the FIRST newline
+  // character in this text segment, and end_ptr is pointing to the first character
+  // RIGHT AFTER the LAST newline character in this text segment.
+
+  // Process the tuples which are between the first newline character and the
+  // last newline character. SKIP any row which is corrupt instead of ABORTING the
+  // whole COPY operation.
+  while (row_ptr < end_ptr) {
+    if (*row_ptr == '\r' || *row_ptr == '\n') {
+      // Skip empty lines.
+      ++row_ptr;
+    } else {
+      row_tuple = parseRow(&row_ptr, relation, &is_faulty);
+      if (is_faulty) {
+        // Skip faulty rows
+        LOG(INFO) << "Faulty row found. Hence switching to next row.";
+      } else {
+        // Convert vector returned to tuple only when a valid row is encountered.
+        tuples.emplace_back(Tuple(std::move(row_tuple)));
+      }
+    }
+  }
+  // Process the tuple that is right after the last newline character.
+  const char *data_end = mem_data_->c_str() + mem_data_->size();
+  while (end_ptr < data_end && *end_ptr != '\n') {
+    ++end_ptr;
+  }
+
+  std::string row_string(row_ptr, end_ptr - row_ptr);
+  if (!row_string.empty()) {
+    if (row_string.back() != '\n') {
+      row_string.push_back('\n');
+    }
+    row_ptr = row_string.c_str();
+
+    row_tuple = parseRow(&row_ptr, relation, &is_faulty);
+    if (is_faulty) {
+      // Skip the faulty row.
+      LOG(INFO) << "Faulty row found. Hence switching to next row.";
+    } else {
+      // Convert vector returned to tuple only when a valid row is encountered.
+      tuples.emplace_back(Tuple(std::move(row_tuple)));
+    }
+  }
+
+  // Store the tuples in a ColumnVectorsValueAccessor for bulk insert.
+  std::unique_ptr<ColumnVectorsValueAccessor> column_vectors =
+      std::make_unique<ColumnVectorsValueAccessor>();
+  std::size_t attr_id = 0;
+  for (const auto &attribute : relation) {
+    const Type &attr_type = attribute.getType();
+    if (attr_type.isVariableLength()) {
+      std::unique_ptr<IndirectColumnVector> column(
+          new IndirectColumnVector(attr_type, tuples.size()));
+      for (const auto &tuple : tuples) {
+        column->appendTypedValue(tuple.getAttributeValue(attr_id));
+      }
+      column_vectors->addColumn(column.release());
+    } else {
+      std::unique_ptr<NativeColumnVector> column(
+          new NativeColumnVector(attr_type, tuples.size()));
+      for (const auto &tuple : tuples) {
+        column->appendTypedValue(tuple.getAttributeValue(attr_id));
+      }
+      column_vectors->addColumn(column.release());
+    }
+    ++attr_id;
   }
 
+  FeedbackMessage msg(TextScanOperator::kTextScanCompletionMessage,
+                      getQueryID(),
+                      operator_index_,
+                      new ColumnVectorsValueAccessor*(column_vectors.release()),
+                      sizeof(ColumnVectorsValueAccessor*));
+  SendFeedbackMessage(
+      bus_, ClientIDMap::Instance()->getValue(), scheduler_client_id_, msg);
+}
+
+void TextScanWorkOrder::executeInputStream() {
+  std::unique_ptr<std::ostringstream> oss = std::make_unique<std::ostringstream>();
+  *oss << std::cin.rdbuf();
+  std::string data = oss->str();
+  oss.reset();
+
   if (data.back() != '\n') {
     data.push_back('\n');
   }
@@ -732,4 +876,18 @@ void TextScanWorkOrder::extractFieldString(const char **field_ptr,
   *field_ptr = cur_ptr + 1;
 }
 
+void BulkInsertWorkOrder::execute() {
+  for (auto &column_vectors : chunks_) {
+    output_destination_->bulkInsertTuples(column_vectors.get());
+  }
+
+  FeedbackMessage msg(TextScanOperator::kBulkInsertCompletionMessage,
+                      getQueryID(),
+                      operator_index_,
+                      new int(0) /* dumb value */,
+                      sizeof(int));
+  SendFeedbackMessage(
+      bus_, ClientIDMap::Instance()->getValue(), scheduler_client_id_, msg);
+}
+
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/relational_operators/TextScanOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.hpp b/relational_operators/TextScanOperator.hpp
index 30462d7..dfedb2b 100644
--- a/relational_operators/TextScanOperator.hpp
+++ b/relational_operators/TextScanOperator.hpp
@@ -23,6 +23,7 @@
 #include <cctype>
 #include <cstddef>
 #include <exception>
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -104,6 +105,11 @@ class TextScanFormatError : public std::exception {
  **/
 class TextScanOperator : public RelationalOperator {
  public:
+  enum FeedbackMessageType : WorkOrder::FeedbackMessageType {
+      kTextScanCompletionMessage,
+      kBulkInsertCompletionMessage
+  };
+
   /**
    * @brief Constructor.
    *
@@ -112,6 +118,7 @@ class TextScanOperator : public RelationalOperator {
    *        pattern could include * (wildcard for multiple chars) and ?
    *        (wildcard for single char). It defaults to single file load, if a
    *        file is specified.
+   * @param mem_data Incoming data that is stored in memory, maybe null.
    * @param options The options that specify the detailed format of the input
             file(s).
    * @param output_relation The output relation.
@@ -120,15 +127,20 @@ class TextScanOperator : public RelationalOperator {
    **/
   TextScanOperator(const std::size_t query_id,
                    const std::string &file_pattern,
+                   const std::string *mem_data,
                    const BulkIoConfigurationPtr &options,
                    const CatalogRelation &output_relation,
                    const QueryContext::insert_destination_id output_destination_index)
       : RelationalOperator(query_id, 1u, output_relation.getNumPartitions() != 1u /* has_repartition */,
                            output_relation.getNumPartitions()),
         file_pattern_(file_pattern),
+        mem_data_(mem_data),
         options_(options),
         output_relation_(output_relation),
         output_destination_index_(output_destination_index),
+        serial_bulk_insert_(mem_data != nullptr),
+        num_remaining_chunks_(0),
+        serial_worker_ready_(true),
         work_generated_(false) {}
 
   ~TextScanOperator() override {}
@@ -157,17 +169,25 @@ class TextScanOperator : public RelationalOperator {
     return output_relation_.getID();
   }
 
+  void receiveFeedbackMessage(const WorkOrder::FeedbackMessage &msg) override;
+
  private:
   serialization::WorkOrder* createWorkOrderProto(const std::string &filename,
                                                  const std::size_t text_offset,
                                                  const std::size_t text_segment_size);
 
   const std::string file_pattern_;
+  const std::string *mem_data_;
   const BulkIoConfigurationPtr options_;
 
   const CatalogRelation &output_relation_;
   const QueryContext::insert_destination_id output_destination_index_;
 
+  const bool serial_bulk_insert_;
+  std::vector<std::unique_ptr<ColumnVectorsValueAccessor>> chunks_;
+  std::size_t num_remaining_chunks_;
+  bool serial_worker_ready_;
+
   bool work_generated_;
 
   DISALLOW_COPY_AND_ASSIGN(TextScanOperator);
@@ -195,18 +215,26 @@ class TextScanWorkOrder : public WorkOrder {
   TextScanWorkOrder(
       const std::size_t query_id,
       const std::string &filename,
+      const std::string *mem_data,
       const std::size_t text_offset,
       const std::size_t text_segment_size,
       const char field_terminator,
       const bool process_escape_sequences,
+      const std::size_t operator_index,
+      const tmb::client_id scheduler_client_id,
+      MessageBus *bus,
       InsertDestination *output_destination,
       void *hdfs = nullptr)
       : WorkOrder(query_id),
         filename_(filename),
+        mem_data_(mem_data),
         text_offset_(text_offset),
         text_segment_size_(text_segment_size),
         field_terminator_(field_terminator),
         process_escape_sequences_(process_escape_sequences),
+        operator_index_(operator_index),
+        scheduler_client_id_(scheduler_client_id),
+        bus_(bus),
         output_destination_(DCHECK_NOTNULL(output_destination)),
         hdfs_(hdfs) {}
 
@@ -226,6 +254,7 @@ class TextScanWorkOrder : public WorkOrder {
 
  private:
   void executeInputStream();
+  void executeMemData();
 
   /**
    * @brief Extract a field string starting at \p *field_ptr. This method also
@@ -331,11 +360,16 @@ class TextScanWorkOrder : public WorkOrder {
   }
 
   const std::string filename_;
+  const std::string *mem_data_;
   const std::size_t text_offset_;
   const std::size_t text_segment_size_;
   const char field_terminator_;
   const bool process_escape_sequences_;
 
+  const std::size_t operator_index_;
+  const tmb::client_id scheduler_client_id_;
+  MessageBus *bus_;
+
   InsertDestination *output_destination_;
 
   // Not owned.
@@ -344,6 +378,36 @@ class TextScanWorkOrder : public WorkOrder {
   DISALLOW_COPY_AND_ASSIGN(TextScanWorkOrder);
 };
 
+class BulkInsertWorkOrder : public WorkOrder {
+ public:
+  BulkInsertWorkOrder(
+      const std::size_t query_id,
+      const std::size_t operator_index,
+      const tmb::client_id scheduler_client_id,
+      MessageBus *bus,
+      std::vector<std::unique_ptr<ColumnVectorsValueAccessor>> &&chunks,
+      InsertDestination *output_destination)
+      : WorkOrder(query_id),
+        operator_index_(operator_index),
+        scheduler_client_id_(scheduler_client_id),
+        bus_(bus),
+        chunks_(std::move(chunks)),
+        output_destination_(output_destination) {
+  }
+
+  void execute() override;
+
+ private:
+  const std::size_t operator_index_;
+  const tmb::client_id scheduler_client_id_;
+  MessageBus *bus_;
+
+  std::vector<std::unique_ptr<ColumnVectorsValueAccessor>> chunks_;
+  InsertDestination *output_destination_;
+
+  DISALLOW_COPY_AND_ASSIGN(BulkInsertWorkOrder);
+};
+
 /** @} */
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 7f11e3e..9eeac9e 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -554,10 +554,14 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
       return new TextScanWorkOrder(
           query_id,
           proto.GetExtension(serialization::TextScanWorkOrder::filename),
+          nullptr /* TODO */,
           proto.GetExtension(serialization::TextScanWorkOrder::text_offset),
           proto.GetExtension(serialization::TextScanWorkOrder::text_segment_size),
           proto.GetExtension(serialization::TextScanWorkOrder::field_terminator),
           proto.GetExtension(serialization::TextScanWorkOrder::process_escape_sequences),
+          0 /* TODO */,
+          0 /* TODO */,
+          nullptr /* TODO */,
           query_context->getInsertDestination(
               proto.GetExtension(serialization::TextScanWorkOrder::insert_destination_index)),
           hdfs);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0bb163a7/relational_operators/tests/TextScanOperator_unittest.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/tests/TextScanOperator_unittest.cpp b/relational_operators/tests/TextScanOperator_unittest.cpp
index 9664fda..aacc70c 100644
--- a/relational_operators/tests/TextScanOperator_unittest.cpp
+++ b/relational_operators/tests/TextScanOperator_unittest.cpp
@@ -200,6 +200,7 @@ TEST_F(TextScanOperatorTest, ScanTest) {
   std::unique_ptr<TextScanOperator> text_scan_op(
       new TextScanOperator(kQueryId,
                            input_filename,
+                           nullptr /* mem_data */,
                            BulkIoConfigurationPtr(options.release()),
                            *relation_,
                            output_destination_index));


[5/7] incubator-quickstep git commit: Improvements and bug fixes

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/CompactKeySeparateChainingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/CompactKeySeparateChainingHashTable.hpp b/storage/CompactKeySeparateChainingHashTable.hpp
new file mode 100644
index 0000000..0d057e4
--- /dev/null
+++ b/storage/CompactKeySeparateChainingHashTable.hpp
@@ -0,0 +1,234 @@
+/**
+ * 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_COMPACT_KEY_SEPARATE_CHAINING_HASH_TABLE_HPP_
+#define QUICKSTEP_STORAGE_COMPACT_KEY_SEPARATE_CHAINING_HASH_TABLE_HPP_
+
+#include <atomic>
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include "catalog/CatalogTypedefs.hpp"
+#include "cli/Flags.hpp"
+#include "storage/HashTableBase.hpp"
+#include "storage/StorageConstants.hpp"
+#include "types/Type.hpp"
+#include "types/TypeID.hpp"
+#include "utility/Macros.hpp"
+#include "utility/Range.hpp"
+#include "utility/ScopedArray.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+class AggregationHandle;
+class ColumnVectorsValueAccessor;
+class StorageManager;
+
+class CompactKeySeparateChainingHashTable : public AggregationStateHashTableBase {
+ public:
+  CompactKeySeparateChainingHashTable(
+      const std::vector<const Type*> &key_types,
+      const std::size_t num_entries,
+      const std::vector<AggregationHandle *> &handles,
+      StorageManager *storage_manager);
+
+  bool upsertValueAccessorCompositeKey(
+      const std::vector<std::vector<MultiSourceAttributeId>> &argument_ids,
+      const std::vector<MultiSourceAttributeId> &key_attr_ids,
+      const ValueAccessorMultiplexer &accessor_mux) override;
+
+  void destroyPayload() override {}
+
+  HashTableImplType getImplType() const override {
+    return HashTableImplType::kCompactKeySeparateChaining;
+  }
+
+  std::size_t getMemoryConsumptionBytes() const override {
+    return kSlotDataSize * num_slots_ + kKeyBucketDataSize * num_key_buckets_;
+  }
+
+  inline std::size_t getNumInitializationPartitions() const {
+    return slots_init_splitter_->getNumPartitions();
+  }
+
+  inline std::size_t getNumFinalizationPartitions() const {
+    if (final_splitter_ == nullptr) {
+      final_splitter_ = std::make_unique<RangeSplitter>(
+          RangeSplitter::CreateWithPartitionLength(
+              0, buckets_allocated_.load(std::memory_order_relaxed),
+              kFinalMinPartitionLength, FLAGS_num_workers * 2));
+    }
+    return final_splitter_->getNumPartitions();
+  }
+
+  void initialize(const std::size_t partition_id) {
+    const Range slots_range = slots_init_splitter_->getPartition(partition_id);
+    std::memset(slots_.get() + slots_range.begin(),
+                0,
+                slots_range.size() * kSlotDataSize);
+
+    const Range key_buckets_range =
+        key_buckets_init_splitter_->getPartition(partition_id);
+    std::memset(key_buckets_.get() + key_buckets_range.begin(),
+                0,
+                key_buckets_range.size() * kKeyBucketDataSize);
+  }
+
+  void finalizeKeys(const std::size_t partition_id,
+                    ColumnVectorsValueAccessor *output) const;
+
+ private:
+  inline static std::size_t CacheLineAlignedBytes(const std::size_t actual_bytes) {
+    return (actual_bytes + kCacheLineBytes - 1) / kCacheLineBytes * kCacheLineBytes;
+  }
+
+  inline static std::size_t CalculateNumInitializationPartitions(
+      const std::size_t memory_size) {
+    // Set initialization memory block size as 4MB.
+    constexpr std::size_t kInitBlockSize = 4uL * 1024u * 1024u;
+
+    // At least 1 partition, at most 80 partitions.
+    return std::max(1uL, std::min(memory_size / kInitBlockSize, 80uL));
+  }
+
+  inline static std::size_t CalculateNumFinalizationPartitions(
+      const std::size_t num_entries) {
+    // Set finalization segment size as 4096 entries.
+    constexpr std::size_t kFinalizeSegmentSize = 4uL * 1024L;
+
+    // At least 1 partition, at most 80 partitions.
+    return std::max(1uL, std::min(num_entries / kFinalizeSegmentSize, 80uL));
+  }
+
+  using KeyCode = std::uint64_t;
+  using BucketIndex = std::uint32_t;
+
+  inline BucketIndex locateBucketInternal(const KeyCode key_code);
+
+  template <typename ValueAccessorT>
+  inline void constructCompactKeyCodeComponent(const std::size_t num_tuples,
+                                               const std::size_t offset,
+                                               const std::size_t key_size,
+                                               ValueAccessorT *accessor,
+                                               const attribute_id attr,
+                                               KeyCode *key_codes);
+
+  static constexpr std::size_t kInitMinPartitionLength = 1024uL * 256uL;
+  static constexpr std::size_t kFinalMinPartitionLength = 1024uL * 4uL;
+
+  struct KeyBucket {
+    KeyCode key_code;
+    std::atomic<BucketIndex> next;
+  };
+
+  static constexpr std::size_t kSlotDataSize = sizeof(std::atomic<BucketIndex>);
+  static constexpr std::size_t kKeyBucketDataSize = sizeof(KeyBucket);
+  static constexpr BucketIndex kExclusiveState = std::numeric_limits<BucketIndex>::max();
+
+  const std::vector<const Type*> key_types_;
+  std::vector<std::size_t> key_sizes_;
+
+  ScopedArray<std::atomic<BucketIndex>> slots_;
+  ScopedArray<KeyBucket> key_buckets_;
+
+  std::size_t num_slots_;
+  std::size_t num_key_buckets_;
+  std::atomic<std::size_t> buckets_allocated_;
+
+  std::unique_ptr<RangeSplitter> slots_init_splitter_;
+  std::unique_ptr<RangeSplitter> key_buckets_init_splitter_;
+  mutable std::unique_ptr<RangeSplitter> final_splitter_;
+
+  DISALLOW_COPY_AND_ASSIGN(CompactKeySeparateChainingHashTable);
+};
+
+// ----------------------------------------------------------------------------
+// Implementations of class methods follow.
+
+inline CompactKeySeparateChainingHashTable::BucketIndex
+    CompactKeySeparateChainingHashTable::locateBucketInternal(const KeyCode key_code) {
+  std::atomic<BucketIndex> *pending_chain = &slots_[key_code % num_slots_];
+
+  for (;;) {
+    BucketIndex existing_chain = 0;
+
+    // Check if current node is the end of the chain.
+    if (pending_chain->compare_exchange_strong(existing_chain,
+                                               kExclusiveState,
+                                               std::memory_order_acq_rel)) {
+      const BucketIndex bucket_index =
+          buckets_allocated_.fetch_add(1, std::memory_order_relaxed);
+
+      // TODO(jianqiao): Resize.
+      if (bucket_index > num_key_buckets_) {
+        LOG(FATAL) << "Need resize, not handled";
+      }
+
+      // Store key code into key bucket.
+      key_buckets_[bucket_index].key_code = key_code;
+
+      // Update the chaing pointer to point to the new node.
+      pending_chain->store(bucket_index + 1, std::memory_order_release);
+
+      return bucket_index;
+    }
+
+    // Spin until the pointer is available.
+    while (existing_chain == kExclusiveState) {
+      existing_chain = pending_chain->load(std::memory_order_acquire);
+    }
+
+    if (existing_chain == 0) {
+      // Other thread had to roll back, so try again.
+      continue;
+    }
+
+    const BucketIndex bucket_index = existing_chain - 1;
+    KeyBucket &key_bucket = key_buckets_[bucket_index];
+    if (key_bucket.key_code == key_code) {
+      return bucket_index;
+    } else {
+      pending_chain = &key_bucket.next;
+    }
+  }
+}
+
+template <typename ValueAccessorT>
+inline void CompactKeySeparateChainingHashTable
+    ::constructCompactKeyCodeComponent(const std::size_t num_tuples,
+                                       const std::size_t offset,
+                                       const std::size_t key_size,
+                                       ValueAccessorT *accessor,
+                                       const attribute_id attr,
+                                       KeyCode *key_codes) {
+  accessor->beginIteration();
+  for (std::size_t i = 0; i < num_tuples; ++i) {
+    accessor->next();
+    std::memcpy(reinterpret_cast<char*>(key_codes + i) + offset,
+                accessor->template getUntypedValue<false>(attr),
+                key_size);
+  }
+}
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_STORAGE_COMPACT_KEY_SEPARATE_CHAINING_HASH_TABLE_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/Flags.hpp
----------------------------------------------------------------------
diff --git a/storage/Flags.hpp b/storage/Flags.hpp
index 1d5527c..87f7da4 100644
--- a/storage/Flags.hpp
+++ b/storage/Flags.hpp
@@ -41,7 +41,6 @@ DECLARE_bool(use_hdfs);
 DECLARE_string(hdfs_namenode_host);
 DECLARE_int32(hdfs_namenode_port);
 DECLARE_int32(hdfs_num_replications);
-
 #endif
 
 /** @} */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/HashTable.proto
----------------------------------------------------------------------
diff --git a/storage/HashTable.proto b/storage/HashTable.proto
index d489b9f..40c8e32 100644
--- a/storage/HashTable.proto
+++ b/storage/HashTable.proto
@@ -23,16 +23,11 @@ import "types/Type.proto";
 
 enum HashTableImplType {
   COLLISION_FREE_VECTOR = 0;
-  LINEAR_OPEN_ADDRESSING = 1;
-  SEPARATE_CHAINING = 2;
-  SIMPLE_SCALAR_SEPARATE_CHAINING = 3;
-  THREAD_PRIVATE_COMPACT_KEY = 4;
-}
-
-message CollisionFreeVectorInfo {
-  required uint64 memory_size = 1;
-  required uint64 num_init_partitions = 2;
-  repeated uint64 state_offsets = 3;
+  COMPACT_KEY_SEPARATE_CHAINING = 1;
+  LINEAR_OPEN_ADDRESSING = 2;
+  SEPARATE_CHAINING = 3;
+  SIMPLE_SCALAR_SEPARATE_CHAINING = 4;
+  THREAD_PRIVATE_COMPACT_KEY = 5;
 }
 
 // NOTE(chasseur): This proto describes the run-time parameters for a resizable

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/HashTableBase.hpp
----------------------------------------------------------------------
diff --git a/storage/HashTableBase.hpp b/storage/HashTableBase.hpp
index 4d9310c..2e89554 100644
--- a/storage/HashTableBase.hpp
+++ b/storage/HashTableBase.hpp
@@ -42,6 +42,7 @@ class ValueAccessor;
  **/
 enum class HashTableImplType {
   kCollisionFreeVector,
+  kCompactKeySeparateChaining,
   kLinearOpenAddressing,
   kSeparateChaining,
   kSimpleScalarSeparateChaining,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/HashTableFactory.hpp
----------------------------------------------------------------------
diff --git a/storage/HashTableFactory.hpp b/storage/HashTableFactory.hpp
index 732920f..df71100 100644
--- a/storage/HashTableFactory.hpp
+++ b/storage/HashTableFactory.hpp
@@ -25,6 +25,7 @@
 #include <vector>
 
 #include "storage/CollisionFreeVectorTable.hpp"
+#include "storage/CompactKeySeparateChainingHashTable.hpp"
 #include "storage/HashTable.hpp"
 #include "storage/HashTableBase.hpp"
 #include "storage/HashTable.pb.h"
@@ -118,6 +119,8 @@ inline HashTableImplType HashTableImplTypeFromProto(
   switch (proto_type) {
     case serialization::HashTableImplType::COLLISION_FREE_VECTOR:
       return HashTableImplType::kCollisionFreeVector;
+    case serialization::HashTableImplType::COMPACT_KEY_SEPARATE_CHAINING:
+      return HashTableImplType::kCompactKeySeparateChaining;
     case serialization::HashTableImplType::LINEAR_OPEN_ADDRESSING:
       return HashTableImplType::kLinearOpenAddressing;
     case serialization::HashTableImplType::SEPARATE_CHAINING:
@@ -356,14 +359,6 @@ class AggregationStateHashTableFactory {
    * @param storage_manager The StorageManager to use (a StorageBlob will be
    *        allocated to hold the hash table's contents). Forwarded as-is to the
    *        hash table constructor.
-   * @param num_partitions The number of partitions of this aggregation state
-   *        hash table.
-   * @param collision_free_vector_memory_size For CollisionFreeVectorTable,
-   *        the memory size.
-   * @param collision_free_vector_num_init_partitions For
-   *        CollisionFreeVectorTable, the number of partitions to initialize.
-   * @param collision_free_vector_state_offsets For CollisionFreeVectorTable,
-   *        the offsets for each state.
    * @return A new aggregation state hash table.
    **/
   static AggregationStateHashTableBase* CreateResizable(
@@ -371,18 +366,15 @@ class AggregationStateHashTableFactory {
       const std::vector<const Type*> &key_types,
       const std::size_t num_entries,
       const std::vector<AggregationHandle *> &handles,
-      StorageManager *storage_manager,
-      const std::size_t num_partitions = 1u,
-      const std::size_t collision_free_vector_memory_size = 0,
-      const std::size_t collision_free_vector_num_init_partitions = 0,
-      const std::vector<std::size_t> &collision_free_vector_state_offsets = std::vector<std::size_t>()) {
+      StorageManager *storage_manager) {
     switch (hash_table_type) {
       case HashTableImplType::kCollisionFreeVector:
         DCHECK_EQ(1u, key_types.size());
         return new CollisionFreeVectorTable(
-            key_types.front(), num_entries, collision_free_vector_memory_size,
-            collision_free_vector_num_init_partitions, num_partitions,
-            collision_free_vector_state_offsets, handles, storage_manager);
+            key_types.front(), num_entries, handles, storage_manager);
+      case HashTableImplType::kCompactKeySeparateChaining:
+        return new CompactKeySeparateChainingHashTable(
+            key_types, num_entries, handles, storage_manager);
       case HashTableImplType::kSeparateChaining:
         return new PackedPayloadHashTable(
             key_types, num_entries, handles, storage_manager);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/utility/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/utility/CMakeLists.txt b/utility/CMakeLists.txt
index c5c9dd8..c78ec59 100644
--- a/utility/CMakeLists.txt
+++ b/utility/CMakeLists.txt
@@ -194,6 +194,8 @@ add_library(quickstep_utility_PrimeNumber PrimeNumber.cpp PrimeNumber.hpp)
 add_library(quickstep_utility_PtrList ../empty_src.cpp PtrList.hpp)
 add_library(quickstep_utility_PtrMap ../empty_src.cpp PtrMap.hpp)
 add_library(quickstep_utility_PtrVector ../empty_src.cpp PtrVector.hpp)
+add_library(quickstep_utility_Range ../empty_src.cpp Range.hpp)
+add_library(quickstep_utility_ScopedArray ../empty_src.cpp ScopedArray.hpp)
 add_library(quickstep_utility_ScopedBuffer ../empty_src.cpp ScopedBuffer.hpp)
 add_library(quickstep_utility_ScopedDeleter ../empty_src.cpp ScopedDeleter.hpp)
 add_library(quickstep_utility_ScopedReassignment ../empty_src.cpp ScopedReassignment.hpp)
@@ -308,6 +310,12 @@ target_link_libraries(quickstep_utility_PtrMap
 target_link_libraries(quickstep_utility_PtrVector
                       glog
                       quickstep_utility_Macros)
+target_link_libraries(quickstep_utility_Range
+                      glog
+                      quickstep_utility_Macros)
+target_link_libraries(quickstep_utility_ScopedArray
+                      quickstep_utility_ScopedBuffer
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_utility_ScopedBuffer
                       glog
                       quickstep_utility_Alignment
@@ -380,6 +388,8 @@ target_link_libraries(quickstep_utility
                       quickstep_utility_PtrList
                       quickstep_utility_PtrMap
                       quickstep_utility_PtrVector
+                      quickstep_utility_Range
+                      quickstep_utility_ScopedArray
                       quickstep_utility_ScopedBuffer
                       quickstep_utility_ScopedDeleter
                       quickstep_utility_ScopedReassignment

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/utility/ExecutionDAGVisualizer.cpp
----------------------------------------------------------------------
diff --git a/utility/ExecutionDAGVisualizer.cpp b/utility/ExecutionDAGVisualizer.cpp
index f009a72..bb8fe8f 100644
--- a/utility/ExecutionDAGVisualizer.cpp
+++ b/utility/ExecutionDAGVisualizer.cpp
@@ -234,6 +234,9 @@ void ExecutionDAGVisualizer::bindProfilingStats(
         std::max(time_end[relop_index], workorder_end_time);
     time_elapsed[relop_index] += (workorder_end_time - workorder_start_time);
 
+    if (workorders_count.find(relop_index) == workorders_count.end()) {
+      workorders_count[relop_index] = 0;
+    }
     ++workorders_count[relop_index];
     if (mean_time_per_workorder.find(relop_index) ==
         mean_time_per_workorder.end()) {
@@ -289,6 +292,7 @@ void ExecutionDAGVisualizer::bindProfilingStats(
       node_info.labels.emplace_back(
           "effective concurrency: " + FormatDigits(concurrency, 2));
 
+      DCHECK(workorders_count.find(node_index) != workorders_count.end());
       const std::size_t workorders_count_for_node = workorders_count[node_index];
       if (workorders_count_for_node > 0) {
         mean_time_per_workorder[node_index] =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/utility/Range.hpp
----------------------------------------------------------------------
diff --git a/utility/Range.hpp b/utility/Range.hpp
new file mode 100644
index 0000000..4fb55be
--- /dev/null
+++ b/utility/Range.hpp
@@ -0,0 +1,188 @@
+/**
+ * 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_UTILITY_RANGE_HPP_
+#define QUICKSTEP_UTILITY_RANGE_HPP_
+
+#include <algorithm>
+#include <cstddef>
+#include <limits>
+
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+class Range {
+ public:
+  Range(const std::size_t begin, const std::size_t end)
+      : begin_(begin), end_(end) {
+    DCHECK_LE(begin_, end_);
+  }
+
+  Range(const Range &range)
+      : begin_(range.begin_), end_(range.end_) {
+    DCHECK_LE(begin_, end_);
+  }
+
+  inline std::size_t begin() const {
+    return begin_;
+  }
+
+  inline std::size_t end() const {
+    return end_;
+  }
+
+  inline std::size_t size() const {
+    return end_ - begin_;
+  }
+
+ private:
+  const std::size_t begin_;
+  const std::size_t end_;
+};
+
+class RangeSplitter {
+ public:
+  static RangeSplitter CreateWithPartitionLength(
+      const std::size_t begin,
+      const std::size_t end,
+      const std::size_t min_partition_length,
+      const std::size_t max_num_partitions = kMaxNumPartitions) {
+    DCHECK_LE(begin, end);
+    DCHECK_GT(min_partition_length, 0u);
+    DCHECK_GT(max_num_partitions, 0u);
+
+    const std::size_t range_length = end - begin;
+    const std::size_t est_num_partitions = range_length / min_partition_length;
+
+    const std::size_t num_partitions =
+        std::max(1uL, std::min(est_num_partitions, max_num_partitions));
+    const std::size_t partition_length = range_length / num_partitions;
+    return RangeSplitter(begin, end, num_partitions, partition_length);
+  }
+
+  static RangeSplitter CreateWithPartitionLength(
+      const Range &range,
+      const std::size_t min_partition_length,
+      const std::size_t max_num_partitions = kMaxNumPartitions) {
+    return CreateWithPartitionLength(
+        range.begin(), range.end(), min_partition_length, max_num_partitions);
+  }
+
+  static RangeSplitter CreateWithMinMaxPartitionLength(
+      const std::size_t begin,
+      const std::size_t end,
+      const std::size_t min_partition_length,
+      const std::size_t max_partition_length,
+      const std::size_t ept_num_partitions) {
+    DCHECK_LE(begin, end);
+    DCHECK_LE(min_partition_length, max_partition_length);
+    DCHECK_GT(min_partition_length, 0u);
+    DCHECK_GT(max_partition_length, 0u);
+
+    const std::size_t range_length = end - begin;
+    const std::size_t ept_partition_length = range_length / ept_num_partitions;
+
+    std::size_t partition_length;
+    if (ept_partition_length < min_partition_length) {
+      partition_length = min_partition_length;
+    } else if (ept_partition_length > max_partition_length) {
+      partition_length = max_partition_length;
+    } else {
+      partition_length = ept_partition_length;
+    }
+
+    const std::size_t num_partitions =
+        std::max(1uL, range_length / partition_length);
+    return RangeSplitter(begin, end, num_partitions, partition_length);
+  }
+
+  static RangeSplitter CreateWithMinMaxPartitionLength(
+      const Range &range,
+      const std::size_t min_partition_length,
+      const std::size_t max_partition_length,
+      const std::size_t ept_num_partitions) {
+    return CreateWithMinMaxPartitionLength(
+        range.begin(), range.end(),
+        min_partition_length, max_partition_length,
+        ept_num_partitions);
+  }
+
+  static RangeSplitter CreateWithNumPartitions(
+      const std::size_t begin,
+      const std::size_t end,
+      const std::size_t num_partitions) {
+    DCHECK_LE(begin, end);
+    DCHECK_GT(num_partitions, 0u);
+
+    const std::size_t partition_length = (end - begin) / num_partitions;
+    return RangeSplitter(begin, end, num_partitions, partition_length);
+  }
+
+  static RangeSplitter CreateWithNumPartitions(
+      const Range &range,
+      const std::size_t num_partitions) {
+    return CreateWithNumPartitions(range.begin(), range.end(), num_partitions);
+  }
+
+  RangeSplitter(const RangeSplitter &other)
+      : begin_(other.begin_), end_(other.end_),
+        num_partitions_(other.num_partitions_),
+        partition_length_(other.partition_length_) {}
+
+  inline std::size_t getNumPartitions() const {
+    return num_partitions_;
+  }
+
+  inline Range getPartition(const std::size_t partition_id) const {
+    DCHECK_LT(partition_id, num_partitions_);
+    const std::size_t begin = begin_ + partition_length_ * partition_id;
+    const std::size_t end =
+        partition_id == num_partitions_ - 1
+            ? end_
+            : begin + partition_length_;
+    return Range(begin, end);
+  }
+
+ private:
+  RangeSplitter(const std::size_t begin,
+                const std::size_t end,
+                const std::size_t num_partitions,
+                const std::size_t partition_length)
+      : begin_(begin),
+        end_(end),
+        num_partitions_(num_partitions),
+        partition_length_(partition_length) {
+    DCHECK_LE(num_partitions_ * partition_length_, end_);
+  }
+
+  static constexpr std::size_t kMaxNumPartitions =
+      std::numeric_limits<std::size_t>::max();
+
+  const std::size_t begin_;
+  const std::size_t end_;
+  const std::size_t num_partitions_;
+  const std::size_t partition_length_;
+};
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_UTILITY_RANGE_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/utility/ScopedArray.hpp
----------------------------------------------------------------------
diff --git a/utility/ScopedArray.hpp b/utility/ScopedArray.hpp
new file mode 100644
index 0000000..c464ba9
--- /dev/null
+++ b/utility/ScopedArray.hpp
@@ -0,0 +1,78 @@
+/**
+ * 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_UTILITY_SCOPED_ARRAY_HPP_
+#define QUICKSTEP_UTILITY_SCOPED_ARRAY_HPP_
+
+#include <cstddef>
+#include <utility>
+
+#include "utility/ScopedBuffer.hpp"
+#include "utility/Macros.hpp"
+
+namespace quickstep {
+
+template <typename T>
+class ScopedArray {
+ public:
+  explicit ScopedArray(const std::size_t length, const bool initialize = false)
+      : buffer_(length * sizeof(T), initialize) {}
+
+  explicit ScopedArray(T *data = nullptr)
+      : buffer_(data) {}
+
+  explicit ScopedArray(ScopedArray &&orig)
+      : buffer_(std::move(orig.buffer_)) {}
+
+  inline void reset(const std::size_t length, const bool initialize = false) {
+    buffer_.reset(length * sizeof(T), initialize);
+  }
+
+  inline void reset(T *data = nullptr) {
+    buffer_.reset(data);
+  }
+
+  inline ScopedArray& operator=(ScopedArray &&rhs) {
+    buffer_ = std::move(rhs.buffer_);
+    return *this;
+  }
+
+  inline T* get() const {
+    return static_cast<T*>(buffer_.get());
+  }
+
+  inline T* release() {
+    return static_cast<T*>(buffer_.release());
+  }
+
+  inline T* operator->() const {
+    return get();
+  }
+
+  inline T& operator[](const std::size_t index) const {
+    return get()[index];
+  }
+
+ private:
+  ScopedBuffer buffer_;
+};
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_UTILITY_SCOPED_ARRAY_HPP_


[6/7] incubator-quickstep git commit: Improvements and bug fixes

Posted by ji...@apache.org.
Improvements and bug fixes


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

Branch: refs/heads/trace
Commit: fff2fab35d82870b60316781f59a981ee426bc93
Parents: b75dba2
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Sat Dec 16 22:32:05 2017 -0600
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Fri Dec 22 21:50:47 2017 -0600

----------------------------------------------------------------------
 cli/QuickstepCli.cpp                            |  10 +-
 query_execution/QueryContext.hpp                |  16 ++
 query_optimizer/ExecutionGenerator.cpp          | 214 ++++++-----------
 .../cost_model/StarSchemaSimpleCostModel.cpp    |  39 +++-
 .../cost_model/StarSchemaSimpleCostModel.hpp    |   4 +-
 query_optimizer/resolver/Resolver.cpp           |   5 +-
 query_optimizer/rules/FuseAggregateJoin.cpp     |   6 -
 query_optimizer/rules/ReorderColumns.cpp        |   6 +-
 .../FinalizeAggregationOperator.cpp             |  29 +--
 .../FinalizeAggregationOperator.hpp             |   3 -
 .../InitializeAggregationOperator.cpp           |  24 +-
 .../InitializeAggregationOperator.hpp           |   7 +-
 relational_operators/InsertOperator.cpp         |  18 +-
 relational_operators/InsertOperator.hpp         |  13 +-
 relational_operators/WorkOrder.proto            |   2 +-
 relational_operators/WorkOrderFactory.cpp       |  28 ++-
 .../tests/AggregationOperator_unittest.cpp      |   2 -
 storage/AggregationOperationState.cpp           | 133 ++++++-----
 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/ExecutionDAGVisualizer.cpp              |   4 +
 utility/Range.hpp                               | 188 +++++++++++++++
 utility/ScopedArray.hpp                         |  78 +++++++
 33 files changed, 1113 insertions(+), 361 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/cli/QuickstepCli.cpp
----------------------------------------------------------------------
diff --git a/cli/QuickstepCli.cpp b/cli/QuickstepCli.cpp
index 5db5dfc..b84b13b 100644
--- a/cli/QuickstepCli.cpp
+++ b/cli/QuickstepCli.cpp
@@ -378,7 +378,15 @@ int main(int argc, char* argv[]) {
               query_handle.release(),
               &bus);
         } catch (const quickstep::SqlError &sql_error) {
-          fprintf(io_handle->err(), "%s", sql_error.formatMessage(*command_string).c_str());
+          switch (statement.getStatementType()) {
+            case ParseStatement::kDropTable:
+              // Quick hack for QuickGrail for cleaner log information
+              // since we don't have DROP TABLE IF EXISTS yet.
+              break;
+            default:
+              fprintf(io_handle->err(), "%s",
+                      sql_error.formatMessage(*command_string).c_str());
+          }
           reset_parser = true;
           break;
         }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_execution/QueryContext.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp
index 7876821..e65f096 100644
--- a/query_execution/QueryContext.hpp
+++ b/query_execution/QueryContext.hpp
@@ -489,6 +489,22 @@ class QueryContext {
   }
 
   /**
+   * @brief Whether the given vector of Tuple ids is valid.
+   *
+   * @param ids The vector of Tuple ids.
+   *
+   * @return True if valid, otherwise false.
+   **/
+  bool areValidTupleIds(const std::vector<tuple_id> &ids) const {
+    for (const tuple_id id : ids) {
+      if (id >= tuples_.size()) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
    * @brief Release the ownership of the Tuple referenced by the id.
    *
    * @note Each id should use only once.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 3bca344..dd6efd4 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<size_t>(2 * FLAGS_num_workers)));
-}
-
-void CalculateCollisionFreeAggregationInfo(
-    const size_t num_entries, const vector<pair<AggregationID, vector<const Type *>>> &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_aggr_info.first) {
-      case AggregationID::kCount: {
-        state_size = sizeof(atomic<size_t>);
-        break;
-      }
-      case AggregationID::kSum: {
-        const vector<const Type *> &argument_types = group_by_aggr_info.second;
-        DCHECK_EQ(1u, argument_types.size());
-        switch (argument_types.front()->getTypeID()) {
-          case TypeID::kInt:
-          case TypeID::kLong:
-            state_size = sizeof(atomic<std::int64_t>);
-            break;
-          case TypeID::kFloat:
-          case TypeID::kDouble:
-            state_size = sizeof(atomic<double>);
-            break;
-          default:
-            LOG(FATAL) << "No support by CollisionFreeVector";
-        }
-        break;
-      }
-      default:
-        LOG(FATAL) << "No support by CollisionFreeVector";
-    }
-
-    collision_free_vector_info->add_state_offsets(memory_size);
-    memory_size += CacheLineAlignedBytes(state_size * num_entries);
-  }
-
-  collision_free_vector_info->set_memory_size(memory_size);
-  collision_free_vector_info->set_num_init_partitions(
-      CalculateNumInitializationPartitionsForCollisionFreeVectorTable(memory_size));
-}
-
-size_t CalculateNumFinalizationPartitionsForCollisionFreeVectorTable(const size_t num_entries) {
-  // Set finalization segment size as 4096 entries.
-  constexpr size_t kFinalizeSegmentSize = 4uL * 1024L;
-
-  // At least 1 partition, at most (#workers * 2) partitions.
-  return std::max(1uL, std::min(num_entries / kFinalizeSegmentSize,
-                                static_cast<size_t>(2 * FLAGS_num_workers)));
-}
-
 bool CheckAggregatePartitioned(const std::size_t num_aggregate_functions,
                                const std::vector<bool> &is_distincts,
                                const std::vector<attribute_id> &group_by_attrs,
@@ -1212,6 +1149,7 @@ void ExecutionGenerator::convertCopyFrom(
         ->MergeFrom(output_relation->getPartitionScheme()->getProto());
   } else {
     insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
+
     const StorageBlockLayout &layout = output_relation->getDefaultStorageBlockLayout();
     const auto sub_block_type = layout.getDescription().tuple_store_description().sub_block_type();
     if (sub_block_type != TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE) {
@@ -1464,72 +1402,75 @@ void ExecutionGenerator::convertInsertTuple(
       *catalog_database_->getRelationById(
           input_relation_info->relation->getID());
 
+
+  // Construct the tuple proto to be inserted.
+  std::vector<QueryContext::tuple_id> tuple_indexes;
+
   for (const std::vector<expressions::ScalarLiteralPtr> &tuple : physical_plan->column_values()) {
-    // Construct the tuple proto to be inserted.
     const QueryContext::tuple_id tuple_index = query_context_proto_->tuples_size();
-
     S::Tuple *tuple_proto = query_context_proto_->add_tuples();
     for (const E::ScalarLiteralPtr &literal : tuple) {
       tuple_proto->add_attribute_values()->CopyFrom(literal->value().getProto());
     }
+    tuple_indexes.push_back(tuple_index);
+  }
 
-    // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
-    //               block supports ad-hoc insertion instead of hard-coding the block types.
-    const StorageBlockLayout &storage_block_layout =
-        input_relation.getDefaultStorageBlockLayout();
-    if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-        TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
-        storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-              TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
-      THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
-                        << input_relation.getName()
-                        << ", because its storage blocks do not support ad-hoc insertion";
-    }
+  // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
+  //               block supports ad-hoc insertion instead of hard-coding the block types.
+  const StorageBlockLayout &storage_block_layout =
+      input_relation.getDefaultStorageBlockLayout();
+  if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+      TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
+      storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+            TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
+    THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
+                      << input_relation.getName()
+                      << ", because its storage blocks do not support ad-hoc insertion";
+  }
 
-    // Create InsertDestination proto.
-    const QueryContext::insert_destination_id insert_destination_index =
-        query_context_proto_->insert_destinations_size();
-    S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
+  // Create InsertDestination proto.
+  const QueryContext::insert_destination_id insert_destination_index =
+      query_context_proto_->insert_destinations_size();
+  S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
 
-    insert_destination_proto->set_relation_id(input_relation.getID());
-    insert_destination_proto->mutable_layout()->MergeFrom(
-        input_relation.getDefaultStorageBlockLayout().getDescription());
+  insert_destination_proto->set_relation_id(input_relation.getID());
+  insert_destination_proto->mutable_layout()->MergeFrom(
+      input_relation.getDefaultStorageBlockLayout().getDescription());
 
-    if (input_relation.hasPartitionScheme()) {
-      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
-      insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
-          ->MergeFrom(input_relation.getPartitionScheme()->getProto());
-    } else {
-      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
+  if (input_relation.hasPartitionScheme()) {
+    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
+    insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
+        ->MergeFrom(input_relation.getPartitionScheme()->getProto());
+  } else {
+    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
 
-      const vector<block_id> blocks(input_relation.getBlocksSnapshot());
-      for (const block_id block : blocks) {
-        insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
-      }
+    const vector<block_id> blocks(input_relation.getBlocksSnapshot());
+    for (const block_id block : blocks) {
+      insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
     }
+  }
 
-    const QueryPlan::DAGNodeIndex insert_operator_index =
-        execution_plan_->addRelationalOperator(
-            new InsertOperator(query_handle_->query_id(),
-                               input_relation,
-                               insert_destination_index,
-                               tuple_index));
-    insert_destination_proto->set_relational_op_index(insert_operator_index);
+  const QueryPlan::DAGNodeIndex insert_operator_index =
+      execution_plan_->addRelationalOperator(
+          new InsertOperator(query_handle_->query_id(),
+                             input_relation,
+                             insert_destination_index,
+                             tuple_indexes));
+  insert_destination_proto->set_relational_op_index(insert_operator_index);
 
-    CatalogRelation *mutable_relation =
-        catalog_database_->getRelationByIdMutable(input_relation.getID());
-    const QueryPlan::DAGNodeIndex save_blocks_index =
-        execution_plan_->addRelationalOperator(
-            new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
-    if (!input_relation_info->isStoredRelation()) {
-      execution_plan_->addDirectDependency(insert_operator_index,
-                                           input_relation_info->producer_operator_index,
-                                           true /* is_pipeline_breaker */);
-    }
-    execution_plan_->addDirectDependency(save_blocks_index,
-                                         insert_operator_index,
-                                         false /* is_pipeline_breaker */);
+  CatalogRelation *mutable_relation =
+      catalog_database_->getRelationByIdMutable(input_relation.getID());
+  const QueryPlan::DAGNodeIndex save_blocks_index =
+      execution_plan_->addRelationalOperator(
+          new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
+  if (!input_relation_info->isStoredRelation()) {
+    execution_plan_->addDirectDependency(insert_operator_index,
+                                         input_relation_info->producer_operator_index,
+                                         true /* is_pipeline_breaker */);
   }
+  execution_plan_->addDirectDependency(save_blocks_index,
+                                       insert_operator_index,
+                                       false /* is_pipeline_breaker */);
 }
 
 void ExecutionGenerator::convertInsertSelection(
@@ -1800,8 +1741,6 @@ void ExecutionGenerator::convertAggregate(
       aggr_state_context_proto->mutable_aggregation_state();
   aggr_state_proto->set_relation_id(input_relation.getID());
 
-  bool use_parallel_initialization = false;
-
   std::vector<const Type*> group_by_types;
   std::vector<attribute_id> group_by_attrs;
   for (const E::NamedExpressionPtr &grouping_expression : physical_plan->grouping_expressions()) {
@@ -1865,27 +1804,30 @@ void ExecutionGenerator::convertAggregate(
     }
   }
 
+  bool use_parallel_initialization = false;
   bool aggr_state_is_partitioned = false;
   std::size_t aggr_state_num_partitions = 1u;
   if (!group_by_types.empty()) {
-    const std::size_t estimated_num_groups =
-        cost_model_for_aggregation_->estimateNumGroupsForAggregate(physical_plan);
-
     std::size_t max_num_groups;
     if (cost_model_for_aggregation_
             ->canUseCollisionFreeAggregation(physical_plan,
-                                             estimated_num_groups,
                                              &max_num_groups)) {
       // First option: use array-based aggregation if applicable.
       aggr_state_proto->set_hash_table_impl_type(
           serialization::HashTableImplType::COLLISION_FREE_VECTOR);
       aggr_state_proto->set_estimated_num_entries(max_num_groups);
       use_parallel_initialization = true;
-      aggr_state_num_partitions = CalculateNumFinalizationPartitionsForCollisionFreeVectorTable(max_num_groups);
-
-      CalculateCollisionFreeAggregationInfo(max_num_groups, group_by_aggrs_info,
-                                            aggr_state_proto->mutable_collision_free_vector_info());
+    } else if (cost_model_for_aggregation_
+                   ->canUseCompactKeySeparateChainingAggregation(physical_plan)) {
+      CHECK(aggregate_expressions.empty());
+      aggr_state_proto->set_hash_table_impl_type(
+          serialization::HashTableImplType::COMPACT_KEY_SEPARATE_CHAINING);
+      aggr_state_proto->set_estimated_num_entries(
+          cost_model_for_aggregation_->estimateCardinality(physical_plan->input()));
+      use_parallel_initialization = true;
     } else {
+      const std::size_t estimated_num_groups =
+          cost_model_for_aggregation_->estimateNumGroupsForAggregate(physical_plan);
       if (cost_model_for_aggregation_->canUseTwoPhaseCompactKeyAggregation(
               physical_plan, estimated_num_groups)) {
         // Second option: use thread-private compact-key aggregation if applicable.
@@ -1895,7 +1837,8 @@ void ExecutionGenerator::convertAggregate(
         // Otherwise, use SeparateChaining.
         aggr_state_proto->set_hash_table_impl_type(
             serialization::HashTableImplType::SEPARATE_CHAINING);
-        if (CheckAggregatePartitioned(aggregate_expressions.size(), is_distincts, group_by_attrs,
+        if (CheckAggregatePartitioned(aggregate_expressions.size(),
+                                      is_distincts, group_by_attrs,
                                       estimated_num_groups)) {
           aggr_state_is_partitioned = true;
           aggr_state_num_partitions = FLAGS_num_aggregation_partitions;
@@ -1930,15 +1873,12 @@ void ExecutionGenerator::convertAggregate(
   }
 
   if (use_parallel_initialization) {
-    DCHECK(aggr_state_proto->has_collision_free_vector_info());
-
     const QueryPlan::DAGNodeIndex initialize_aggregation_operator_index =
         execution_plan_->addRelationalOperator(
             new InitializeAggregationOperator(
                 query_handle_->query_id(),
                 aggr_state_index,
-                num_partitions,
-                aggr_state_proto->collision_free_vector_info().num_init_partitions()));
+                num_partitions));
 
     execution_plan_->addDirectDependency(aggregation_operator_index,
                                          initialize_aggregation_operator_index,
@@ -1960,7 +1900,6 @@ void ExecutionGenerator::convertAggregate(
                                           aggr_state_index,
                                           num_partitions,
                                           physical_plan->hasRepartition(),
-                                          aggr_state_num_partitions,
                                           *output_relation,
                                           insert_destination_index));
 
@@ -2031,10 +1970,7 @@ void ExecutionGenerator::convertCrossReferenceCoalesceAggregate(
 
   const size_t estimated_num_entries = physical_plan->group_by_key_value_range();
   aggr_state_proto->set_estimated_num_entries(estimated_num_entries);
-
-  const size_t aggr_state_num_partitions =
-      CalculateNumFinalizationPartitionsForCollisionFreeVectorTable(estimated_num_entries);
-  aggr_state_proto->set_num_partitions(aggr_state_num_partitions);
+  aggr_state_proto->set_num_partitions(1u);
 
   if (physical_plan->right_filter_predicate() != nullptr) {
     std::unique_ptr<const Predicate> predicate(
@@ -2070,16 +2006,12 @@ void ExecutionGenerator::convertCrossReferenceCoalesceAggregate(
     aggr_proto->set_is_distinct(false);
   }
 
-  CalculateCollisionFreeAggregationInfo(estimated_num_entries, group_by_aggrs_info,
-                                        aggr_state_proto->mutable_collision_free_vector_info());
-
   const QueryPlan::DAGNodeIndex initialize_aggregation_operator_index =
       execution_plan_->addRelationalOperator(
           new InitializeAggregationOperator(
               query_handle_->query_id(),
               aggr_state_index,
-              num_partitions,
-              aggr_state_proto->collision_free_vector_info().num_init_partitions()));
+              num_partitions));
 
   const QueryPlan::DAGNodeIndex build_aggregation_existence_map_operator_index =
       execution_plan_->addRelationalOperator(
@@ -2122,7 +2054,6 @@ void ExecutionGenerator::convertCrossReferenceCoalesceAggregate(
                                        build_aggregation_existence_map_operator_index,
                                        true /* is_pipeline_breaker */);
 
-
   // Create InsertDestination proto.
   const CatalogRelation *output_relation = nullptr;
   const QueryContext::insert_destination_id insert_destination_index =
@@ -2138,7 +2069,6 @@ void ExecutionGenerator::convertCrossReferenceCoalesceAggregate(
                                           aggr_state_index,
                                           num_partitions,
                                           physical_plan->hasRepartition(),
-                                          aggr_state_num_partitions,
                                           *output_relation,
                                           insert_destination_index));
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
index 2c84fc5..729a563 100644
--- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
+++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
@@ -605,7 +605,6 @@ attribute_id StarSchemaSimpleCostModel::findCatalogRelationAttributeId(
 
 bool StarSchemaSimpleCostModel::canUseCollisionFreeAggregation(
     const P::AggregatePtr &aggregate,
-    const std::size_t estimated_num_groups,
     std::size_t *max_num_groups) {
 #ifdef QUICKSTEP_DISTRIBUTED
   // Currently we cannot do this fast path with the distributed setting. See
@@ -661,7 +660,7 @@ bool StarSchemaSimpleCostModel::canUseCollisionFreeAggregation(
   //    of hardcoding it as a gflag.
   if (min_cpp_value < 0 ||
       max_cpp_value >= FLAGS_collision_free_vector_table_max_size ||
-      max_cpp_value / static_cast<double>(estimated_num_groups) > 256.0) {
+      max_cpp_value / static_cast<double>(estimateNumGroupsForAggregate(aggregate)) > 256.0) {
     return false;
   }
 
@@ -767,6 +766,42 @@ bool StarSchemaSimpleCostModel::canUseTwoPhaseCompactKeyAggregation(
   return true;
 }
 
+bool StarSchemaSimpleCostModel::canUseCompactKeySeparateChainingAggregation(
+    const P::AggregatePtr &aggregate) {
+  P::TableReferencePtr table_reference;
+  if (!P::SomeTableReference::MatchesWithConditionalCast(aggregate->input(), &table_reference)) {
+    return false;
+  }
+
+  const auto &stat = table_reference->relation()->getStatistics();
+  if (!stat.isExact() || !stat.hasNumTuples()) {
+    return false;
+  }
+
+  if (stat.getNumTuples() <= 1000u) {
+    return false;
+  }
+
+  // Require fix-length non-nullable keys that can be packed into a 64-bit QWORD.
+  std::size_t total_key_size = 0;
+  for (const auto &key_expr : aggregate->grouping_expressions()) {
+    const Type &type = key_expr->getValueType();
+    if (type.isNullable() || type.isVariableLength()) {
+      return false;
+    }
+    total_key_size += type.maximumByteLength();
+  }
+  if (total_key_size > sizeof(std::uint64_t)) {
+    return false;
+  }
+
+  if (!aggregate->aggregate_expressions().empty()) {
+    return false;
+  }
+
+  return true;
+}
+
 }  // namespace cost
 }  // namespace optimizer
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp
index 99518cf..a056866 100644
--- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp
+++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp
@@ -173,7 +173,6 @@ class StarSchemaSimpleCostModel : public CostModel {
    *        the collision-free aggregation fast path.
    *
    * @param aggregate The physical aggregate node to be checked.
-   * @param estimated_num_groups The estimated number of groups for the aggregate.
    * @param exact_num_groups If collision-free aggregation is applicable, the
    *        pointed content of this pointer will be set as the maximum possible
    *        number of groups that the collision-free hash table need to hold.
@@ -181,7 +180,6 @@ class StarSchemaSimpleCostModel : public CostModel {
    *         used to evaluate \p aggregate.
    */
   bool canUseCollisionFreeAggregation(const physical::AggregatePtr &aggregate,
-                                      const std::size_t estimated_num_groups,
                                       std::size_t *max_num_groups);
 
   /**
@@ -196,6 +194,8 @@ class StarSchemaSimpleCostModel : public CostModel {
   bool canUseTwoPhaseCompactKeyAggregation(const physical::AggregatePtr &aggregate,
                                            const std::size_t estimated_num_groups);
 
+  bool canUseCompactKeySeparateChainingAggregation(const physical::AggregatePtr &aggregate);
+
  private:
   std::size_t estimateCardinalityForAggregate(
       const physical::AggregatePtr &physical_plan);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 17198c2..02bc1fb 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -1589,7 +1589,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<E::NamedExpressionPtr> cast_expressions;
     for (std::size_t aid = 0; aid < operation_attributes.size(); ++aid) {
@@ -2107,8 +2107,7 @@ E::WindowInfo Resolver::resolveWindow(const ParseWindow &parse_window,
 const CatalogRelation* Resolver::resolveRelationName(
     const ParseString *relation_name) {
   const CatalogRelation *relation =
-      catalog_database_.getRelationByName(
-          ToLower(relation_name->value()));
+      catalog_database_.getRelationByName(ToLower(relation_name->value()));
   if (relation == nullptr) {
     THROW_SQL_ERROR_AT(relation_name) << "Unrecognized relation "
                                       << relation_name->value();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/query_optimizer/rules/FuseAggregateJoin.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/FuseAggregateJoin.cpp b/query_optimizer/rules/FuseAggregateJoin.cpp
index 6efc7e8..69e85af 100644
--- a/query_optimizer/rules/FuseAggregateJoin.cpp
+++ b/query_optimizer/rules/FuseAggregateJoin.cpp
@@ -109,23 +109,17 @@ P::PhysicalPtr FuseAggregateJoin::applyToNode(
 
   // Collision-free vector aggregation is applicable, and both the left and right
   // join attributes are range-bounded integer values.
-  const std::size_t estimated_num_groups =
-      cost_model_->estimateNumGroupsForAggregate(aggregate);
-
   std::size_t max_num_groups_left;
   if (!cost_model_->canUseCollisionFreeAggregation(aggregate,
-                                                   estimated_num_groups,
                                                    &max_num_groups_left)) {
     return node;
   }
-
   std::size_t max_num_groups_right;
   if (!cost_model_->canUseCollisionFreeAggregation(
            P::Aggregate::Create(hash_join->right(),
                                 E::ToNamedExpressions(hash_join->right_join_attributes()),
                                 aggregate->aggregate_expressions(),
                                 nullptr),
-           estimated_num_groups,
            &max_num_groups_right)) {
     return node;
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/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<P::PhysicalPtr> 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->getPhysicalType() == P::PhysicalType::kUnionAll) {
+        child_lock_ordering = true;
+      }
+      new_children.emplace_back(applyInternal(child, child_lock_ordering));
     }
 
     if (new_children != input->children()) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/FinalizeAggregationOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/FinalizeAggregationOperator.cpp b/relational_operators/FinalizeAggregationOperator.cpp
index 92fc7f6..cdba25a 100644
--- a/relational_operators/FinalizeAggregationOperator.cpp
+++ b/relational_operators/FinalizeAggregationOperator.cpp
@@ -50,7 +50,7 @@ bool FinalizeAggregationOperator::getAllWorkOrders(
         query_context->getAggregationState(aggr_state_index_, part_id);
     DCHECK(agg_state != nullptr);
     for (std::size_t state_part_id = 0;
-         state_part_id < aggr_state_num_partitions_;
+         state_part_id < agg_state->getNumFinalizationPartitions();
          ++state_part_id) {
       container->addNormalWorkOrder(
           new FinalizeAggregationWorkOrder(
@@ -68,32 +68,7 @@ bool FinalizeAggregationOperator::getAllWorkOrders(
 }
 
 bool FinalizeAggregationOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container) {
-  if (started_) {
-    return true;
-  }
-
-  for (partition_id part_id = 0; part_id < num_partitions_; ++part_id) {
-    for (std::size_t state_part_id = 0;
-         state_part_id < aggr_state_num_partitions_;
-         ++state_part_id) {
-      serialization::WorkOrder *proto = new serialization::WorkOrder;
-      proto->set_work_order_type(serialization::FINALIZE_AGGREGATION);
-      proto->set_query_id(query_id_);
-      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::aggr_state_index,
-                          aggr_state_index_);
-      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::partition_id,
-                          part_id);
-      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::state_partition_id,
-                          state_part_id);
-      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::insert_destination_index,
-                          output_destination_index_);
-
-      container->addWorkOrderProto(proto, op_index_);
-    }
-  }
-
-  started_ = true;
-  return true;
+  LOG(FATAL) << "Not supported";
 }
 
 void FinalizeAggregationWorkOrder::execute() {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/FinalizeAggregationOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/FinalizeAggregationOperator.hpp b/relational_operators/FinalizeAggregationOperator.hpp
index 5931ca2..087fad5 100644
--- a/relational_operators/FinalizeAggregationOperator.hpp
+++ b/relational_operators/FinalizeAggregationOperator.hpp
@@ -71,12 +71,10 @@ class FinalizeAggregationOperator : public RelationalOperator {
       const QueryContext::aggregation_state_id aggr_state_index,
       const std::size_t num_partitions,
       const bool has_repartition,
-      const std::size_t aggr_state_num_partitions,
       const CatalogRelation &output_relation,
       const QueryContext::insert_destination_id output_destination_index)
       : RelationalOperator(query_id, num_partitions, has_repartition, output_relation.getNumPartitions()),
         aggr_state_index_(aggr_state_index),
-        aggr_state_num_partitions_(aggr_state_num_partitions),
         output_relation_(output_relation),
         output_destination_index_(output_destination_index),
         started_(false) {
@@ -111,7 +109,6 @@ class FinalizeAggregationOperator : public RelationalOperator {
 
  private:
   const QueryContext::aggregation_state_id aggr_state_index_;
-  const std::size_t aggr_state_num_partitions_;
   const CatalogRelation &output_relation_;
   const QueryContext::insert_destination_id output_destination_index_;
   bool started_;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/InitializeAggregationOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/InitializeAggregationOperator.cpp b/relational_operators/InitializeAggregationOperator.cpp
index 89dfd7e..6bd9e8d 100644
--- a/relational_operators/InitializeAggregationOperator.cpp
+++ b/relational_operators/InitializeAggregationOperator.cpp
@@ -49,7 +49,7 @@ bool InitializeAggregationOperator::getAllWorkOrders(
     DCHECK(agg_state != nullptr);
 
     for (std::size_t state_part_id = 0;
-         state_part_id < aggr_state_num_init_partitions_;
+         state_part_id < agg_state->getNumInitializationPartitions();
          ++state_part_id) {
       container->addNormalWorkOrder(
           new InitializeAggregationWorkOrder(query_id_,
@@ -65,27 +65,7 @@ bool InitializeAggregationOperator::getAllWorkOrders(
 }
 
 bool InitializeAggregationOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container) {
-  if (started_) {
-    return true;
-  }
-
-  for (partition_id part_id = 0; part_id < num_partitions_; ++part_id) {
-    for (std::size_t state_part_id = 0;
-         state_part_id < aggr_state_num_init_partitions_;
-         ++state_part_id) {
-      serialization::WorkOrder *proto = new serialization::WorkOrder;
-      proto->set_work_order_type(serialization::INITIALIZE_AGGREGATION);
-      proto->set_query_id(query_id_);
-
-      proto->SetExtension(serialization::InitializeAggregationWorkOrder::aggr_state_index, aggr_state_index_);
-      proto->SetExtension(serialization::InitializeAggregationWorkOrder::partition_id, part_id);
-      proto->SetExtension(serialization::InitializeAggregationWorkOrder::state_partition_id, state_part_id);
-
-      container->addWorkOrderProto(proto, op_index_);
-    }
-  }
-  started_ = true;
-  return true;
+  LOG(FATAL) << "Not supported";
 }
 
 void InitializeAggregationWorkOrder::execute() {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/InitializeAggregationOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/InitializeAggregationOperator.hpp b/relational_operators/InitializeAggregationOperator.hpp
index cf9abe5..beedc14 100644
--- a/relational_operators/InitializeAggregationOperator.hpp
+++ b/relational_operators/InitializeAggregationOperator.hpp
@@ -58,16 +58,12 @@ class InitializeAggregationOperator : public RelationalOperator {
    * @param aggr_state_index The index of the AggregationOperationState in QueryContext.
    * @param num_partitions The number of partitions in 'input_relation'. If no
    *        partitions, it is one.
-   * @param aggr_state_num_init_partitions The number of partitions to be used
-   *        for initialize the aggregation state collision free vector table.
    **/
   InitializeAggregationOperator(const std::size_t query_id,
                                 const QueryContext::aggregation_state_id aggr_state_index,
-                                const std::size_t num_partitions,
-                                const std::size_t aggr_state_num_init_partitions)
+                                const std::size_t num_partitions)
       : RelationalOperator(query_id, num_partitions),
         aggr_state_index_(aggr_state_index),
-        aggr_state_num_init_partitions_(aggr_state_num_init_partitions),
         started_(false) {}
 
   ~InitializeAggregationOperator() override {}
@@ -90,7 +86,6 @@ class InitializeAggregationOperator : public RelationalOperator {
 
  private:
   const QueryContext::aggregation_state_id aggr_state_index_;
-  const std::size_t aggr_state_num_init_partitions_;
   bool started_;
 
   DISALLOW_COPY_AND_ASSIGN(InitializeAggregationOperator);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/InsertOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.cpp b/relational_operators/InsertOperator.cpp
index fbd3a07..b8c9f07 100644
--- a/relational_operators/InsertOperator.cpp
+++ b/relational_operators/InsertOperator.cpp
@@ -20,6 +20,7 @@
 #include "relational_operators/InsertOperator.hpp"
 
 #include <memory>
+#include <vector>
 
 #include "query_execution/QueryContext.hpp"
 #include "query_execution/WorkOrderProtosContainer.hpp"
@@ -43,12 +44,19 @@ bool InsertOperator::getAllWorkOrders(
     return true;
   }
 
+  std::vector<std::unique_ptr<Tuple>> tuples;
+
+  for (const QueryContext::tuple_id tuple_index : tuple_indexes_) {
+    std::unique_ptr<Tuple> newTuple(query_context->releaseTuple(tuple_index));
+    tuples.push_back(std::move(newTuple));
+  }
+
   DCHECK(query_context != nullptr);
   container->addNormalWorkOrder(
       new InsertWorkOrder(
           query_id_,
           query_context->getInsertDestination(output_destination_index_),
-          query_context->releaseTuple(tuple_index_)),
+          std::move(tuples)),
       op_index_);
 
   work_generated_ = true;
@@ -64,7 +72,9 @@ bool InsertOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container)
   proto->set_work_order_type(serialization::INSERT);
   proto->set_query_id(query_id_);
   proto->SetExtension(serialization::InsertWorkOrder::insert_destination_index, output_destination_index_);
-  proto->SetExtension(serialization::InsertWorkOrder::tuple_index, tuple_index_);
+  for (const QueryContext::tuple_id tuple_index : tuple_indexes_) {
+    proto->AddExtension(serialization::InsertWorkOrder::tuple_indexes, tuple_index);
+  }
 
   container->addWorkOrderProto(proto, op_index_);
 
@@ -74,7 +84,9 @@ bool InsertOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container)
 
 
 void InsertWorkOrder::execute() {
-  output_destination_->insertTuple(*tuple_);
+  for (const auto &tuple : tuples_) {
+    output_destination_->insertTuple(*tuple);
+  }
 }
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/InsertOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.hpp b/relational_operators/InsertOperator.hpp
index b103538..3865a7f 100644
--- a/relational_operators/InsertOperator.hpp
+++ b/relational_operators/InsertOperator.hpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <string>
 #include <memory>
+#include <vector>
 
 #include "catalog/CatalogRelation.hpp"
 #include "catalog/CatalogTypedefs.hpp"
@@ -67,11 +68,11 @@ class InsertOperator : public RelationalOperator {
       const std::size_t query_id,
       const CatalogRelation &output_relation,
       const QueryContext::insert_destination_id output_destination_index,
-      const QueryContext::tuple_id tuple_index)
+      const std::vector<QueryContext::tuple_id> &tuple_indexes)
       : RelationalOperator(query_id, 1u, false, output_relation.getNumPartitions()),
         output_relation_(output_relation),
         output_destination_index_(output_destination_index),
-        tuple_index_(tuple_index),
+        tuple_indexes_(tuple_indexes),
         work_generated_(false) {}
 
   ~InsertOperator() override {}
@@ -103,7 +104,7 @@ class InsertOperator : public RelationalOperator {
  private:
   const CatalogRelation &output_relation_;
   const QueryContext::insert_destination_id output_destination_index_;
-  const QueryContext::tuple_id tuple_index_;
+  const std::vector<QueryContext::tuple_id> tuple_indexes_;
   bool work_generated_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertOperator);
@@ -125,10 +126,10 @@ class InsertWorkOrder : public WorkOrder {
    **/
   InsertWorkOrder(const std::size_t query_id,
                   InsertDestination *output_destination,
-                  Tuple *tuple)
+                  std::vector<std::unique_ptr<Tuple>> &&tuples)
       : WorkOrder(query_id),
         output_destination_(DCHECK_NOTNULL(output_destination)),
-        tuple_(DCHECK_NOTNULL(tuple)) {}
+        tuples_(std::move(tuples)) {}
 
   ~InsertWorkOrder() override {}
 
@@ -140,7 +141,7 @@ class InsertWorkOrder : public WorkOrder {
 
  private:
   InsertDestination *output_destination_;
-  std::unique_ptr<Tuple> tuple_;
+  std::vector<std::unique_ptr<Tuple>> tuples_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertWorkOrder);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/WorkOrder.proto
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrder.proto b/relational_operators/WorkOrder.proto
index aaf7929..b84e758 100644
--- a/relational_operators/WorkOrder.proto
+++ b/relational_operators/WorkOrder.proto
@@ -201,7 +201,7 @@ message InsertWorkOrder {
   extend WorkOrder {
     // All required.
     optional int32 insert_destination_index = 176;
-    optional uint32 tuple_index = 177;
+    repeated uint32 tuple_indexes = 177;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 3a991bd..7f11e3e 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -395,12 +395,22 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
     }
     case serialization::INSERT: {
       LOG(INFO) << "Creating InsertWorkOrder for Query " << query_id << " in Shiftboss " << shiftboss_index;
+
+      const int tuple_count = proto.ExtensionSize(serialization::InsertWorkOrder::tuple_indexes);
+      std::vector<std::unique_ptr<Tuple>> tuple_indexes;
+
+      for (int specific_tuple_index = 0; specific_tuple_index < tuple_count; specific_tuple_index++) {
+        const int tuple_index =
+            proto.GetExtension(serialization::InsertWorkOrder::tuple_indexes, specific_tuple_index);
+        tuple_indexes.emplace_back(
+            std::unique_ptr<Tuple>(query_context->releaseTuple(tuple_index)));
+      }
+
       return new InsertWorkOrder(
           query_id,
           query_context->getInsertDestination(
               proto.GetExtension(serialization::InsertWorkOrder::insert_destination_index)),
-          query_context->releaseTuple(
-              proto.GetExtension(serialization::InsertWorkOrder::tuple_index)));
+              std::move(tuple_indexes));
     }
     case serialization::NESTED_LOOP_JOIN: {
       const partition_id part_id =
@@ -852,12 +862,20 @@ bool WorkOrderFactory::ProtoIsValid(const serialization::WorkOrder &proto,
              proto.HasExtension(serialization::InitializeAggregationWorkOrder::state_partition_id);
     }
     case serialization::INSERT: {
+      const int tuple_count = proto.ExtensionSize(serialization::InsertWorkOrder::tuple_indexes);
+      std::vector<QueryContext::tuple_id> tuple_indexes;
+
+      for (int specific_tuple_index = 0; specific_tuple_index < tuple_count; specific_tuple_index++) {
+        const int tuple_index =
+            proto.GetExtension(serialization::InsertWorkOrder::tuple_indexes, specific_tuple_index);
+        tuple_indexes.push_back(tuple_index);
+      }
+
       return proto.HasExtension(serialization::InsertWorkOrder::insert_destination_index) &&
              query_context.isValidInsertDestinationId(
                  proto.GetExtension(serialization::InsertWorkOrder::insert_destination_index)) &&
-             proto.HasExtension(serialization::InsertWorkOrder::tuple_index) &&
-             query_context.isValidTupleId(
-                 proto.GetExtension(serialization::InsertWorkOrder::tuple_index));
+             proto.HasExtension(serialization::InsertWorkOrder::tuple_indexes) &&
+             query_context.areValidTupleIds(tuple_indexes);
     }
     case serialization::NESTED_LOOP_JOIN: {
       if (!proto.HasExtension(serialization::NestedLoopsJoinWorkOrder::left_relation_id) ||

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/relational_operators/tests/AggregationOperator_unittest.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/tests/AggregationOperator_unittest.cpp b/relational_operators/tests/AggregationOperator_unittest.cpp
index 5c9cc7a..fa622f1 100644
--- a/relational_operators/tests/AggregationOperator_unittest.cpp
+++ b/relational_operators/tests/AggregationOperator_unittest.cpp
@@ -295,7 +295,6 @@ class AggregationOperatorTest : public ::testing::Test {
                                         aggr_state_index,
                                         kNumPartitions,
                                         kNoRepartition,
-                                        kNumPartitions,
                                         *result_table_,
                                         insert_destination_index));
 
@@ -391,7 +390,6 @@ class AggregationOperatorTest : public ::testing::Test {
                                         aggr_state_index,
                                         kNumPartitions,
                                         kNoRepartition,
-                                        kNumPartitions,
                                         *result_table_,
                                         insert_destination_index));
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/AggregationOperationState.cpp
----------------------------------------------------------------------
diff --git a/storage/AggregationOperationState.cpp b/storage/AggregationOperationState.cpp
index 9d58107..92798d8 100644
--- a/storage/AggregationOperationState.cpp
+++ b/storage/AggregationOperationState.cpp
@@ -83,14 +83,9 @@ AggregationOperationState::AggregationOperationState(
     const std::size_t num_partitions,
     const HashTableImplType hash_table_impl_type,
     const std::vector<HashTableImplType> &distinctify_hash_table_impl_types,
-    StorageManager *storage_manager,
-    const size_t collision_free_vector_memory_size,
-    const size_t collision_free_vector_num_init_partitions,
-    const vector<size_t> &collision_free_vector_state_offsets)
+    StorageManager *storage_manager)
     : input_relation_(input_relation),
-      is_aggregate_collision_free_(
-          group_by.empty() ? false
-                           : hash_table_impl_type == HashTableImplType::kCollisionFreeVector),
+      hash_table_impl_type_(hash_table_impl_type),
       is_aggregate_partitioned_(is_partitioned),
       predicate_(predicate),
       is_distinct_(std::move(is_distinct)),
@@ -209,18 +204,14 @@ AggregationOperationState::AggregationOperationState(
 
   if (!group_by_key_ids_.empty()) {
     // Aggregation with GROUP BY: create the hash table (pool).
-    if (is_aggregate_collision_free_) {
-      collision_free_hashtable_.reset(
+    if (useCollisionFreeVector() || useCompactKeySeparateChaining()) {
+      shared_hash_table_.reset(
           AggregationStateHashTableFactory::CreateResizable(
               hash_table_impl_type,
               group_by_types_,
               estimated_num_entries,
               group_by_handles,
-              storage_manager,
-              num_partitions,
-              collision_free_vector_memory_size,
-              collision_free_vector_num_init_partitions,
-              collision_free_vector_state_offsets));
+              storage_manager));
     } else if (is_aggregate_partitioned_) {
       if (all_distinct_) {
         DCHECK_EQ(1u, group_by_handles.size());
@@ -300,19 +291,6 @@ AggregationOperationState* AggregationOperationState::ReconstructFromProto(
         PredicateFactory::ReconstructFromProto(proto.predicate(), database));
   }
 
-  size_t collision_free_vector_memory_size = 0;
-  size_t collision_free_vector_num_init_partitions = 0;
-  vector<size_t> collision_free_vector_state_offsets;
-  if (proto.has_collision_free_vector_info()) {
-    const serialization::CollisionFreeVectorInfo &collision_free_vector_info =
-        proto.collision_free_vector_info();
-    collision_free_vector_memory_size = collision_free_vector_info.memory_size();
-    collision_free_vector_num_init_partitions = collision_free_vector_info.num_init_partitions();
-    for (int i = 0; i < collision_free_vector_info.state_offsets_size(); ++i) {
-      collision_free_vector_state_offsets.push_back(collision_free_vector_info.state_offsets(i));
-    }
-  }
-
   return new AggregationOperationState(
       database.getRelationSchemaById(proto.relation_id()),
       aggregate_functions,
@@ -325,10 +303,7 @@ AggregationOperationState* AggregationOperationState::ReconstructFromProto(
       proto.num_partitions(),
       HashTableImplTypeFromProto(proto.hash_table_impl_type()),
       distinctify_hash_table_impl_types,
-      storage_manager,
-      collision_free_vector_memory_size,
-      collision_free_vector_num_init_partitions,
-      collision_free_vector_state_offsets);
+      storage_manager);
 }
 
 bool AggregationOperationState::ProtoIsValid(
@@ -386,17 +361,6 @@ bool AggregationOperationState::ProtoIsValid(
             proto.hash_table_impl_type())) {
       return false;
     }
-
-    if (proto.hash_table_impl_type() == S::HashTableImplType::COLLISION_FREE_VECTOR) {
-      if (!proto.has_collision_free_vector_info()) {
-        return false;
-      }
-
-      const S::CollisionFreeVectorInfo &proto_collision_free_vector_info = proto.collision_free_vector_info();
-      if (!proto_collision_free_vector_info.IsInitialized()) {
-        return false;
-      }
-    }
   }
 
   if (proto.has_predicate()) {
@@ -410,22 +374,25 @@ bool AggregationOperationState::ProtoIsValid(
 
 CollisionFreeVectorTable* AggregationOperationState
     ::getCollisionFreeVectorTable() const {
-  return static_cast<CollisionFreeVectorTable *>(
-      collision_free_hashtable_.get());
+  return static_cast<CollisionFreeVectorTable *>(shared_hash_table_.get());
 }
 
 void AggregationOperationState::initialize(const std::size_t partition_id) {
-  if (is_aggregate_collision_free_) {
-    static_cast<CollisionFreeVectorTable *>(
-        collision_free_hashtable_.get())->initialize(partition_id);
+  if (useCollisionFreeVector()) {
+    static_cast<CollisionFreeVectorTable*>(
+        shared_hash_table_.get())->initialize(partition_id);
+  } else if (useCompactKeySeparateChaining()) {
+    static_cast<CompactKeySeparateChainingHashTable*>(
+        shared_hash_table_.get())->initialize(partition_id);
   } else {
     LOG(FATAL) << "AggregationOperationState::initialize() "
                << "is not supported by this aggregation";
   }
 }
 
-void AggregationOperationState::aggregateBlock(const block_id input_block,
-                                               LIPFilterAdaptiveProber *lip_filter_adaptive_prober) {
+void AggregationOperationState::aggregateBlock(
+    const block_id input_block,
+    LIPFilterAdaptiveProber *lip_filter_adaptive_prober) {
   BlockReference block(
       storage_manager_->getBlock(input_block, input_relation_));
   const auto &tuple_store = block->getTupleStorageSubBlock();
@@ -526,8 +493,8 @@ void AggregationOperationState::mergeGroupByHashTables(
 
 void AggregationOperationState::aggregateBlockHashTable(
     const ValueAccessorMultiplexer &accessor_mux) {
-  if (is_aggregate_collision_free_) {
-    aggregateBlockHashTableImplCollisionFree(accessor_mux);
+  if (useCollisionFreeVector() || useCompactKeySeparateChaining()) {
+    aggregateBlockHashTableImplSharedTable(accessor_mux);
   } else if (is_aggregate_partitioned_) {
     aggregateBlockHashTableImplPartitioned(accessor_mux);
   } else {
@@ -535,13 +502,13 @@ void AggregationOperationState::aggregateBlockHashTable(
   }
 }
 
-void AggregationOperationState::aggregateBlockHashTableImplCollisionFree(
+void AggregationOperationState::aggregateBlockHashTableImplSharedTable(
     const ValueAccessorMultiplexer &accessor_mux) {
-  DCHECK(collision_free_hashtable_ != nullptr);
+  DCHECK(shared_hash_table_ != nullptr);
 
-  collision_free_hashtable_->upsertValueAccessorCompositeKey(argument_ids_,
-                                                             group_by_key_ids_,
-                                                             accessor_mux);
+  shared_hash_table_->upsertValueAccessorCompositeKey(argument_ids_,
+                                                      group_by_key_ids_,
+                                                      accessor_mux);
 }
 
 void AggregationOperationState::aggregateBlockHashTableImplPartitioned(
@@ -671,8 +638,10 @@ void AggregationOperationState::finalizeSingleState(
 void AggregationOperationState::finalizeHashTable(
     const std::size_t partition_id,
     InsertDestination *output_destination) {
-  if (is_aggregate_collision_free_) {
+  if (useCollisionFreeVector()) {
     finalizeHashTableImplCollisionFree(partition_id, output_destination);
+  } else if (useCompactKeySeparateChaining()) {
+    finalizeHashTableImplCompactKeySeparateChaining(partition_id, output_destination);
   } else if (is_aggregate_partitioned_) {
     finalizeHashTableImplPartitioned(partition_id, output_destination);
   } else {
@@ -695,9 +664,8 @@ void AggregationOperationState::finalizeHashTable(
 void AggregationOperationState::finalizeHashTableImplCollisionFree(
     const std::size_t partition_id,
     InsertDestination *output_destination) {
-  std::vector<std::unique_ptr<ColumnVector>> final_values;
   CollisionFreeVectorTable *hash_table =
-      static_cast<CollisionFreeVectorTable *>(collision_free_hashtable_.get());
+      static_cast<CollisionFreeVectorTable *>(shared_hash_table_.get());
 
   const std::size_t max_length =
       hash_table->getNumTuplesInFinalizationPartition(partition_id);
@@ -726,6 +694,19 @@ void AggregationOperationState::finalizeHashTableImplCollisionFree(
   output_destination->bulkInsertTuples(&complete_result);
 }
 
+void AggregationOperationState::finalizeHashTableImplCompactKeySeparateChaining(
+    const std::size_t partition_id,
+    InsertDestination *output_destination) {
+  CompactKeySeparateChainingHashTable *hash_table =
+      static_cast<CompactKeySeparateChainingHashTable *>(shared_hash_table_.get());
+
+  ColumnVectorsValueAccessor complete_result;
+  hash_table->finalizeKeys(partition_id, &complete_result);
+
+  // Bulk-insert the complete result.
+  output_destination->bulkInsertTuples(&complete_result);
+}
+
 void AggregationOperationState::finalizeHashTableImplPartitioned(
     const std::size_t partition_id,
     InsertDestination *output_destination) {
@@ -949,8 +930,8 @@ void AggregationOperationState::finalizeHashTableImplThreadPrivateCompactKey(
 std::size_t AggregationOperationState::getMemoryConsumptionBytes() const {
   std::size_t memory = getMemoryConsumptionBytesHelper(distinctify_hashtables_);
   memory += getMemoryConsumptionBytesHelper(group_by_hashtables_);
-  if (collision_free_hashtable_ != nullptr) {
-    memory += collision_free_hashtable_->getMemoryConsumptionBytes();
+  if (shared_hash_table_ != nullptr) {
+    memory += shared_hash_table_->getMemoryConsumptionBytes();
   }
   if (group_by_hashtable_pool_ != nullptr) {
     memory += group_by_hashtable_pool_->getMemoryConsumptionPoolBytes();
@@ -973,4 +954,34 @@ std::size_t AggregationOperationState::getMemoryConsumptionBytesHelper(
   return memory;
 }
 
+std::size_t AggregationOperationState::getNumInitializationPartitions() const {
+  if (useCollisionFreeVector()) {
+    return static_cast<const CollisionFreeVectorTable*>(
+        shared_hash_table_.get())->getNumInitializationPartitions();
+  }
+  if (useCompactKeySeparateChaining()) {
+    return static_cast<const CompactKeySeparateChainingHashTable*>(
+        shared_hash_table_.get())->getNumInitializationPartitions();
+  }
+  return 0u;
+}
+
+std::size_t AggregationOperationState::getNumFinalizationPartitions() const {
+  if (group_by_key_ids_.empty()) {
+    return 1u;
+  }
+  if (useCollisionFreeVector()) {
+    return static_cast<const CollisionFreeVectorTable *>(
+        shared_hash_table_.get())->getNumFinalizationPartitions();
+  }
+  if (useCompactKeySeparateChaining()) {
+    return static_cast<const CompactKeySeparateChainingHashTable *>(
+        shared_hash_table_.get())->getNumFinalizationPartitions();
+  }
+  if (is_aggregate_partitioned_) {
+    return partitioned_group_by_hashtable_pool_->getNumPartitions();
+  }
+  return 1u;
+}
+
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/AggregationOperationState.hpp
----------------------------------------------------------------------
diff --git a/storage/AggregationOperationState.hpp b/storage/AggregationOperationState.hpp
index c7680b0..ae14dd1 100644
--- a/storage/AggregationOperationState.hpp
+++ b/storage/AggregationOperationState.hpp
@@ -108,12 +108,6 @@ class AggregationOperationState {
    * @param storage_manager The StorageManager to use for allocating hash
    *        tables. Single aggregation state (when GROUP BY list is not
    *        specified) is not allocated using memory from storage manager.
-   * @param collision_free_vector_memory_size For CollisionFreeVectorTable,
-   *        the memory size.
-   * @param collision_free_vector_num_init_partitions For
-   *        CollisionFreeVectorTable, the number of partitions to initialize.
-   * @param collision_free_vector_state_offsets For CollisionFreeVectorTable,
-   *        the offsets for each state.
    */
   AggregationOperationState(
       const CatalogRelationSchema &input_relation,
@@ -127,10 +121,7 @@ class AggregationOperationState {
       const std::size_t num_partitions,
       const HashTableImplType hash_table_impl_type,
       const std::vector<HashTableImplType> &distinctify_hash_table_impl_types,
-      StorageManager *storage_manager,
-      const std::size_t collision_free_vector_memory_size = 0,
-      const std::size_t collision_free_vector_num_init_partitions = 0,
-      const std::vector<std::size_t> &collision_free_vector_state_offsets = std::vector<std::size_t>());
+      StorageManager *storage_manager);
 
   ~AggregationOperationState() {}
 
@@ -175,6 +166,14 @@ class AggregationOperationState {
   std::size_t getNumInitializationPartitions() const;
 
   /**
+   * @brief Get the number of partitions to be used for finalizing the
+   *        aggregation.
+   *
+   * @return The number of partitions to be used for finalizing the aggregation.
+   **/
+  std::size_t getNumFinalizationPartitions() const;
+
+  /**
    * @brief Initialize the specified partition of this aggregation.
    *
    * @param partition_id ID of the partition to be initialized.
@@ -219,6 +218,14 @@ class AggregationOperationState {
   std::size_t getMemoryConsumptionBytes() const;
 
  private:
+  bool useCollisionFreeVector() const {
+    return hash_table_impl_type_ == HashTableImplType::kCollisionFreeVector;
+  }
+
+  bool useCompactKeySeparateChaining() const {
+    return hash_table_impl_type_ == HashTableImplType::kCompactKeySeparateChaining;
+  }
+
   // Aggregate on input block.
   void aggregateBlockSingleState(const ValueAccessorMultiplexer &accessor_mux);
 
@@ -239,7 +246,7 @@ class AggregationOperationState {
                          InsertDestination *output_destination);
 
   // Specialized implementations for aggregateBlockHashTable.
-  void aggregateBlockHashTableImplCollisionFree(
+  void aggregateBlockHashTableImplSharedTable(
       const ValueAccessorMultiplexer &accessor_mux);
 
   void aggregateBlockHashTableImplPartitioned(
@@ -252,6 +259,9 @@ class AggregationOperationState {
   void finalizeHashTableImplCollisionFree(const std::size_t partition_id,
                                           InsertDestination *output_destination);
 
+  void finalizeHashTableImplCompactKeySeparateChaining(const std::size_t partition_id,
+                                                       InsertDestination *output_destination);
+
   void finalizeHashTableImplPartitioned(const std::size_t partition_id,
                                         InsertDestination *output_destination);
 
@@ -269,8 +279,8 @@ class AggregationOperationState {
   // filter predicate (if any), and the list of GROUP BY expressions (if any).
   const CatalogRelationSchema &input_relation_;
 
-  // Whether the aggregation is collision free or not.
-  const bool is_aggregate_collision_free_;
+  // Hash table implementation type.
+  const HashTableImplType hash_table_impl_type_;
 
   // Whether the aggregation is partitioned or not.
   const bool is_aggregate_partitioned_;
@@ -313,7 +323,7 @@ class AggregationOperationState {
 
   std::unique_ptr<PartitionedHashTablePool> partitioned_group_by_hashtable_pool_;
 
-  std::unique_ptr<AggregationStateHashTableBase> collision_free_hashtable_;
+  std::unique_ptr<AggregationStateHashTableBase> shared_hash_table_;
 
   StorageManager *storage_manager_;
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/AggregationOperationState.proto
----------------------------------------------------------------------
diff --git a/storage/AggregationOperationState.proto b/storage/AggregationOperationState.proto
index d2305f1..1a8a302 100644
--- a/storage/AggregationOperationState.proto
+++ b/storage/AggregationOperationState.proto
@@ -45,7 +45,4 @@ message AggregationOperationState {
 
   optional bool is_partitioned = 8;
   optional uint64 num_partitions = 9 [default = 1];
-
-  // Required if 'hash_table_impl_type' is 'COLLISION_FREE_VECTOR'.
-  optional CollisionFreeVectorInfo collision_free_vector_info = 10;
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt
index fb09e49..8ac7285 100644
--- a/storage/CMakeLists.txt
+++ b/storage/CMakeLists.txt
@@ -169,6 +169,9 @@ add_library(quickstep_storage_CollisionFreeVectorTable
             CollisionFreeVectorTable.cpp
             CollisionFreeVectorTable.hpp)
 add_library(quickstep_storage_ColumnStoreUtil ColumnStoreUtil.cpp ColumnStoreUtil.hpp)
+add_library(quickstep_storage_CompactKeySeparateChainingHashTable
+            CompactKeySeparateChainingHashTable.cpp
+            CompactKeySeparateChainingHashTable.hpp)
 add_library(quickstep_storage_CompressedBlockBuilder CompressedBlockBuilder.cpp CompressedBlockBuilder.hpp)
 add_library(quickstep_storage_CompressedColumnStoreTupleStorageSubBlock
             CompressedColumnStoreTupleStorageSubBlock.cpp
@@ -474,6 +477,25 @@ target_link_libraries(quickstep_storage_ColumnStoreUtil
                       quickstep_types_operations_comparisons_ComparisonID
                       quickstep_types_operations_comparisons_ComparisonUtil
                       quickstep_utility_Macros)
+target_link_libraries(quickstep_storage_CompactKeySeparateChainingHashTable
+                      glog
+                      quickstep_catalog_CatalogTypedefs
+                      quickstep_cli_Flags
+                      quickstep_storage_HashTableBase
+                      quickstep_storage_StorageBlockInfo
+                      quickstep_storage_StorageConstants
+                      quickstep_storage_StorageManager
+                      quickstep_storage_ValueAccessor
+                      quickstep_storage_ValueAccessorUtil
+                      quickstep_types_CharType
+                      quickstep_types_Type
+                      quickstep_types_TypeID
+                      quickstep_types_containers_ColumnVector
+                      quickstep_types_containers_ColumnVectorsValueAccessor
+                      quickstep_utility_PrimeNumber
+                      quickstep_utility_Range
+                      quickstep_utility_ScopedArray
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_storage_CompressedBlockBuilder
                       quickstep_catalog_CatalogAttribute
                       quickstep_catalog_CatalogRelationSchema
@@ -721,6 +743,7 @@ target_link_libraries(quickstep_storage_HashTable_proto
 target_link_libraries(quickstep_storage_HashTableFactory
                       glog
                       quickstep_storage_CollisionFreeVectorTable
+                      quickstep_storage_CompactKeySeparateChainingHashTable
                       quickstep_storage_HashTable
                       quickstep_storage_HashTable_proto
                       quickstep_storage_HashTableBase
@@ -1146,6 +1169,7 @@ target_link_libraries(quickstep_storage
                       quickstep_storage_CSBTreeIndexSubBlock
                       quickstep_storage_CollisionFreeVectorTable
                       quickstep_storage_ColumnStoreUtil
+                      quickstep_storage_CompactKeySeparateChainingHashTable
                       quickstep_storage_CompressedBlockBuilder
                       quickstep_storage_CompressedColumnStoreTupleStorageSubBlock
                       quickstep_storage_CompressedColumnStoreValueAccessor

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/CollisionFreeVectorTable.cpp
----------------------------------------------------------------------
diff --git a/storage/CollisionFreeVectorTable.cpp b/storage/CollisionFreeVectorTable.cpp
index e803954..d836014 100644
--- a/storage/CollisionFreeVectorTable.cpp
+++ b/storage/CollisionFreeVectorTable.cpp
@@ -43,33 +43,66 @@ namespace quickstep {
 CollisionFreeVectorTable::CollisionFreeVectorTable(
     const Type *key_type,
     const std::size_t num_entries,
-    const std::size_t memory_size,
-    const std::size_t num_init_partitions,
-    const std::size_t num_finalize_partitions,
-    const std::vector<std::size_t> &state_offsets,
     const std::vector<AggregationHandle *> &handles,
     StorageManager *storage_manager)
     : key_type_(key_type),
       num_entries_(num_entries),
       num_handles_(handles.size()),
       handles_(handles),
-      memory_size_(memory_size),
-      num_init_partitions_(num_init_partitions),
-      num_finalize_partitions_(num_finalize_partitions),
+      num_finalize_partitions_(CalculateNumFinalizationPartitions(num_entries_)),
       storage_manager_(storage_manager) {
   DCHECK_GT(num_entries, 0u);
-  DCHECK_GT(num_finalize_partitions_, 0u);
-  DCHECK_EQ(num_handles_, state_offsets.size());
+
+  std::size_t required_memory = 0;
+  const std::size_t existence_map_offset = 0;
+  std::vector<std::size_t> state_offsets;
+
+  required_memory += CacheLineAlignedBytes(
+      BarrieredReadWriteConcurrentBitVector::BytesNeeded(num_entries));
+
+  for (std::size_t i = 0; i < num_handles_; ++i) {
+    const AggregationHandle *handle = handles_[i];
+    const std::vector<const Type *> argument_types = handle->getArgumentTypes();
+
+    std::size_t state_size = 0;
+    switch (handle->getAggregationID()) {
+      case AggregationID::kCount: {
+        state_size = sizeof(std::atomic<std::size_t>);
+        break;
+      }
+      case AggregationID::kSum: {
+        DCHECK_EQ(1u, argument_types.size());
+        switch (argument_types.front()->getTypeID()) {
+          case TypeID::kInt:  // Fall through
+          case TypeID::kLong:
+            state_size = sizeof(std::atomic<std::int64_t>);
+            break;
+          case TypeID::kFloat:  // Fall through
+          case TypeID::kDouble:
+            state_size = sizeof(std::atomic<double>);
+            break;
+          default:
+            LOG(FATAL) << "Not implemented";
+        }
+        break;
+      }
+      default:
+        LOG(FATAL) << "Not implemented";
+    }
+
+    state_offsets.emplace_back(required_memory);
+    required_memory += CacheLineAlignedBytes(state_size * num_entries);
+  }
 
   const std::size_t num_storage_slots =
-      storage_manager_->SlotsNeededForBytes(memory_size_);
+      storage_manager_->SlotsNeededForBytes(required_memory);
 
   const block_id blob_id = storage_manager_->createBlob(num_storage_slots);
   blob_ = storage_manager_->getBlobMutable(blob_id);
 
   void *memory_start = blob_->getMemoryMutable();
   existence_map_.reset(new BarrieredReadWriteConcurrentBitVector(
-      reinterpret_cast<char *>(memory_start),
+      reinterpret_cast<char *>(memory_start) + existence_map_offset,
       num_entries,
       false /* initialize */));
 
@@ -78,6 +111,9 @@ CollisionFreeVectorTable::CollisionFreeVectorTable(
     vec_tables_.emplace_back(
         reinterpret_cast<char *>(memory_start) + state_offsets.at(i));
   }
+
+  memory_size_ = required_memory;
+  num_init_partitions_ = CalculateNumInitializationPartitions(memory_size_);
 }
 
 CollisionFreeVectorTable::~CollisionFreeVectorTable() {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/CollisionFreeVectorTable.hpp
----------------------------------------------------------------------
diff --git a/storage/CollisionFreeVectorTable.hpp b/storage/CollisionFreeVectorTable.hpp
index 8e1342b..7a7d07e 100644
--- a/storage/CollisionFreeVectorTable.hpp
+++ b/storage/CollisionFreeVectorTable.hpp
@@ -58,12 +58,6 @@ class CollisionFreeVectorTable : public AggregationStateHashTableBase {
    *
    * @param key_type The group-by key type.
    * @param num_entries The estimated number of entries this table will hold.
-   * @param memory_size The memory size for this table.
-   * @param num_init_partitions The number of partitions to be used for
-   *        initializing the aggregation.
-   * @param num_finalize_partitions The number of partitions to be used for
-   *        finalizing the aggregation.
-   * @param state_offsets The offsets for each state in the table.
    * @param handles The aggregation handles.
    * @param storage_manager The StorageManager to use (a StorageBlob will be
    *        allocated to hold this table's contents).
@@ -71,10 +65,6 @@ class CollisionFreeVectorTable : public AggregationStateHashTableBase {
   CollisionFreeVectorTable(
       const Type *key_type,
       const std::size_t num_entries,
-      const std::size_t memory_size,
-      const std::size_t num_init_partitions,
-      const std::size_t num_finalize_partitions,
-      const std::vector<std::size_t> &state_offsets,
       const std::vector<AggregationHandle *> &handles,
       StorageManager *storage_manager);
 
@@ -188,6 +178,32 @@ class CollisionFreeVectorTable : public AggregationStateHashTableBase {
   }
 
  private:
+  inline static std::size_t CacheLineAlignedBytes(const std::size_t actual_bytes) {
+    return (actual_bytes + kCacheLineBytes - 1) / kCacheLineBytes * kCacheLineBytes;
+  }
+
+  inline static std::size_t CalculateNumInitializationPartitions(
+      const std::size_t memory_size) {
+    // Set initialization memory block size as 4MB.
+    constexpr std::size_t kInitBlockSize = 4uL * 1024u * 1024u;
+
+    // At least 1 partition, at most 80 partitions.
+    // TODO(jianqiao): set the upbound as (# of workers * 2) instead of the
+    // hardcoded 80.
+    return std::max(1uL, std::min(memory_size / kInitBlockSize, 80uL));
+  }
+
+  inline static std::size_t CalculateNumFinalizationPartitions(
+      const std::size_t num_entries) {
+    // Set finalization segment size as 4096 entries.
+    constexpr std::size_t kFinalizeSegmentSize = 4uL * 1024L;
+
+    // At least 1 partition, at most 80 partitions.
+    // TODO(jianqiao): set the upbound as (# of workers * 2) instead of the
+    // hardcoded 80.
+    return std::max(1uL, std::min(num_entries / kFinalizeSegmentSize, 80uL));
+  }
+
   inline std::size_t calculatePartitionLength() const {
     const std::size_t partition_length =
         (num_entries_ + num_finalize_partitions_ - 1) / num_finalize_partitions_;
@@ -325,9 +341,9 @@ class CollisionFreeVectorTable : public AggregationStateHashTableBase {
   std::unique_ptr<BarrieredReadWriteConcurrentBitVector> existence_map_;
   std::vector<void *> vec_tables_;
 
-  const std::size_t memory_size_;
-  const std::size_t num_init_partitions_;
-  const std::size_t num_finalize_partitions_;
+  std::size_t memory_size_;
+  std::size_t num_init_partitions_;
+  std::size_t num_finalize_partitions_;
 
   StorageManager *storage_manager_;
   MutableBlobReference blob_;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/fff2fab3/storage/CompactKeySeparateChainingHashTable.cpp
----------------------------------------------------------------------
diff --git a/storage/CompactKeySeparateChainingHashTable.cpp b/storage/CompactKeySeparateChainingHashTable.cpp
new file mode 100644
index 0000000..fd7a69f
--- /dev/null
+++ b/storage/CompactKeySeparateChainingHashTable.cpp
@@ -0,0 +1,195 @@
+/**
+ * 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/CompactKeySeparateChainingHashTable.hpp"
+
+#include <cstddef>
+#include <memory>
+#include <vector>
+#include <type_traits>
+
+#include "cli/Flags.hpp"
+#include "storage/StorageBlockInfo.hpp"
+#include "storage/StorageConstants.hpp"
+#include "storage/StorageManager.hpp"
+#include "storage/ValueAccessor.hpp"
+#include "storage/ValueAccessorUtil.hpp"
+#include "types/CharType.hpp"
+#include "types/Type.hpp"
+#include "types/TypeID.hpp"
+#include "types/containers/ColumnVector.hpp"
+#include "types/containers/ColumnVectorsValueAccessor.hpp"
+#include "utility/PrimeNumber.hpp"
+#include "utility/Range.hpp"
+#include "utility/ScopedArray.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+class AggregationHandle;
+
+namespace {
+
+template <typename Functor>
+inline auto InvokeOnKeySize(const std::size_t key_size,
+                            const Functor &functor) {
+  switch (key_size) {
+    case 0u:
+      break;
+    case 1u:
+      return functor(std::integral_constant<std::size_t, 1u>());
+    case 2u:
+      return functor(std::integral_constant<std::size_t, 2u>());
+    case 3u:
+      return functor(std::integral_constant<std::size_t, 3u>());
+    case 4u:
+      return functor(std::integral_constant<std::size_t, 4u>());
+    case 5u:
+      return functor(std::integral_constant<std::size_t, 5u>());
+    case 6u:
+      return functor(std::integral_constant<std::size_t, 6u>());
+    case 7u:
+      return functor(std::integral_constant<std::size_t, 7u>());
+    case 8u:
+      return functor(std::integral_constant<std::size_t, 8u>());
+    default:
+      break;
+  }
+  LOG(FATAL) << "Not supported";
+}
+
+}  // namespace
+
+CompactKeySeparateChainingHashTable::CompactKeySeparateChainingHashTable(
+    const std::vector<const Type*> &key_types,
+    const std::size_t num_entries,
+    const std::vector<AggregationHandle *> &handles,
+    StorageManager *storage_manager)
+    : key_types_(key_types),
+      buckets_allocated_(0) {
+  DCHECK_GT(num_entries, 0u);
+  if (!handles.empty()) {
+    LOG(FATAL) << "CompactKeySeparateChainingHashTable do not "
+               << "support aggregate functions yet";
+  }
+
+  num_slots_ = get_next_prime_number(num_entries * kHashTableLoadFactor);
+  num_key_buckets_ = num_slots_ / kHashTableLoadFactor;
+
+  // TODO: use storage manager for allocating memory.
+  slots_.reset(num_slots_);
+  key_buckets_.reset(num_key_buckets_);
+
+  std::size_t total_key_size = 0;
+  for (const Type *key_type : key_types) {
+    CHECK(!key_type->isNullable()) << "Not supported";
+    CHECK(!key_type->isVariableLength()) << "Not supported";
+
+    const std::size_t key_size = key_type->maximumByteLength();
+    key_sizes_.emplace_back(key_size);
+    total_key_size += key_size;
+  }
+
+  if (total_key_size > sizeof(KeyCode)) {
+    LOG(FATAL) << "Total key size exceeded KeyCode size";
+  }
+
+  slots_init_splitter_ = std::make_unique<RangeSplitter>(
+      RangeSplitter::CreateWithPartitionLength(
+          0, num_slots_, kInitMinPartitionLength, FLAGS_num_workers));
+
+  key_buckets_init_splitter_ = std::make_unique<RangeSplitter>(
+      RangeSplitter::CreateWithNumPartitions(
+          0, num_key_buckets_, slots_init_splitter_->getNumPartitions()));
+}
+
+bool CompactKeySeparateChainingHashTable::upsertValueAccessorCompositeKey(
+    const std::vector<std::vector<MultiSourceAttributeId>> &argument_ids,
+    const std::vector<MultiSourceAttributeId> &key_attr_ids,
+    const ValueAccessorMultiplexer &accessor_mux) {
+  DCHECK(argument_ids.empty());
+  DCHECK_EQ(key_sizes_.size(), key_attr_ids.size());
+
+  const std::size_t num_tuples =
+      accessor_mux.getValueAccessorBySource(
+          key_attr_ids.front().source)->getNumTuplesVirtual();
+
+  ScopedArray<KeyCode> key_codes(num_tuples, true);
+
+  std::size_t offset = 0;
+  for (std::size_t i = 0; i < key_sizes_.size(); ++i) {
+    const MultiSourceAttributeId &key_attr = key_attr_ids[i];
+
+    InvokeOnAnyValueAccessor(
+        accessor_mux.getValueAccessorBySource(key_attr.source),
+        [&](auto *accessor) -> void {
+
+      InvokeOnKeySize(
+          key_sizes_[i],
+          [&](auto key_size) -> void {
+        this->constructCompactKeyCodeComponent(num_tuples,
+                                               offset,
+                                               decltype(key_size)::value,
+                                               accessor,
+                                               key_attr.attr_id,
+                                               key_codes.get());
+      });
+    });
+
+    offset += key_sizes_[i];
+  }
+
+  for (std::size_t i = 0; i < num_tuples; ++i) {
+    locateBucketInternal(key_codes[i]);
+  }
+
+  return true;
+}
+
+void CompactKeySeparateChainingHashTable::finalizeKeys(
+    const std::size_t partition_id,
+    ColumnVectorsValueAccessor *output) const {
+  DCHECK(final_splitter_ != nullptr);
+  const Range range = final_splitter_->getPartition(partition_id);
+
+  std::size_t offset = 0;
+  for (std::size_t i = 0; i < key_sizes_.size(); ++i) {
+    std::unique_ptr<NativeColumnVector> cv =
+        std::make_unique<NativeColumnVector>(*key_types_[i], range.size());
+
+    InvokeOnKeySize(
+        key_sizes_[i],
+        [&](auto key_size) -> void {
+      const char *key_ptr =
+          reinterpret_cast<const char*>(&key_buckets_[range.begin()].key_code) + offset;
+      for (std::size_t j = 0; j < range.size(); ++j) {
+        std::memcpy(cv->getPtrForDirectWrite(),
+                    key_ptr,
+                    decltype(key_size)::value);
+        key_ptr += kKeyBucketDataSize;
+      }
+    });
+
+    output->addColumn(ColumnVectorPtr(cv.release()));
+    offset += key_sizes_[i];
+  }
+}
+
+}  // namespace quickstep