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

2017-12-22 Thread jianqiao
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 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 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(physical_plan);
   const CatalogRelationStatistics &stat =
   table_reference->relation()->getStatistics();
-  if (stat.hasNumTuples()) {
+  if (stat.isExact(

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

2017-12-22 Thread jianqiao
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 
Authored: Tue Dec 19 17:00:46 2017 -0600
Committer: Jianqiao Zhu 
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 io_handle(io->getNextIOHandle());
-ScopedReassignment reassign_stdin(&stdin, io_handle->in());
 ScopedReassignment reassign_stdout(&stdout, io_handle->out());
 //ScopedReassignment reassign_stderr(&stderr, io_handle->err());
 
@@ -361,6 +360,7 @@ int main(int argc, char* argv[]) {
   auto query_handle = std::make_unique(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/Ex

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

2017-12-22 Thread jianqiao
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 
Authored: Sat Sep 2 23:06:37 2017 -0500
Committer: Jianqiao Zhu 
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 
&arguments,
 CatalogRelationStatistics *mutable_stat =
 mutable_relation->getStatisticsMutable();
 
+mutable_stat->clear();
+
 const std::string rel_name = EscapeQuotes(relation.getName(), '"');
 
-// Get the number

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

2017-12-22 Thread jianqiao
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 000..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 
+#include 
+#include 
+#include 
+
+#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 &key_types,
+  const std::size_t num_entries,
+  const std::vector &handles,
+  StorageManager *storage_manager);
+
+  bool upsertValueAccessorCompositeKey(
+  const std::vector> &argument_ids,
+  const std::vector &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::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 
+  inline void constructCompactKeyCodeComponent(const std::size_t num_tuples,
+  

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

2017-12-22 Thread jianqiao
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,  1

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

2017-12-22 Thread jianqiao
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 
Authored: Sat Dec 16 22:32:05 2017 -0600
Committer: Jianqiao Zhu 
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 &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 3

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

2017-12-22 Thread jianqiao
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