You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sp...@apache.org on 2016/12/11 17:46:09 UTC

[46/51] [abbrv] [partial] incubator-quickstep git commit: remove c++ files

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/IndexScheme.hpp
----------------------------------------------------------------------
diff --git a/catalog/IndexScheme.hpp b/catalog/IndexScheme.hpp
deleted file mode 100644
index 3bf3f17..0000000
--- a/catalog/IndexScheme.hpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_CATALOG_INDEX_SCHEME_HPP_
-#define QUICKSTEP_CATALOG_INDEX_SCHEME_HPP_
-
-#include <algorithm>
-#include <cstddef>
-#include <string>
-#include <unordered_map>
-#include <vector>
-
-#include "catalog/Catalog.pb.h"
-#include "storage/StorageBlockLayout.pb.h"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-/** \addtogroup Catalog
- *  @{
- */
-
-/**
- * @brief The Index Scheme class which stores the information about
- *        various indicies defined for a particular relation.
- **/
-class IndexScheme {
- public:
-  typedef std::unordered_map<std::string, IndexSubBlockDescription>::const_iterator const_iterator;
-
-  /**
-   * @brief Constructor.
-   **/
-  IndexScheme() {
-  }
-
-  /**
-   * @brief Reconstruct an Index Scheme from its serialized
-   *        Protocol Buffer form.
-   *
-   * @param proto The Protocol Buffer serialization of a Index Scheme,
-   *              previously produced by getProto().
-   * @return The deserialied index scheme object.
-   **/
-  static IndexScheme* ReconstructFromProto(const serialization::IndexScheme &proto);
-
-  /**
-   * @brief Check whether a serialization::IndexScheme is fully-formed and
-   *        all parts are valid.
-   *
-   * @param proto A serialized Protocol Buffer representation of a
-   *              IndexScheme, originally generated by getProto().
-   * @return Whether proto is fully-formed and valid.
-   **/
-  static bool ProtoIsValid(const serialization::IndexScheme &proto);
-
-  /**
-   * @brief Serialize the Index Scheme as Protocol Buffer.
-   *
-   * @return The Protocol Buffer representation of Index Scheme.
-   **/
-  serialization::IndexScheme getProto() const;
-
-  /**
-   * @brief Get the number of indices for the relation.
-   *
-   * @return The number of indices defined for the relation.
-   **/
-  inline std::size_t getNumIndices() const {
-    return index_map_.size();
-  }
-
-  /**
-   * @brief Check whether an index with the given exists or not.
-   *
-   * @param index_name Name of the index to be checked.
-   * @return Whether the index exists or not.
-   **/
-  bool hasIndexWithName(const std::string &index_name) const {
-    return index_map_.find(index_name) != index_map_.end();
-  }
-
-  /**
-   * @brief Check whether an index with the given description
-   *        containing the same attribute id and index type
-   *        exists or not in the index map.
-   *
-   * @param index_descripton Index Description to check against.
-   * @return Whether a similar index description was already defined or not.
-   **/
-  bool hasIndexWithDescription(const IndexSubBlockDescription &index_description_checked) const {
-    // Iterate through every index description corresponding to each key in the index map.
-    for (auto cit = index_map_.cbegin(); cit != index_map_.cend(); ++cit) {
-      const IndexSubBlockDescription &index_description_expected = cit->second;
-      // Check if the stored description matches the given description.
-      if (areIndexDescriptionsSame(index_description_expected, index_description_checked)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  /**
-   * @brief Check whether two index descriptions are same or not.
-   *        Two index descriptions are same if they have any matching
-   *        attributes ids and same index type.
-   *
-   * @param description_expected First index description.
-   * @param description_checked Second index description.
-   * @return Whether the two index_descriptions are similar or not.
-   **/
-  bool areIndexDescriptionsSame(const IndexSubBlockDescription &description_expected,
-                                const IndexSubBlockDescription &description_checked) const {
-    if (description_expected.sub_block_type() != description_checked.sub_block_type()) {
-      return false;
-    }
-
-    // Serialize and sort the two protobuf index descriptions and compare.
-    std::string serialized_description_expected, serialized_description_checked;
-    description_expected.SerializeToString(&serialized_description_expected);
-    description_checked.SerializeToString(&serialized_description_checked);
-    std::sort(serialized_description_expected.begin(), serialized_description_expected.end());
-    std::sort(serialized_description_checked.begin(), serialized_description_checked.end());
-
-    return (serialized_description_expected.compare(serialized_description_checked) == 0);
-  }
-
-  /**
-   * @brief Get an iterator at beginning of the index map.
-   *
-   * @return An iterator at beginning of the index map.
-   **/
-  inline const_iterator begin() const {
-    return index_map_.begin();
-  }
-
-  /**
-   * @brief Get an iterator at one-past-the-end of the index map.
-   *
-   * @return An iterator one-past-the-end of the index map.
-   **/
-  inline const_iterator end() const {
-    return index_map_.end();
-  }
-
-  /**
-   * @brief Adds a new index entry to the index map.
-   * @warning Must call before hasIndexWithName() and hasIndexWithDescription().
-   * @note This method assumes that the caller has already acquired the
-   *       necessary locks before invoking it.
-   *
-   * @param index_name The name of index to add (key).
-   * @param index_description The index description for this index (value).
-   **/
-  bool addIndexMapEntry(const std::string &index_name,
-                        IndexSubBlockDescription &&index_description) {  // NOLINT(whitespace/operators)
-    if (index_map_.find(index_name) != index_map_.end()) {
-      return false;  // index_name is already present!
-    }
-    // Value for this index_map key is the index description provided.
-    index_map_.emplace(index_name, std::move(index_description));
-    return true;
-  }
-
- private:
-  // A map of index names to their index description.
-  std::unordered_map<std::string, IndexSubBlockDescription> index_map_;
-
-  DISALLOW_COPY_AND_ASSIGN(IndexScheme);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_CATALOG_INDEX_SCHEME_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/NUMAPlacementScheme.cpp
----------------------------------------------------------------------
diff --git a/catalog/NUMAPlacementScheme.cpp b/catalog/NUMAPlacementScheme.cpp
deleted file mode 100644
index 8e7d0fa..0000000
--- a/catalog/NUMAPlacementScheme.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "catalog/NUMAPlacementScheme.hpp"
-
-#include <unordered_map>
-#include <utility>
-
-#include "catalog/Catalog.pb.h"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-bool NUMAPlacementScheme::ProtoIsValid(
-    const serialization::NUMAPlacementScheme &proto) {
-  // Check that proto is fully initialized.
-  if (!proto.IsInitialized()) {
-    return false;
-  }
-  // Check if the number of numa nodes is non-zero.
-  if (proto.num_numa_nodes() <= 0) {
-    return false;
-  }
-  // Protobuf for NUMAPlacementScheme is valid.
-  return true;
-}
-
-serialization::NUMAPlacementScheme NUMAPlacementScheme::getProto() const {
-  serialization::NUMAPlacementScheme proto;
-
-  // Serialize the number of numa nodes.
-  proto.set_num_numa_nodes(getNumNUMANodes());
-
-  // Serialize the block to NUMA node map.
-  for (std::unordered_map<block_id, int>::const_iterator block_to_node_iter =
-           block_to_numa_node_map_.begin();
-       block_to_node_iter != block_to_numa_node_map_.end();
-       ++block_to_node_iter) {
-    serialization::NUMAPlacementScheme_BlockToNUMANodeEntry *entry =
-        proto.add_block_to_numa_node_map();
-    entry->set_block_id(block_to_node_iter->first);
-    entry->set_numa_node(block_to_node_iter->second);
-  }
-
-  return proto;
-}
-
-NUMAPlacementScheme* NUMAPlacementScheme::ReconstructFromProto(
-    const serialization::NUMAPlacementScheme &proto,
-    const std::size_t num_partitions) {
-  // This call to the constructor will populate the values of partition-to-NUMA
-  // node map.
-  NUMAPlacementScheme *placement_scheme = new NUMAPlacementScheme(num_partitions);
-
-  DCHECK(ProtoIsValid(proto))
-      << "Attempted to create NUMAPlacementScheme from an invalid proto description:\n"
-      << proto.DebugString();
-
-  // Deserialize block to NUMA node mapping.
-  for (int i = 0; i < proto.block_to_numa_node_map_size(); ++i) {
-    placement_scheme->addBlockToNUMANodeMap(
-        proto.block_to_numa_node_map(i).block_id(),
-        proto.block_to_numa_node_map(i).numa_node());
-  }
-  return placement_scheme;
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/NUMAPlacementScheme.hpp
----------------------------------------------------------------------
diff --git a/catalog/NUMAPlacementScheme.hpp b/catalog/NUMAPlacementScheme.hpp
deleted file mode 100644
index e5ab83a..0000000
--- a/catalog/NUMAPlacementScheme.hpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_CATALOG_PARTITION_PLACEMENT_SCHEME_HPP_
-#define QUICKSTEP_CATALOG_PARTITION_PLACEMENT_SCHEME_HPP_
-
-#include <numa.h>
-
-#include <cstddef>
-#include <ostream>
-#include <unordered_map>
-#include <utility>
-
-#include "catalog/Catalog.pb.h"
-#include "catalog/CatalogTypedefs.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-/** \addtogroup Catalog
- *  @{
- */
-
-/**
- * @brief A NUMAPlacementScheme object which stores the mapping between the
- * blocks in a partition and the NUMA nodes corresponding to those partitions.
- *
- * @note NUMA stands for Non-Uniform Memory Access.
- *
- * @note There is always only a one-on-one mapping between the partitions and
- * the NUMA nodes. This means that the blocks of a relation that belong to a
- * particular partition can be placed on ONLY one NUMA node. Earlier we had a
- * design where we can place the blocks in a single partition on multiple
- * NUMA nodes but we later decided that there wouldn't be any scenario where
- * we would want to place the blocks belonging to a single partition on more
- * than one NUMA node and hence that earlier design has been discarded.
- *
- * @note The terms node and socket would be used interchangeably in the
- * context of NUMA. A NUMA node or a NUMA socket would essentially mean
- * the same.
- **/
-class NUMAPlacementScheme {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param num_partitions The number of partitions of the Catalog Relation.
-   *                       This would be the same as the number of partitions
-   *                       in the Partition Scheme of the relation.
-   **/
-  explicit NUMAPlacementScheme(const std::size_t num_partitions)
-      : num_numa_nodes_(numa_num_configured_nodes()),
-        num_partitions_(num_partitions) {
-    // Assign each partition to exactly one NUMA node.
-    // Partitions are assigned in a round robin way to NUMA nodes.
-    for (std::size_t part_id = 0;
-         part_id < num_partitions_;
-         ++part_id) {
-      partition_to_numa_node_map_[part_id] = part_id % num_numa_nodes_;
-    }
-  }
-
-  /**
-   * @brief Destructor.
-   **/
-  ~NUMAPlacementScheme() {}
-
-  /**
-   * @brief Get the number of partitions.
-   *
-   * @return Number of partitions in the Catalog Relation.
-   **/
-  inline std::size_t getNumPartitions() const {
-    return num_partitions_;
-  }
-
-  /**
-   * @brief Get the total number of NUMA nodes available in the system.
-   *
-   * @return Total number of NUMA nodes available in the system.
-   **/
-  inline std::size_t getNumNUMANodes() const {
-    return num_numa_nodes_;
-  }
-
-  /**
-   * @brief Get the NUMA node on which a partition is placed.
-   *
-   * @param part_id The partition id for which to find the NUMA node.
-   *
-   * @return The NUMA node on which the partition is placed.
-   **/
-  inline numa_node_id getNUMANodeForPartition(const partition_id part_id)
-      const {
-    auto partition_to_numa_node_map_iter =
-        partition_to_numa_node_map_.find(part_id);
-    DCHECK(partition_to_numa_node_map_iter != partition_to_numa_node_map_.end());
-    return partition_to_numa_node_map_iter->second;
-  }
-
-  /**
-   * @brief Add a mapping between a block and the NUMA node on which the block
-   *        is placed.
-   *
-   * @param block The block_id of the block for which the NUMA node mapping is
-   *              added.
-   * @param numa_node The numa node id on which the block is placed.
-   **/
-  void addBlockToNUMANodeMap(const block_id block, const int numa_node) {
-    // Make sure that the block doesn't have a mapping already.
-    // A block will be mapped to only one NUMA node.
-    // A NUMA node will be associated with a block only once.
-    DCHECK(block_to_numa_node_map_.find(block) == block_to_numa_node_map_.end());
-    DCHECK_GT(numa_num_configured_nodes(), numa_node)
-        << "NUMA node above the valid value.";
-    block_to_numa_node_map_[block] = numa_node;
-  }
-
-  /**
-   * @brief Get the NUMA node associated with a block.
-   *
-   * @param block The block_id of the block for which the associated NUMA node
-   *              id is to be found.
-   *
-   * @return The NUMA node id associated with the block.
-   **/
-  inline numa_node_id getNUMANodeForBlock(const block_id block) const {
-    auto block_to_numa_node_map_iter = block_to_numa_node_map_.find(block);
-    DCHECK(block_to_numa_node_map_iter != block_to_numa_node_map_.end());
-    return block_to_numa_node_map_iter->second;
-  }
-
-  /**
-   * @brief Check whether a serialization::NUMAPlacementScheme is fully-formed
-   *        and all parts are valid.
-   *
-   * @param proto A serialized Protocol Buffer representation of a
-   *              NUMAPlacementScheme, originally generated by getProto().
-   *
-   * @return Whether proto is fully-formed and valid.
-   **/
-  static bool ProtoIsValid(const serialization::NUMAPlacementScheme &proto);
-
-  /**
-   * @brief Serialize the NUMA Placement Scheme as Protocol Buffer.
-   *
-   * @return The Protocol Buffer representation of NUMA Placement Scheme.
-   **/
-  serialization::NUMAPlacementScheme getProto() const;
-
-  /**
-   * @brief Reconstruct a NUMA Placement Scheme from its serialized
-   *        Protocol Buffer form.
-   *
-   * @param proto The Protocol Buffer serialization of a NUMA Placement Scheme,
-   *              previously produced by getProto().
-   * @param partition_proto The Protocol Buffer serialization of a
-   *                        ParitionScheme. This is needed for number of
-   *                        partitions.
-   *
-   * @return The deserialized NUMA Placement Scheme object.
-   **/
-  static NUMAPlacementScheme* ReconstructFromProto(
-      const serialization::NUMAPlacementScheme &proto,
-      const std::size_t num_partitions);
-
- private:
-  // Number of NUMA nodes available in the system.
-  const std::size_t num_numa_nodes_;
-
-  // Number of partitions in the Catalog Relation.
-  const std::size_t num_partitions_;
-
-  // A map between the partition ids and NUMA node ids.
-  // All the blocks that belong to a particular partition are placed on only
-  // one NUMA node.
-  std::unordered_map<partition_id, numa_node_id> partition_to_numa_node_map_;
-
-  // A map between the block ids and the NUMA node ids.
-  std::unordered_map<block_id, numa_node_id> block_to_numa_node_map_;
-
-  DISALLOW_COPY_AND_ASSIGN(NUMAPlacementScheme);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_CATALOG_PARTITION_PLACEMENT_SCHEME_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/PartitionScheme.cpp
----------------------------------------------------------------------
diff --git a/catalog/PartitionScheme.cpp b/catalog/PartitionScheme.cpp
deleted file mode 100644
index d6e3469..0000000
--- a/catalog/PartitionScheme.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "catalog/PartitionScheme.hpp"
-
-#include <cstddef>
-#include <limits>
-#include <unordered_set>
-#include <utility>
-#include <vector>
-
-#include "catalog/Catalog.pb.h"
-#include "catalog/PartitionSchemeHeader.hpp"
-#include "storage/StorageBlockInfo.hpp"
-
-#include "glog/logging.h"
-
-using std::move;
-using std::unordered_set;
-using std::vector;
-
-namespace quickstep {
-
-bool PartitionScheme::ProtoIsValid(
-    const serialization::PartitionScheme &proto) {
-  // Check that proto is fully initialized.
-  if (!proto.IsInitialized()) {
-    return false;
-  }
-
-  if (!PartitionSchemeHeader::ProtoIsValid(proto.header())) {
-    return false;
-  }
-
-  if (static_cast<std::size_t>(proto.partitions_size()) != proto.header().num_partitions()) {
-    return false;
-  }
-
-  return true;
-}
-
-PartitionScheme* PartitionScheme::ReconstructFromProto(const serialization::PartitionScheme &proto,
-                                                       const Type &attr_type) {
-  DCHECK(ProtoIsValid(proto))
-      << "Attempted to create PartitionScheme from an invalid proto description:\n"
-      << proto.DebugString();
-
-  vector<unordered_set<block_id>> blocks_in_partition;
-  for (int i = 0; i < proto.partitions_size(); ++i) {
-    unordered_set<block_id> blocks;
-
-    const serialization::Partition &proto_blocks = proto.partitions(i);
-    for (int j = 0; j < proto_blocks.blocks_size(); ++j) {
-      blocks.insert(proto_blocks.blocks(j));
-    }
-
-    blocks_in_partition.push_back(move(blocks));
-  }
-
-  return new PartitionScheme(
-      PartitionSchemeHeader::ReconstructFromProto(proto.header(), attr_type),
-      move(blocks_in_partition));
-}
-
-serialization::PartitionScheme PartitionScheme::getProto() const {
-  serialization::PartitionScheme proto;
-
-  proto.mutable_header()->MergeFrom(header_->getProto());
-
-  // Add blocks to the corresponding partitions.
-  for (std::size_t i = 0; i < blocks_in_partition_.size(); ++i) {
-    serialization::Partition *proto_blocks = proto.add_partitions();
-
-    SpinSharedMutexSharedLock<false> lock(blocks_in_partition_mutexes_[i]);
-    const std::unordered_set<block_id> &partition = blocks_in_partition_[i];
-    for (const block_id block : partition) {
-      proto_blocks->add_blocks(block);
-    }
-  }
-
-  return proto;
-}
-
-partition_id PartitionScheme::getPartitionForBlock(const block_id block) const {
-  // Check if the block is present in the available partitions.
-  // If so, return the partition id for the block.
-  for (partition_id part_id = 0; part_id < header_->getNumPartitions(); ++part_id) {
-    SpinSharedMutexSharedLock<false> lock(
-        blocks_in_partition_mutexes_[part_id]);
-    if (blocks_in_partition_[part_id].find(block) !=
-        blocks_in_partition_[part_id].end()) {
-      return part_id;
-    }
-  }
-  // Block was not found in any partitions.
-  return std::numeric_limits<std::size_t>::max();
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/PartitionScheme.hpp
----------------------------------------------------------------------
diff --git a/catalog/PartitionScheme.hpp b/catalog/PartitionScheme.hpp
deleted file mode 100644
index c882a5e..0000000
--- a/catalog/PartitionScheme.hpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_CATALOG_PARTITION_SCHEME_HPP_
-#define QUICKSTEP_CATALOG_PARTITION_SCHEME_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <unordered_set>
-#include <utility>
-#include <vector>
-
-#include "catalog/Catalog.pb.h"
-#include "catalog/CatalogTypedefs.hpp"
-#include "catalog/PartitionSchemeHeader.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "threading/Mutex.hpp"
-#include "threading/SharedMutex.hpp"
-#include "threading/SpinSharedMutex.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class Type;
-
-/** \addtogroup Catalog
- *  @{
- */
-
-/**
- * @brief The class which stores the partitioning information and partitioned
- *        blocks for a particular relation.
- **/
-class PartitionScheme {
- public:
-  /**
-   * @brief Constructor.
-   * @note The constructor takes ownership of \c header.
-   *
-   * @param header The partition header.
-   * @param blocks_in_partition All blocks in partitions.
-   **/
-  explicit PartitionScheme(PartitionSchemeHeader *header)
-      : header_(DCHECK_NOTNULL(header)),
-        blocks_in_partition_(header_->getNumPartitions()),
-        blocks_in_partition_mutexes_(header_->getNumPartitions()) {}
-
-  /**
-   * @brief Constructor.
-   * @note The constructor takes ownership of \c header.
-   *
-   * @param header The partition header.
-   * @param blocks_in_partition All blocks in partitions.
-   **/
-  PartitionScheme(PartitionSchemeHeader *header,
-                  std::vector<std::unordered_set<block_id>> &&blocks_in_partition)
-      : header_(DCHECK_NOTNULL(header)),
-        blocks_in_partition_(std::move(blocks_in_partition)),
-        blocks_in_partition_mutexes_(header_->getNumPartitions()) {}
-
-  /**
-   * @brief Reconstruct a Partition Scheme from its serialized
-   *        Protocol Buffer form.
-   *
-   * @param proto The Protocol Buffer serialization of a Partition Scheme,
-   *        previously produced by getProto().
-   * @param attr_type The attribute type of the partitioning attribute.
-   * @return The deserialized partition scheme object.
-   **/
-  static PartitionScheme* ReconstructFromProto(const serialization::PartitionScheme &proto,
-                                               const Type &attr_type);
-
-  /**
-   * @brief Check whether a serialization::PartitionScheme is fully-formed and
-   *        all parts are valid.
-   *
-   * @param proto A serialized Protocol Buffer representation of a
-   *              PartitionScheme, originally generated by getProto().
-   * @return Whether proto is fully-formed and valid.
-   **/
-  static bool ProtoIsValid(const serialization::PartitionScheme &proto);
-
-  /**
-   * @brief Get the partitioning attribute for the relation.
-   *
-   * @return The partitioning attribute with which the relation
-   *         is partitioned into.
-   **/
-  const PartitionSchemeHeader& getPartitionSchemeHeader() const {
-    return *header_;
-  }
-
-  /**
-   * @brief Add a block to a partition.
-   *
-   * @param block_id The id of the block to be added to the partition.
-   * @param part_id The id of the partition to add the block to.
-   **/
-  inline void addBlockToPartition(const block_id block,
-                                  const partition_id part_id) {
-    DCHECK_LT(part_id, header_->getNumPartitions());
-    SpinSharedMutexExclusiveLock<false> lock(
-        blocks_in_partition_mutexes_[part_id]);
-    blocks_in_partition_[part_id].insert(block);
-  }
-
-  /**
-   * @brief Remove a block from a partition.
-   *
-   * @param block_id The id of the block to be removed from the partition.
-   * @param part_id The id of the partition to remove the block from.
-   **/
-  inline void removeBlockFromPartition(const block_id block,
-                                       const partition_id part_id) {
-    DCHECK_LT(part_id, header_->getNumPartitions());
-    SpinSharedMutexExclusiveLock<false> lock(
-        blocks_in_partition_mutexes_[part_id]);
-    std::unordered_set<block_id> &blocks_in_partition =
-        blocks_in_partition_[part_id];
-    blocks_in_partition.erase(block);
-  }
-
-  /**
-   * @brief Get all the blocks from a particular partition.
-   *
-   * @param part_id The id of the partition to retrieve the blocks from.
-   * @return The block_ids of blocks belonging to this partition at the moment
-   *         when this method is called.
-   **/
-  inline std::vector<block_id> getBlocksInPartition(
-      const partition_id part_id) const {
-    DCHECK_LT(part_id, header_->getNumPartitions());
-    SpinSharedMutexSharedLock<false> lock(
-        blocks_in_partition_mutexes_[part_id]);
-    return std::vector<block_id>(blocks_in_partition_[part_id].begin(),
-                                 blocks_in_partition_[part_id].end());
-  }
-
-  /**
-   * @brief Serialize the Partition Scheme as Protocol Buffer.
-   *
-   * @return The Protocol Buffer representation of Partition Scheme.
-   **/
-  serialization::PartitionScheme getProto() const;
-
-  /**
-   * @brief Get the partition id for a block.
-   *
-   * @param block The id of the block.
-   *
-   * @return The partition id to which the block belongs. If the block is not
-   *         found in any partition, then the maximum finite value for the type
-   *         std::size_t is returned.
-   **/
-  partition_id getPartitionForBlock(const block_id block) const;
-
- private:
-  std::unique_ptr<const PartitionSchemeHeader> header_;
-
-  // The unordered set of blocks per partition.
-  std::vector<std::unordered_set<block_id>> blocks_in_partition_;
-  // Mutexes for locking each partition separately.
-  mutable std::vector<SpinSharedMutex<false>> blocks_in_partition_mutexes_;
-
-  DISALLOW_COPY_AND_ASSIGN(PartitionScheme);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_CATALOG_PARTITION_SCHEME_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/PartitionSchemeHeader.cpp
----------------------------------------------------------------------
diff --git a/catalog/PartitionSchemeHeader.cpp b/catalog/PartitionSchemeHeader.cpp
deleted file mode 100644
index 26c317d..0000000
--- a/catalog/PartitionSchemeHeader.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "catalog/PartitionSchemeHeader.hpp"
-
-#include <cstddef>
-#include <utility>
-#include <vector>
-
-#include "catalog/Catalog.pb.h"
-#include "types/TypedValue.hpp"
-#include "types/TypedValue.pb.h"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-PartitionSchemeHeader::PartitionSchemeHeader(const PartitionType type,
-                                             const std::size_t num_partitions,
-                                             const attribute_id attr_id)
-    : partition_type_(type),
-      num_partitions_(num_partitions),
-      partition_attribute_id_(attr_id) {
-  DCHECK_GT(num_partitions, 0u);
-  DCHECK_GE(attr_id, 0);
-}
-
-bool PartitionSchemeHeader::ProtoIsValid(
-    const serialization::PartitionSchemeHeader &proto) {
-  // Check that proto is fully initialized.
-  if (!proto.IsInitialized()) {
-    return false;
-  }
-  // Check if the partitioning attribute exists in the relation.
-  // TODO(gerald): Figure out how to find the max_attr_id of the
-  // relation so that we can check that partitioning attribute
-  // is not greater than the max_attr_id.
-
-  // Check that the proto has a valid partition type.
-  switch (proto.partition_type()) {
-    case serialization::PartitionSchemeHeader::HASH:
-      return true;
-    case serialization::PartitionSchemeHeader::RANGE: {
-      const std::size_t num_ranges =
-          proto.ExtensionSize(serialization::RangePartitionSchemeHeader::partition_range_boundaries);
-      return num_ranges == proto.num_partitions() - 1;
-    }
-    default:
-      // Partition type is unknown.
-      return false;
-  }
-}
-
-PartitionSchemeHeader* PartitionSchemeHeader::ReconstructFromProto(
-    const serialization::PartitionSchemeHeader &proto, const Type &attr_type) {
-  DCHECK(ProtoIsValid(proto))
-      << "Attempted to create PartitionSchemeHeader from an invalid proto description:\n"
-      << proto.DebugString();
-
-  switch (proto.partition_type()) {
-    case serialization::PartitionSchemeHeader::HASH: {
-      return new HashPartitionSchemeHeader(proto.num_partitions(), proto.partition_attribute_id());
-    }
-    case serialization::PartitionSchemeHeader::RANGE: {
-      std::vector<TypedValue> partition_ranges;
-      for (int i = 0;
-           i < proto.ExtensionSize(serialization::RangePartitionSchemeHeader::partition_range_boundaries);
-           ++i) {
-        partition_ranges.emplace_back(
-            TypedValue::ReconstructFromProto(
-                proto.GetExtension(serialization::RangePartitionSchemeHeader::partition_range_boundaries, i)));
-      }
-
-      return new RangePartitionSchemeHeader(attr_type,
-                                            proto.num_partitions(),
-                                            proto.partition_attribute_id(),
-                                            std::move(partition_ranges));
-    }
-    default:
-      LOG(FATAL) << "Invalid partition scheme header.";
-  }
-}
-
-serialization::PartitionSchemeHeader PartitionSchemeHeader::getProto() const {
-  serialization::PartitionSchemeHeader proto;
-
-  switch (partition_type_) {
-    case PartitionType::kHash:
-      proto.set_partition_type(serialization::PartitionSchemeHeader::HASH);
-      break;
-    case PartitionType::kRange:
-      LOG(FATAL) << "RangePartitionSchemeHeader should call the overridden method.";
-    default:
-      LOG(FATAL) << "Invalid Partition Type.";
-  }
-
-  proto.set_num_partitions(num_partitions_);
-  proto.set_partition_attribute_id(partition_attribute_id_);
-
-  return proto;
-}
-
-serialization::PartitionSchemeHeader RangePartitionSchemeHeader::getProto() const {
-  serialization::PartitionSchemeHeader proto;
-
-  proto.set_partition_type(serialization::PartitionSchemeHeader::RANGE);
-  proto.set_num_partitions(num_partitions_);
-  proto.set_partition_attribute_id(partition_attribute_id_);
-
-  for (std::size_t i = 0; i < partition_range_boundaries_.size(); ++i) {
-    proto.AddExtension(serialization::RangePartitionSchemeHeader::partition_range_boundaries)
-        ->MergeFrom(partition_range_boundaries_[i].getProto());
-  }
-
-  return proto;
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/PartitionSchemeHeader.hpp
----------------------------------------------------------------------
diff --git a/catalog/PartitionSchemeHeader.hpp b/catalog/PartitionSchemeHeader.hpp
deleted file mode 100644
index 89efc6d..0000000
--- a/catalog/PartitionSchemeHeader.hpp
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_CATALOG_PARTITION_SCHEME_HEADER_HPP_
-#define QUICKSTEP_CATALOG_PARTITION_SCHEME_HEADER_HPP_
-
-#include <cstddef>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "catalog/Catalog.pb.h"
-#include "catalog/CatalogTypedefs.hpp"
-#include "types/TypedValue.hpp"
-#include "types/operations/comparisons/Comparison.hpp"
-#include "types/operations/comparisons/LessComparison.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-
-class Type;
-
-/** \addtogroup Catalog
- *  @{
- */
-
-/**
- * @brief The base class which stores the partitioning information for a
- *        particular relation.
- **/
-class PartitionSchemeHeader {
- public:
-  enum PartitionType {
-    kHash = 0,
-    kRange
-  };
-
-  /**
-   * @brief Virtual destructor.
-   **/
-  virtual ~PartitionSchemeHeader() {
-  }
-
-  /**
-   * @brief Reconstruct a PartitionSchemeHeader from its serialized
-   *        Protocol Buffer form.
-   *
-   * @param proto The Protocol Buffer serialization of a PartitionSchemeHeader,
-   *        previously produced by getProto().
-   * @param attr_type The attribute type of the partitioning attribute.
-   * @return The reconstructed PartitionSchemeHeader object.
-   **/
-  static PartitionSchemeHeader* ReconstructFromProto(
-      const serialization::PartitionSchemeHeader &proto,
-      const Type &attr_type);
-
-  /**
-   * @brief Check whether a serialization::PartitionSchemeHeader is fully-formed
-   *        and all parts are valid.
-   *
-   * @param proto A serialized Protocol Buffer representation of a
-   *              PartitionSchemeHeader, originally generated by getProto().
-   * @return Whether proto is fully-formed and valid.
-   **/
-  static bool ProtoIsValid(const serialization::PartitionSchemeHeader &proto);
-
-  /**
-   * @brief Calculate the partition id into which the attribute value should
-   *        be inserted.
-   *
-   * @param value_of_attribute The attribute value for which the
-   *                           partition id is to be determined.
-   * @return The partition id of the partition for the attribute value.
-   **/
-  // TODO(gerald): Make this method more efficient since currently this is
-  // done for each and every tuple. We can go through the entire set of tuples
-  // once using a value accessor and create bitmaps for each partition with
-  // tuples that correspond to those partitions.
-  virtual partition_id getPartitionId(
-      const TypedValue &value_of_attribute) const = 0;
-
-  /**
-   * @brief Serialize the Partition Scheme as Protocol Buffer.
-   *
-   * @return The Protocol Buffer representation of Partition Scheme.
-   **/
-  virtual serialization::PartitionSchemeHeader getProto() const;
-
-  /**
-   * @brief Get the partition type of the relation.
-   *
-   * @return The partition type used to partition the relation.
-   **/
-  inline PartitionType getPartitionType() const {
-    return partition_type_;
-  }
-
-  /**
-   * @brief Get the number of partitions for the relation.
-   *
-   * @return The number of partitions the relation is partitioned into.
-   **/
-  inline std::size_t getNumPartitions() const {
-    return num_partitions_;
-  }
-
-  /**
-   * @brief Get the partitioning attribute for the relation.
-   *
-   * @return The partitioning attribute with which the relation
-   *         is partitioned into.
-   **/
-  inline attribute_id getPartitionAttributeId() const {
-    return partition_attribute_id_;
-  }
-
- protected:
-  /**
-   * @brief Constructor.
-   *
-   * @param type The type of partitioning to be used to partition the
-   *             relation.
-   * @param num_partitions The number of partitions to be created.
-   * @param attr_id The attribute on which the partitioning happens.
-   **/
-  PartitionSchemeHeader(const PartitionType type,
-                        const std::size_t num_partitions,
-                        const attribute_id attr_id);
-
-  // The type of partitioning: Hash or Range.
-  const PartitionType partition_type_;
-  // The number of partitions.
-  const std::size_t num_partitions_;
-  // The attribute of partioning.
-  const attribute_id partition_attribute_id_;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(PartitionSchemeHeader);
-};
-
-/**
- * @brief Implementation of PartitionSchemeHeader that partitions the tuples in
- *        a relation based on a hash function on the partitioning attribute.
-**/
-class HashPartitionSchemeHeader : public PartitionSchemeHeader {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param num_partitions The number of partitions to be created.
-   * @param attribute The attribute on which the partitioning happens.
-   **/
-  HashPartitionSchemeHeader(const std::size_t num_partitions, const attribute_id attribute)
-      : PartitionSchemeHeader(PartitionType::kHash, num_partitions, attribute) {
-  }
-
-  /**
-   * @brief Destructor.
-   **/
-  ~HashPartitionSchemeHeader() override {
-  }
-
-  /**
-   * @brief Calulate the partition id into which the attribute value
-   *        should be inserted.
-   *
-   * @param value_of_attribute The attribute value for which the
-   *                           partition id is to be determined.
-   * @return The partition id of the partition for the attribute value.
-   **/
-  partition_id getPartitionId(
-      const TypedValue &value_of_attribute) const override {
-    // TODO(gerald): Optimize for the case where the number of partitions is a
-    // power of 2. We can just mask out the lower-order hash bits rather than
-    // doing a division operation.
-    return value_of_attribute.getHash() % num_partitions_;
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(HashPartitionSchemeHeader);
-};
-
-/**
- * @brief Implementation of PartitionSchemeHeader that partitions the tuples in
- *        a relation based on a given value range on the partitioning attribute.
-**/
-class RangePartitionSchemeHeader : public PartitionSchemeHeader {
- public:
-  /**
-   * @brief Constructor.
-   *
-   * @param partition_attribute_type The type of CatalogAttribute that is used
-   *                                 for partitioning.
-   * @param num_partitions The number of partitions to be created.
-   * @param attribute The attribute_id on which the partitioning happens.
-   * @param partition_range The mapping between the partition ids and the upper
-   *                        bound of the range boundaries. If two ranges R1 and
-   *                        R2 are separated by a boundary value V, then V
-   *                        would fall into range R2. For creating a range
-   *                        partition scheme with n partitions, you need to
-   *                        specify n-1 boundary values. The first partition
-   *                        will have all the values less than the first
-   *                        boundary and the last partition would have all
-   *                        values greater than or equal to the last boundary
-   *                        value.
-   **/
-  RangePartitionSchemeHeader(const Type &partition_attribute_type,
-                             const std::size_t num_partitions,
-                             const attribute_id attribute,
-                             std::vector<TypedValue> &&partition_range)
-      : PartitionSchemeHeader(PartitionType::kRange, num_partitions, attribute),
-        partition_range_boundaries_(std::move(partition_range)) {
-    DCHECK_EQ(num_partitions - 1, partition_range_boundaries_.size());
-
-    const Comparison &less_comparison_op(LessComparison::Instance());
-    less_unchecked_comparator_.reset(
-        less_comparison_op.makeUncheckedComparatorForTypes(
-            partition_attribute_type, partition_attribute_type));
-
-#ifdef QUICKSTEP_DEBUG
-    checkPartitionRangeBoundaries();
-#endif
-  }
-
-  /**
-   * @brief Destructor.
-   **/
-  ~RangePartitionSchemeHeader() override {
-  }
-
-  /**
-   * @brief Calulate the partition id into which the attribute value
-   *        should be inserted.
-   *
-   * @param value_of_attribute The attribute value for which the
-   *                           partition id is to be determined.
-   * @return The partition id of the partition for the attribute value.
-   **/
-  partition_id getPartitionId(
-      const TypedValue &value_of_attribute) const override {
-    partition_id start = 0, end = partition_range_boundaries_.size() - 1;
-    if (!less_unchecked_comparator_->compareTypedValues(value_of_attribute, partition_range_boundaries_[end])) {
-      return num_partitions_ - 1;
-    }
-
-    while (start < end) {
-      const partition_id mid = start + ((end - start) >> 1);
-      if (less_unchecked_comparator_->compareTypedValues(value_of_attribute, partition_range_boundaries_[mid])) {
-        end = mid;
-      } else {
-        start = mid + 1;
-      }
-    }
-
-    return start;
-  }
-
-  serialization::PartitionSchemeHeader getProto() const override;
-
-  /**
-   * @brief Get the range boundaries for partitions.
-   *
-   * @return The vector of range boundaries for partitions.
-   **/
-  inline const std::vector<TypedValue>& getPartitionRangeBoundaries() const {
-    return partition_range_boundaries_;
-  }
-
- private:
-  /**
-   * @brief Check if the partition range boundaries are in ascending order.
-   **/
-  void checkPartitionRangeBoundaries() {
-    for (partition_id part_id = 1; part_id < partition_range_boundaries_.size(); ++part_id) {
-      if (less_unchecked_comparator_->compareTypedValues(
-              partition_range_boundaries_[part_id],
-              partition_range_boundaries_[part_id - 1])) {
-        LOG(FATAL) << "Partition boundaries are not in ascending order.";
-      }
-    }
-  }
-
-  // The boundaries for each range in the RangePartitionSchemeHeader.
-  // The upper bound of the range is stored here.
-  const std::vector<TypedValue> partition_range_boundaries_;
-
-  std::unique_ptr<UncheckedComparator> less_unchecked_comparator_;
-
-  DISALLOW_COPY_AND_ASSIGN(RangePartitionSchemeHeader);
-};
-
-/** @} */
-
-}  // namespace quickstep
-
-#endif  // QUICKSTEP_CATALOG_PARTITION_SCHEME_HEADER_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/tests/Catalog_unittest.cpp
----------------------------------------------------------------------
diff --git a/catalog/tests/Catalog_unittest.cpp b/catalog/tests/Catalog_unittest.cpp
deleted file mode 100644
index e430b89..0000000
--- a/catalog/tests/Catalog_unittest.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include <algorithm>
-#include <cstddef>
-#include <limits>
-#include <memory>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include "catalog/Catalog.hpp"
-#include "catalog/Catalog.pb.h"
-#include "catalog/CatalogAttribute.hpp"
-#include "catalog/CatalogDatabase.hpp"
-#include "catalog/CatalogDatabaseCache.hpp"
-#include "catalog/CatalogRelation.hpp"
-#include "catalog/CatalogRelationSchema.hpp"
-#include "catalog/CatalogTypedefs.hpp"
-#include "catalog/IndexScheme.hpp"
-#include "storage/StorageBlockInfo.hpp"
-#include "storage/StorageBlockLayout.hpp"
-#include "storage/StorageBlockLayout.pb.h"
-#include "storage/SubBlockTypeRegistryMacros.hpp"
-#include "types/Type.hpp"
-#include "types/TypeFactory.hpp"
-#include "types/TypeID.hpp"
-#include "utility/Macros.hpp"
-#include "utility/PtrVector.hpp"
-
-#include "gtest/gtest.h"
-
-namespace quickstep {
-
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(BasicColumnStoreTupleStorageSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(CSBTreeIndexSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(CompressedColumnStoreTupleStorageSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(CompressedPackedRowStoreTupleStorageSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(PackedRowStoreTupleStorageSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(SMAIndexSubBlock);
-QUICKSTEP_FORCE_SUB_BLOCK_REGISTRATION(SplitRowStoreTupleStorageSubBlock);
-
-class CatalogTest : public ::testing::Test {
- protected:
-  virtual void SetUp() {
-    db_ = cat_.getDatabaseByIdMutable(cat_.addDatabase(new CatalogDatabase(nullptr, "db")));
-  }
-
-  CatalogRelation* createCatalogRelation(const std::string &name, bool temporary = false) {
-    return db_->getRelationByIdMutable(db_->addRelation(new CatalogRelation(nullptr, name, -1, temporary)));
-  }
-
-  static void CompareCatalogAttribute(const CatalogAttribute &expected, const CatalogAttribute &checked) {
-    EXPECT_EQ(expected.getID(), checked.getID());
-    EXPECT_EQ(expected.getName(), checked.getName());
-    EXPECT_TRUE(expected.getType().equals(checked.getType()));
-    EXPECT_EQ(expected.getDisplayName(), checked.getDisplayName());
-  }
-
-  static void CompareTupleStorageSubBlockDescription(
-      const TupleStorageSubBlockDescription &expected,
-      const TupleStorageSubBlockDescription &checked) {
-    EXPECT_EQ(expected.sub_block_type(), checked.sub_block_type());
-
-    switch (expected.sub_block_type()) {
-      case TupleStorageSubBlockDescription::PACKED_ROW_STORE:
-        break;
-      case TupleStorageSubBlockDescription::BASIC_COLUMN_STORE:
-        EXPECT_TRUE(expected.HasExtension(BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-        EXPECT_TRUE(checked.HasExtension(BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-        EXPECT_EQ(
-            expected.GetExtension(BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id),
-            checked.GetExtension(BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-        break;
-      case TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE:
-        ASSERT_EQ(
-            expected.ExtensionSize(CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id),
-            checked.ExtensionSize(CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id));
-
-        for (int i = 0;
-             i < expected.ExtensionSize(
-                     CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id);
-             ++i) {
-          EXPECT_EQ(
-              expected.GetExtension(
-                  CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i),
-              checked.GetExtension(
-                  CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i));
-        }
-        break;
-      case TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE:
-        EXPECT_TRUE(expected.HasExtension(CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-        EXPECT_TRUE(checked.HasExtension(CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-        EXPECT_EQ(
-            expected.GetExtension(CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id),
-            checked.GetExtension(CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
-
-        ASSERT_EQ(
-            expected.ExtensionSize(CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id),
-            checked.ExtensionSize(CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id));
-
-        for (int i = 0;
-             i < expected.ExtensionSize(CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id);
-             ++i) {
-          EXPECT_EQ(
-              expected.GetExtension(CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id, i),
-              checked.GetExtension(CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id, i));
-        }
-        break;
-      case TupleStorageSubBlockDescription::SPLIT_ROW_STORE:
-        break;
-      default:
-        FATAL_ERROR("Unknown TupleStorageSubBlockType encountered in CompareTupleStorageSubBlockDescription");
-    }
-  }
-
-  static void CompareIndexSubBlockDescription(
-      const IndexSubBlockDescription &expected,
-      const IndexSubBlockDescription &checked) {
-    EXPECT_EQ(expected.sub_block_type(), checked.sub_block_type());
-
-    ASSERT_EQ(expected.indexed_attribute_ids_size(), checked.indexed_attribute_ids_size());
-    for (int i = 0; i < expected.indexed_attribute_ids_size(); ++i) {
-      EXPECT_EQ(expected.indexed_attribute_ids(i), checked.indexed_attribute_ids(i));
-    }
-  }
-
-  static void CompareStorageBlockLayoutDescription(
-      const StorageBlockLayoutDescription &expected,
-      const StorageBlockLayoutDescription &checked) {
-    EXPECT_EQ(expected.num_slots(), checked.num_slots());
-    CompareTupleStorageSubBlockDescription(expected.tuple_store_description(), checked.tuple_store_description());
-
-    ASSERT_EQ(expected.index_description_size(), checked.index_description_size());
-    for (int i = 0; i < expected.index_description_size(); ++i) {
-      CompareIndexSubBlockDescription(expected.index_description(i), checked.index_description(i));
-    }
-  }
-
-  static void CompareCatalogRelation(const CatalogRelation &expected, const CatalogRelation &checked) {
-    EXPECT_EQ(expected.getID(), checked.getID());
-    EXPECT_EQ(expected.getName(), checked.getName());
-    EXPECT_EQ(expected.isTemporary(), checked.isTemporary());
-
-    CompareStorageBlockLayoutDescription(
-        expected.getDefaultStorageBlockLayout().getDescription(),
-        checked.getDefaultStorageBlockLayout().getDescription());
-
-    EXPECT_EQ(expected.blocks_, checked.blocks_);
-
-    ASSERT_EQ(expected.size(), checked.size());
-    for (CatalogRelation::const_iterator it1 = expected.begin(), it2 = checked.begin();
-         it1 != expected.end();
-         ++it1, ++it2) {
-      CompareCatalogAttribute(*it1, *it2);
-    }
-
-    ASSERT_EQ((expected.index_scheme_ != nullptr), (checked.index_scheme_ != nullptr));
-
-    if (checked.index_scheme_ != nullptr) {
-      ASSERT_EQ(expected.index_scheme_->getNumIndices(), checked.index_scheme_->getNumIndices());
-
-      std::string expected_index_scheme_serialized_proto, checked_index_scheme_serialized_proto;
-      expected.index_scheme_->getProto().SerializeToString(&expected_index_scheme_serialized_proto);
-      checked.index_scheme_->getProto().SerializeToString(&checked_index_scheme_serialized_proto);
-      std::sort(expected_index_scheme_serialized_proto.begin(), expected_index_scheme_serialized_proto.end());
-      std::sort(checked_index_scheme_serialized_proto.begin(), checked_index_scheme_serialized_proto.end());
-      EXPECT_EQ(expected_index_scheme_serialized_proto, checked_index_scheme_serialized_proto);
-    }
-  }
-
-  static void CompareCatalogDatabase(const CatalogDatabase &expected, const CatalogDatabase &checked) {
-    EXPECT_EQ(expected.getID(), checked.getID());
-    EXPECT_EQ(expected.getName(), checked.getName());
-    ASSERT_EQ(expected.size(), checked.size());
-    for (CatalogDatabase::const_iterator it1 = expected.begin(), it2 = checked.begin();
-         it1 != expected.end();
-         ++it1, ++it2) {
-      CompareCatalogRelation(*it1, *it2);
-    }
-  }
-
-  void compareCatalogDatabaseCache(const CatalogDatabaseCache &cache) {
-    ASSERT_EQ(db_->size(), cache.size());
-    for (const CatalogRelationSchema &expected : *db_) {
-      const relation_id rel_id = expected.getID();
-
-      ASSERT_TRUE(cache.hasRelationWithId(rel_id));
-      const CatalogRelationSchema &checked = cache.getRelationSchemaById(rel_id);
-
-      EXPECT_EQ(rel_id, checked.getID());
-      EXPECT_EQ(expected.getName(), checked.getName());
-      EXPECT_EQ(expected.isTemporary(), checked.isTemporary());
-
-      ASSERT_EQ(expected.size(), checked.size());
-      for (auto cit_expected = expected.begin(), cit_checked = checked.begin();
-           cit_expected != expected.end();
-           ++cit_expected, ++cit_checked) {
-        CompareCatalogAttribute(*cit_expected, *cit_checked);
-      }
-      const std::vector<std::size_t>& expected_max_lengths =
-          expected.getMaximumAttributeByteLengths();
-      const std::vector<std::size_t>& checked_max_lengths =
-          checked.getMaximumAttributeByteLengths();
-      ASSERT_EQ(expected_max_lengths.size(), checked_max_lengths.size());
-      for (attribute_id len_index = 0;
-           static_cast<std::size_t>(len_index) < expected_max_lengths.size();
-           ++len_index) {
-        EXPECT_EQ(expected_max_lengths[len_index],
-                  checked_max_lengths[len_index]);
-      }
-    }
-  }
-
-  void checkCatalogSerialization() {
-    Catalog cat_from_proto(cat_.getProto());
-    ASSERT_EQ(cat_.size(), cat_from_proto.size());
-    for (Catalog::const_iterator it = cat_.begin(), it_from_proto = cat_from_proto.begin();
-         it != cat_.end();
-         ++it, ++it_from_proto) {
-      CompareCatalogDatabase(*it, *it_from_proto);
-    }
-  }
-
-  Catalog cat_;
-  // db_ is owned by cat_.
-  CatalogDatabase *db_;
-};
-
-TEST_F(CatalogTest, CatalogAttributeSerializationTest) {
-  CatalogRelation* const rel_numeric = createCatalogRelation("rel_numeric");
-
-  rel_numeric->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 14));
-  rel_numeric->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 7));
-
-  rel_numeric->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt), -1 /* id */, "int"));
-  rel_numeric->addAttribute(
-      new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong), -1 /* id */, "long"));
-  rel_numeric->addAttribute(
-      new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat), -1 /* id */, "float"));
-  rel_numeric->addAttribute(
-      new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble), -1 /* id */, "double"));
-
-  CatalogRelation* const rel_string = createCatalogRelation("rel_string");
-
-  rel_string->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 19));
-  rel_string->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 4));
-
-  StorageBlockLayoutDescription layout_description_string(
-      rel_string->getDefaultStorageBlockLayout().getDescription());
-
-  std::size_t str_type_length = 0;
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "char_length_0",
-                           TypeFactory::GetType(kChar, str_type_length),
-                           -1 /* id */,
-                           "char_0"));
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_0", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  str_type_length = 8;
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_8", TypeFactory::GetType(kChar, str_type_length)));
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_8",
-                           TypeFactory::GetType(kVarChar, str_type_length),
-                           -1 /* id */,
-                           "vchar_8"));
-
-  str_type_length = 1024;
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_1024", TypeFactory::GetType(kChar, str_type_length)));
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_1024", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  str_type_length = 65536;
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_65536", TypeFactory::GetType(kChar, str_type_length)));
-  rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_65536", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  // COMPRESSED_PACKED_ROW_STORE supports variable-length attributes.
-  TupleStorageSubBlockDescription* tuple_store_description_string =
-      layout_description_string.mutable_tuple_store_description();
-  tuple_store_description_string->set_sub_block_type(
-      TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE);
-  for (int i = 0; i <= rel_string->getMaxAttributeId(); ++i) {
-    tuple_store_description_string->AddExtension(
-        CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i);
-  }
-  rel_string->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel_string, layout_description_string));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, NullableCatalogAttributeSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-
-  StorageBlockLayoutDescription layout_description(
-      rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int_nullable", TypeFactory::GetType(kInt, true)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long_nullable", TypeFactory::GetType(kLong, true)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float_nullable", TypeFactory::GetType(kFloat, true)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double_nullable", TypeFactory::GetType(kDouble, true)));
-
-  std::size_t str_type_length = 0;
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_0_nullable", TypeFactory::GetType(kChar, str_type_length, true)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_0_nullable",
-                           TypeFactory::GetType(kVarChar, str_type_length, true)));
-
-  str_type_length = 8;
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_8_nullable", TypeFactory::GetType(kChar, str_type_length, true)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_8_nullable",
-                           TypeFactory::GetType(kVarChar, str_type_length, true)));
-
-  str_type_length = 1024;
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_1024_nullable", TypeFactory::GetType(kChar, str_type_length, true)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_1024_nullable",
-                           TypeFactory::GetType(kVarChar, str_type_length, true)));
-
-  str_type_length = 65536;
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_65536_nullable", TypeFactory::GetType(kChar, str_type_length, true)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_65536_nullable",
-                           TypeFactory::GetType(kVarChar, str_type_length, true)));
-
-  TupleStorageSubBlockDescription* tuple_store_description =
-      layout_description.mutable_tuple_store_description();
-  tuple_store_description->set_sub_block_type(
-      TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE);
-  for (int i = 0; i <= rel->getMaxAttributeId(); ++i) {
-    tuple_store_description->AddExtension(
-        CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i);
-  }
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, TemporaryCatalogRelationSerializationTest) {
-  CatalogRelation* const tmp_rel_numeric = createCatalogRelation("tmp_rel_numeric", true);
-
-  tmp_rel_numeric->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 14));
-  tmp_rel_numeric->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 7));
-
-  tmp_rel_numeric->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  tmp_rel_numeric->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  tmp_rel_numeric->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  tmp_rel_numeric->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  CatalogRelation* const tmp_rel_string = createCatalogRelation("tmp_rel_string", true);
-
-  tmp_rel_string->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 19));
-  tmp_rel_string->addBlock(BlockIdUtil::GetBlockId(0 /* domain */, 4));
-
-  StorageBlockLayoutDescription layout_description_string(
-      tmp_rel_string->getDefaultStorageBlockLayout().getDescription());
-
-  std::size_t str_type_length = 0;
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_0", TypeFactory::GetType(kChar, str_type_length)));
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_0", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  str_type_length = 8;
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_8", TypeFactory::GetType(kChar, str_type_length)));
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_8", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  str_type_length = 1024;
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_1024", TypeFactory::GetType(kChar, str_type_length)));
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_1024", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  str_type_length = 65536;
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_65536", TypeFactory::GetType(kChar, str_type_length)));
-  tmp_rel_string->addAttribute(
-      new CatalogAttribute(nullptr, "var_char_length_65536", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  // COMPRESSED_PACKED_ROW_STORE supports variable-length attributes.
-  TupleStorageSubBlockDescription* tuple_store_description_string =
-      layout_description_string.mutable_tuple_store_description();
-  tuple_store_description_string->set_sub_block_type(
-      TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE);
-  for (int i = 0; i <= tmp_rel_string->getMaxAttributeId(); ++i) {
-    tuple_store_description_string->AddExtension(
-        CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i);
-  }
-  tmp_rel_string->setDefaultStorageBlockLayout(new StorageBlockLayout(*tmp_rel_string, layout_description_string));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, DroppedCatalogRelationSerializationTest) {
-  for (int i = 0; i < 20; ++i) {
-    std::ostringstream oss;
-    oss << "rel" << i;
-    createCatalogRelation(oss.str());
-  }
-
-  db_->dropRelationByName("rel10");
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogPackedRowStoreSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  const std::size_t str_type_length = 20;
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_char", TypeFactory::GetType(kChar, str_type_length)));
-  // NOTE(zuyu): PackedRowStoreTupleStorageSubBlock does NOT support variable-length attributes.
-
-  layout_description.mutable_tuple_store_description()->set_sub_block_type(
-      TupleStorageSubBlockDescription::PACKED_ROW_STORE);
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogBasicColumnStoreSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  const std::size_t str_type_length = 120;
-  const attribute_id attr_id =
-      rel->addAttribute(new CatalogAttribute(nullptr, "attr_char", TypeFactory::GetType(kChar, str_type_length)));
-  // NOTE(zuyu): BasicColumnStoreTupleStorageSubBlock does NOT support variable-length attributes.
-
-  TupleStorageSubBlockDescription* tuple_store_description =
-      layout_description.mutable_tuple_store_description();
-  tuple_store_description->set_sub_block_type(TupleStorageSubBlockDescription::BASIC_COLUMN_STORE);
-  tuple_store_description->SetExtension(
-      BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id, attr_id);
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogCompressedPackedRowStoreSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  const std::size_t str_type_length = 1024;
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_char", TypeFactory::GetType(kChar, str_type_length)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_var_char", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  TupleStorageSubBlockDescription* tuple_store_description =
-      layout_description.mutable_tuple_store_description();
-  tuple_store_description->set_sub_block_type(
-      TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE);
-  for (int i = 0; i <= rel->getMaxAttributeId(); ++i) {
-    tuple_store_description->AddExtension(
-        CompressedPackedRowStoreTupleStorageSubBlockDescription::compressed_attribute_id, i);
-  }
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogCompressedColumnStoreSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  const std::size_t str_type_length = 65536;
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_char", TypeFactory::GetType(kChar, str_type_length)));
-  const attribute_id attr_id =
-      rel->addAttribute(
-          new CatalogAttribute(nullptr, "attr_var_char", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  TupleStorageSubBlockDescription* tuple_store_description =
-      layout_description.mutable_tuple_store_description();
-  tuple_store_description->set_sub_block_type(
-      TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE);
-  tuple_store_description->SetExtension(
-      CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id, attr_id);
-  for (int i = 0; i <= rel->getMaxAttributeId(); ++i) {
-    tuple_store_description->AddExtension(
-        CompressedColumnStoreTupleStorageSubBlockDescription::compressed_attribute_id, i);
-  }
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogSplitRowStoreSerializationTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  const std::size_t str_type_length = std::numeric_limits<std::size_t>::max();
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_char", TypeFactory::GetType(kChar, str_type_length)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_var_char", TypeFactory::GetType(kVarChar, str_type_length)));
-
-  layout_description.mutable_tuple_store_description()->set_sub_block_type(
-      TupleStorageSubBlockDescription::SPLIT_ROW_STORE);
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogIndexTest) {
-  CatalogRelation* const rel = createCatalogRelation("rel");
-  StorageBlockLayoutDescription layout_description(rel->getDefaultStorageBlockLayout().getDescription());
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_idx1", TypeFactory::GetType(kInt)));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_idx2", TypeFactory::GetType(kInt)));
-
-  layout_description.mutable_tuple_store_description()->set_sub_block_type(
-      TupleStorageSubBlockDescription::PACKED_ROW_STORE);
-
-  rel->setDefaultStorageBlockLayout(new StorageBlockLayout(*rel, layout_description));
-
-  IndexSubBlockDescription index_description;
-  index_description.set_sub_block_type(IndexSubBlockDescription::CSB_TREE);
-  index_description.add_indexed_attribute_ids(rel->getAttributeByName("attr_idx1")->getID());
-
-  EXPECT_TRUE(rel->addIndex("idx1", std::move(index_description)));
-  EXPECT_TRUE(rel->hasIndexWithName("idx1"));
-  // Adding an index with duplicate name should return false.
-  EXPECT_FALSE(rel->addIndex("idx1", std::move(index_description)));
-  // Adding an index of same type with different name on the same attribute should return false.
-  EXPECT_FALSE(rel->addIndex("idx2", std::move(index_description)));
-
-  index_description.Clear();
-  index_description.set_sub_block_type(IndexSubBlockDescription::CSB_TREE);
-  index_description.add_indexed_attribute_ids(rel->getAttributeByName("attr_idx2")->getID());
-
-  EXPECT_TRUE(rel->addIndex("idx2", std::move(index_description)));
-  EXPECT_TRUE(rel->hasIndexWithName("idx2"));
-
-  checkCatalogSerialization();
-}
-
-TEST_F(CatalogTest, CatalogDatabaseCacheTest) {
-  CatalogRelationSchema* const rel = createCatalogRelation("rel");
-
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_int", TypeFactory::GetType(kInt), -1 /* id */, "int"));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_long", TypeFactory::GetType(kLong)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "attr_float", TypeFactory::GetType(kFloat), -1 /* id */, "float"));
-  rel->addAttribute(new CatalogAttribute(nullptr, "attr_double", TypeFactory::GetType(kDouble)));
-
-  CatalogDatabaseCache cache(db_->getProto());
-  compareCatalogDatabaseCache(cache);
-
-  // Test dropping relations in the cache.
-  cache.dropRelationById(rel->getID());
-  ASSERT_EQ(0u, cache.size());
-
-  // CatalogRelactionSchema changes.
-  const std::size_t str_type_length = 8;
-  rel->addAttribute(
-      new CatalogAttribute(nullptr, "char_length_8", TypeFactory::GetType(kChar, str_type_length)));
-  rel->addAttribute(
-      new CatalogAttribute(nullptr,
-                           "var_char_length_8",
-                           TypeFactory::GetType(kVarChar, str_type_length),
-                           -1 /* id */,
-                           "vchar_8"));
-
-  // Update the cache after the schema changed.
-  cache.update(db_->getProto());
-  compareCatalogDatabaseCache(cache);
-}
-
-}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/catalog/tests/NUMAPlacementScheme_unittest.cpp
----------------------------------------------------------------------
diff --git a/catalog/tests/NUMAPlacementScheme_unittest.cpp b/catalog/tests/NUMAPlacementScheme_unittest.cpp
deleted file mode 100644
index 6a3b32f..0000000
--- a/catalog/tests/NUMAPlacementScheme_unittest.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include <numa.h>
-
-#include <cstddef>
-#include <memory>
-
-#include "catalog/NUMAPlacementScheme.hpp"
-#include "catalog/PartitionSchemeHeader.hpp"
-#include "storage/StorageBlockInfo.hpp"
-
-#include "gtest/gtest.h"
-
-namespace quickstep {
-
-// Test to check if the number of NUMA nodes in the system
-// is the same as the number of NUMA nodes as reported by
-// the NUMAPlacementScheme.
-TEST(NUMAPlacementSchemeTest, CheckNumNUMANodes) {
-  // Number of partitions in the Catalog Relation.
-  std::size_t num_partitions = 4;
-
-  // Create a NUMAPlacementScheme object with the num_partitions.
-  std::unique_ptr<NUMAPlacementScheme> placement_scheme(
-      new NUMAPlacementScheme(num_partitions));
-
-  // Get the number of NUMA nodes in the system.
-  const std::size_t num_numa_nodes = numa_num_configured_nodes();
-
-  // Check if the number of NUMA nodes in NUMAPlacementScheme and that returned
-  // from the system are the same.
-  EXPECT_EQ(num_numa_nodes, placement_scheme->getNumNUMANodes());
-}
-
-// Test to check if the partitions are assigned the available NUMA nodes in a
-// round-robin manner.
-TEST(NUMAPlacementSchemeTest, CheckNUMANodesAssignment) {
-  // Number of partitions in the Catalog Relation.
-  std::size_t num_partitions = 64;
-
-  // Create a NUMAPlacementScheme object with the num_partitions.
-  std::unique_ptr<NUMAPlacementScheme> placement_scheme(
-      new NUMAPlacementScheme(num_partitions));
-
-  // Check that the partitions are assigned to the NUMA nodes in a
-  // round-robbin manner. Partition 0 should be assigned to NUMA node 0,
-  // partition 1 should be assigned to NUMA node 1, and so on. Partition n
-  // should be assigned to NUMA node n modulus number_of_NUMA_nodes.
-  for (std::size_t part_num = 0;
-       part_num < num_partitions;
-       ++part_num) {
-    EXPECT_EQ(static_cast<int>(part_num % placement_scheme->getNumNUMANodes()),
-              placement_scheme->getNUMANodeForPartition(part_num));
-  }
-}
-
-// Test the serialization and deserialization of NUMAPlacementScheme object.
-TEST(NUMAPlacementSchemeTest, NUMAPlacementSchemeSerializationTest) {
-  // Number of blocks in the Catalog Relation.
-  constexpr int kNumBlocks = 10;
-
-  // Number of partitions in the Catalog Relation.
-  std::size_t num_partitions = 64;
-
-  // Create a HashPartitionSchemeHeader object with 64 partitions and attribute
-  //  0 as the partitioning attribute.
-  std::unique_ptr<PartitionSchemeHeader> partition_scheme_header(
-      new HashPartitionSchemeHeader(num_partitions, 0));
-
-  // Create a NUMAPlacementScheme object with the num_partitions.
-  std::unique_ptr<NUMAPlacementScheme> placement_scheme(
-      new NUMAPlacementScheme(num_partitions));
-
-  // Add some entries into block to NUMA node map.
-  for (block_id block = 0; block < kNumBlocks; ++block) {
-    placement_scheme->addBlockToNUMANodeMap(
-        block, block % placement_scheme->getNumNUMANodes());
-  }
-
-  // Check if the BlockToNUMANodeMap has exactly the same entries that we just
-  // inserted..
-  for (block_id block = 0; block < kNumBlocks; ++block) {
-    EXPECT_EQ(static_cast<int>(block % placement_scheme->getNumNUMANodes()),
-              placement_scheme->getNUMANodeForBlock(block));
-  }
-
-  // Create a new placement scheme object from the protobuf version of the
-  // previously created placement scheme object. Note that serialization is done
-  // using getProto() and deserialization is done using
-  // ReconstructFromProto() methods, respectively.
-  std::unique_ptr<NUMAPlacementScheme> placement_scheme_from_proto;
-  placement_scheme_from_proto.reset(
-      NUMAPlacementScheme::ReconstructFromProto(
-          placement_scheme->getProto(), partition_scheme_header->getNumPartitions()));
-
-  // Check if the number of NUMA nodes is the same in both the placement scheme
-  // objects.
-  EXPECT_EQ(placement_scheme->getNumNUMANodes(),
-            placement_scheme_from_proto->getNumNUMANodes());
-
-  // Check if the mapping between the partitions to the NUMA nodes is the same
-  // in both the placement scheme objects.
-  for (std::size_t part_id = 0; part_id < num_partitions; ++part_id) {
-    EXPECT_EQ(placement_scheme->getNUMANodeForPartition(part_id),
-              placement_scheme_from_proto->getNUMANodeForPartition(part_id));
-  }
-
-  // Check if the entries in the block to NUMA node map are the same in both the
-  // placement scheme objects.
-  for (block_id block = 0; block < kNumBlocks; ++block) {
-    EXPECT_EQ(placement_scheme->getNUMANodeForBlock(block),
-              placement_scheme_from_proto->getNUMANodeForBlock(block));
-  }
-}
-
-}  // namespace quickstep