You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2016/05/31 19:20:35 UTC
incubator-quickstep git commit: Minor Improvements in Storage.
Repository: incubator-quickstep
Updated Branches:
refs/heads/storage-fix [created] a12548e46
Minor Improvements in Storage.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a12548e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a12548e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a12548e4
Branch: refs/heads/storage-fix
Commit: a12548e46f816afd0ef31b2540071483038774bf
Parents: 50b4e55
Author: Zuyu Zhang <zz...@pivotal.io>
Authored: Tue May 31 12:20:50 2016 -0700
Committer: Zuyu Zhang <zz...@pivotal.io>
Committed: Tue May 31 12:20:50 2016 -0700
----------------------------------------------------------------------
.../BasicColumnStoreTupleStorageSubBlock.cpp | 14 +-
storage/BloomFilterIndexSubBlock.cpp | 7 +-
storage/CMakeLists.txt | 6 +
storage/CSBTreeIndexSubBlock.cpp | 10 +-
...ompressedColumnStoreTupleStorageSubBlock.cpp | 13 +-
...ressedPackedRowStoreTupleStorageSubBlock.cpp | 13 +-
storage/PackedRowStoreTupleStorageSubBlock.cpp | 12 +-
storage/SMAIndexSubBlock.cpp | 4 +-
storage/SplitRowStoreTupleStorageSubBlock.cpp | 12 +-
storage/StorageBlock.cpp | 130 +++++++++----------
storage/StorageBlock.hpp | 6 +-
storage/StorageBlockLayout.cpp | 27 ++--
12 files changed, 130 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/BasicColumnStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/BasicColumnStoreTupleStorageSubBlock.cpp b/storage/BasicColumnStoreTupleStorageSubBlock.cpp
index 0c913ff..3b41af5 100644
--- a/storage/BasicColumnStoreTupleStorageSubBlock.cpp
+++ b/storage/BasicColumnStoreTupleStorageSubBlock.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,8 @@
#include "utility/PtrVector.hpp"
#include "utility/ScopedBuffer.hpp"
+#include "glog/logging.h"
+
using std::memcpy;
using std::memmove;
using std::size_t;
@@ -106,9 +108,9 @@ BasicColumnStoreTupleStorageSubBlock::BasicColumnStoreTupleStorageSubBlock(
sub_block_memory_size),
sorted_(true),
header_(static_cast<BasicColumnStoreHeader*>(sub_block_memory)) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a BasicColumnStoreTupleStorageSubBlock from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a BasicColumnStoreTupleStorageSubBlock from an invalid description:\n"
+ << description_.DebugString();
sort_column_id_ = description_.GetExtension(BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id);
sort_column_type_ = &(relation_.getAttributeById(sort_column_id_)->getType());
@@ -194,7 +196,7 @@ bool BasicColumnStoreTupleStorageSubBlock::DescriptionIsValid(
}
// Check that the specified sort attribute exists and can be ordered by LessComparison.
- attribute_id sort_attribute_id = description.GetExtension(
+ const attribute_id sort_attribute_id = description.GetExtension(
BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id);
if (!relation.hasAttributeWithId(sort_attribute_id)) {
return false;
@@ -211,7 +213,7 @@ bool BasicColumnStoreTupleStorageSubBlock::DescriptionIsValid(
std::size_t BasicColumnStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const TupleStorageSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
// NOTE(chasseur): We round-up the number of bytes needed in the NULL bitmaps
// to avoid estimating 0 bytes needed for a relation with less than 8
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/BloomFilterIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/BloomFilterIndexSubBlock.cpp b/storage/BloomFilterIndexSubBlock.cpp
index e806217..e28bee0 100644
--- a/storage/BloomFilterIndexSubBlock.cpp
+++ b/storage/BloomFilterIndexSubBlock.cpp
@@ -58,8 +58,9 @@ BloomFilterIndexSubBlock::BloomFilterIndexSubBlock(const TupleStorageSubBlock &t
random_seed_(kBloomFilterSeed),
bit_array_size_in_bytes_(description.GetExtension(
BloomFilterIndexSubBlockDescription::bloom_filter_size)) {
- CHECK(DescriptionIsValid(relation_, description_))
- << "Attempted to construct an BloomFilterIndexSubBlock from an invalid description.";
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct an BloomFilterIndexSubBlock from an invalid description:\n"
+ << description_.DebugString();
// Store the attribute ids that are being indexed.
indexed_attribute_ids_.reserve(description.indexed_attribute_ids_size());
@@ -88,7 +89,7 @@ BloomFilterIndexSubBlock::~BloomFilterIndexSubBlock() {
}
bool BloomFilterIndexSubBlock::DescriptionIsValid(const CatalogRelationSchema &relation,
- const IndexSubBlockDescription &description) {
+ const IndexSubBlockDescription &description) {
if (!description.IsInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt
index a77976a..569be3a 100644
--- a/storage/CMakeLists.txt
+++ b/storage/CMakeLists.txt
@@ -284,6 +284,7 @@ target_link_libraries(quickstep_storage_AggregationOperationState_proto
quickstep_storage_HashTable_proto
${PROTOBUF_LIBRARY})
target_link_libraries(quickstep_storage_BasicColumnStoreTupleStorageSubBlock
+ glog
quickstep_catalog_CatalogAttribute
quickstep_catalog_CatalogRelationSchema
quickstep_catalog_CatalogTypedefs
@@ -449,6 +450,7 @@ target_link_libraries(quickstep_storage_CompressedBlockBuilder
quickstep_utility_PtrMap
quickstep_utility_PtrVector)
target_link_libraries(quickstep_storage_CompressedColumnStoreTupleStorageSubBlock
+ glog
quickstep_catalog_CatalogAttribute
quickstep_catalog_CatalogRelationSchema
quickstep_catalog_CatalogTypedefs
@@ -484,6 +486,7 @@ target_link_libraries(quickstep_storage_CompressedColumnStoreValueAccessor
quickstep_utility_Macros
quickstep_utility_PtrMap)
target_link_libraries(quickstep_storage_CompressedPackedRowStoreTupleStorageSubBlock
+ glog
quickstep_catalog_CatalogAttribute
quickstep_catalog_CatalogRelationSchema
quickstep_catalog_CatalogTypedefs
@@ -754,6 +757,7 @@ target_link_libraries(quickstep_storage_LinearOpenAddressingHashTable
quickstep_utility_Macros
quickstep_utility_PrimeNumber)
target_link_libraries(quickstep_storage_PackedRowStoreTupleStorageSubBlock
+ glog
quickstep_catalog_CatalogAttribute
quickstep_catalog_CatalogRelationSchema
quickstep_catalog_CatalogTypedefs
@@ -856,6 +860,7 @@ target_link_libraries(quickstep_storage_SimpleScalarSeparateChainingHashTable
quickstep_utility_Macros
quickstep_utility_PrimeNumber)
target_link_libraries(quickstep_storage_SplitRowStoreTupleStorageSubBlock
+ glog
quickstep_catalog_CatalogRelationSchema
quickstep_expressions_predicate_PredicateCost
quickstep_storage_SplitRowStoreValueAccessor
@@ -888,6 +893,7 @@ target_link_libraries(quickstep_storage_StorageBlob
quickstep_utility_Macros)
target_link_libraries(quickstep_storage_StorageBlock
glog
+ quickstep_catalog_CatalogAttribute
quickstep_catalog_CatalogRelationSchema
quickstep_catalog_CatalogTypedefs
quickstep_expressions_aggregation_AggregationHandle
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/CSBTreeIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CSBTreeIndexSubBlock.cpp b/storage/CSBTreeIndexSubBlock.cpp
index 8535398..bd2ea34 100644
--- a/storage/CSBTreeIndexSubBlock.cpp
+++ b/storage/CSBTreeIndexSubBlock.cpp
@@ -53,6 +53,8 @@
#include "utility/PtrVector.hpp"
#include "utility/ScopedBuffer.hpp"
+#include "glog/logging.h"
+
using std::memcpy;
using std::memmove;
using std::pair;
@@ -245,9 +247,9 @@ CSBTreeIndexSubBlock::CSBTreeIndexSubBlock(const TupleStorageSubBlock &tuple_sto
key_type_(nullptr),
next_free_node_group_(kNodeGroupNone),
num_free_node_groups_(0) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a CSBTreeIndexSubBlock from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a CSBTreeIndexSubBlock from an invalid description:\n"
+ << description_.DebugString();
const int num_indexed_attributes = description_.indexed_attribute_ids_size();
if (num_indexed_attributes > 1) {
@@ -341,7 +343,7 @@ bool CSBTreeIndexSubBlock::DescriptionIsValid(const CatalogRelationSchema &relat
std::size_t CSBTreeIndexSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const IndexSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
size_t key_length = 0;
for (int indexed_attribute_num = 0;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedColumnStoreTupleStorageSubBlock.cpp b/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
index 1173a84..ab1593d 100644
--- a/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
+++ b/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +47,8 @@
#include "utility/Macros.hpp"
#include "utility/PtrVector.hpp"
+#include "glog/logging.h"
+
using std::equal_to;
using std::greater;
using std::less_equal;
@@ -78,10 +80,9 @@ CompressedColumnStoreTupleStorageSubBlock::CompressedColumnStoreTupleStorageSubB
sub_block_memory,
sub_block_memory_size),
uncompressed_nulls_in_sort_column_(0) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a CompressedColumnStoreTupleStorageSubBlock "
- "from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a CompressedColumnStoreTupleStorageSubBlock from an invalid description:\n"
+ << description_.DebugString();
sort_column_id_ = description_.GetExtension(
CompressedColumnStoreTupleStorageSubBlockDescription::sort_attribute_id);
@@ -163,7 +164,7 @@ bool CompressedColumnStoreTupleStorageSubBlock::DescriptionIsValid(
std::size_t CompressedColumnStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const TupleStorageSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
std::unordered_set<attribute_id> compressed_attributes;
for (int compressed_attribute_num = 0;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp b/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
index 163e7df..eb02413 100644
--- a/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
+++ b/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +44,8 @@
#include "utility/BitVector.hpp"
#include "utility/Macros.hpp"
+#include "glog/logging.h"
+
using std::equal_to;
using std::greater;
using std::less_equal;
@@ -71,10 +73,9 @@ CompressedPackedRowStoreTupleStorageSubBlock::CompressedPackedRowStoreTupleStora
sub_block_memory,
sub_block_memory_size),
num_uncompressed_attributes_with_nulls_(0) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a CompressedPackedRowStoreTupleStorageSubBlock "
- "from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a CompressedPackedRowStoreTupleStorageSubBlock from an invalid description:\n"
+ << description_.DebugString();
if ((!new_block) && (*static_cast<tuple_id*>(sub_block_memory_) != 0)) {
initialize();
@@ -138,7 +139,7 @@ bool CompressedPackedRowStoreTupleStorageSubBlock::DescriptionIsValid(
std::size_t CompressedPackedRowStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const TupleStorageSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
std::unordered_set<attribute_id> compressed_attributes;
for (int compressed_attribute_num = 0;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/PackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/PackedRowStoreTupleStorageSubBlock.cpp b/storage/PackedRowStoreTupleStorageSubBlock.cpp
index ef83a29..0d9565f 100644
--- a/storage/PackedRowStoreTupleStorageSubBlock.cpp
+++ b/storage/PackedRowStoreTupleStorageSubBlock.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
* Copyright 2016, Quickstep Research Group, Computer Sciences Department,
* University of Wisconsin\u2014Madison.
*
@@ -40,6 +40,8 @@
#include "utility/BitVector.hpp"
#include "utility/Macros.hpp"
+#include "glog/logging.h"
+
using std::vector;
using std::memcpy;
using std::size_t;
@@ -61,9 +63,9 @@ PackedRowStoreTupleStorageSubBlock::PackedRowStoreTupleStorageSubBlock(
sub_block_memory_size),
header_(static_cast<PackedRowStoreHeader*>(sub_block_memory)),
null_bitmap_bytes_(0) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a PackedRowStoreTupleStorageSubBlock from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a PackedRowStoreTupleStorageSubBlock from an invalid description:\n"
+ << description_.DebugString();
if (sub_block_memory_size < sizeof(PackedRowStoreHeader)) {
throw BlockMemoryTooSmall("PackedRowStoreTupleStorageSubBlock", sub_block_memory_size);
@@ -128,7 +130,7 @@ bool PackedRowStoreTupleStorageSubBlock::DescriptionIsValid(
std::size_t PackedRowStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const TupleStorageSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
// NOTE(chasseur): We round-up the number of bytes needed in the NULL bitmap
// to avoid estimating 0 bytes needed for a relation with less than 8
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/SMAIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SMAIndexSubBlock.cpp b/storage/SMAIndexSubBlock.cpp
index 3a1ccc2..f8bac29 100644
--- a/storage/SMAIndexSubBlock.cpp
+++ b/storage/SMAIndexSubBlock.cpp
@@ -315,10 +315,10 @@ SMAIndexSubBlock::SMAIndexSubBlock(const TupleStorageSubBlock &tuple_store,
attribute_to_entry_(new int[tuple_store.getRelation().size()]),
num_indexed_attributes_(description.indexed_attribute_ids_size()),
initialized_(false) {
- CHECK(DescriptionIsValid(relation_, description_))
+ DCHECK(DescriptionIsValid(relation_, description_))
<< "Attempted to construct an SMAIndexSubBlock from an invalid description.";
- CHECK((sizeof(sma_internal::SMAHeader)
+ DCHECK((sizeof(sma_internal::SMAHeader)
+ (num_indexed_attributes_ * sizeof(SMAEntry))) <= sub_block_memory_size_)
<< "Attempted to create SMAIndexSubBlock without enough space allocated.";
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/SplitRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SplitRowStoreTupleStorageSubBlock.cpp b/storage/SplitRowStoreTupleStorageSubBlock.cpp
index 6c70d0f..b8f425c 100644
--- a/storage/SplitRowStoreTupleStorageSubBlock.cpp
+++ b/storage/SplitRowStoreTupleStorageSubBlock.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,8 @@
#include "utility/Macros.hpp"
#include "utility/ScopedBuffer.hpp"
+#include "glog/logging.h"
+
namespace quickstep {
QUICKSTEP_REGISTER_TUPLE_STORE(SplitRowStoreTupleStorageSubBlock, SPLIT_ROW_STORE);
@@ -100,9 +102,9 @@ SplitRowStoreTupleStorageSubBlock::SplitRowStoreTupleStorageSubBlock(
sub_block_memory,
sub_block_memory_size),
header_(static_cast<Header*>(sub_block_memory)) {
- if (!DescriptionIsValid(relation_, description_)) {
- FATAL_ERROR("Attempted to construct a SplitRowStoreTupleStorageSubBlock from an invalid description.");
- }
+ DCHECK(DescriptionIsValid(relation_, description_))
+ << "Attempted to construct a SplitRowStoreTupleStorageSubBlock from an invalid description."
+ << description_.DebugString();
if (sub_block_memory_size < sizeof(Header)) {
throw BlockMemoryTooSmall("SplitRowStoreTupleStorageSubBlock", sub_block_memory_size);
@@ -166,7 +168,7 @@ bool SplitRowStoreTupleStorageSubBlock::DescriptionIsValid(
std::size_t SplitRowStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const CatalogRelationSchema &relation,
const TupleStorageSubBlockDescription &description) {
- DEBUG_ASSERT(DescriptionIsValid(relation, description));
+ DCHECK(DescriptionIsValid(relation, description));
return relation.getFixedByteLength() // Fixed-length attrs
+ BitVector<true>::BytesNeeded(relation.numNullableAttributes()) // Null bitmap
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/StorageBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp
index fdd438d..173dc57 100644
--- a/storage/StorageBlock.cpp
+++ b/storage/StorageBlock.cpp
@@ -19,13 +19,13 @@
#include "storage/StorageBlock.hpp"
-#include <climits>
#include <memory>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
+#include "catalog/CatalogAttribute.hpp"
#include "catalog/CatalogRelationSchema.hpp"
#include "catalog/CatalogTypedefs.hpp"
#include "expressions/aggregation/AggregationHandle.hpp"
@@ -54,21 +54,21 @@
#include "storage/TupleStorageSubBlock.hpp"
#include "storage/ValueAccessor.hpp"
#include "storage/ValueAccessorUtil.hpp"
+
+#ifdef QUICKSTEP_HAVE_BITWEAVING
+#include "storage/bitweaving/BitWeavingIndexSubBlock.hpp"
+#include "storage/bitweaving/BitWeavingHIndexSubBlock.hpp"
+#include "storage/bitweaving/BitWeavingVIndexSubBlock.hpp"
+#endif
+
#include "types/TypedValue.hpp"
#include "types/containers/ColumnVector.hpp"
#include "types/containers/ColumnVectorsValueAccessor.hpp"
#include "types/containers/Tuple.hpp"
#include "types/operations/comparisons/ComparisonUtil.hpp"
-#include "utility/Macros.hpp"
#include "glog/logging.h"
-#ifdef QUICKSTEP_HAVE_BITWEAVING
-#include "storage/bitweaving/BitWeavingIndexSubBlock.hpp"
-#include "storage/bitweaving/BitWeavingHIndexSubBlock.hpp"
-#include "storage/bitweaving/BitWeavingVIndexSubBlock.hpp"
-#endif
-
using std::make_pair;
using std::pair;
using std::size_t;
@@ -96,12 +96,11 @@ StorageBlock::StorageBlock(const CatalogRelationSchema &relation,
}
layout.copyHeaderTo(block_memory_);
- DEBUG_ASSERT(*static_cast<const int*>(block_memory_) > 0);
+ DCHECK_GT(*static_cast<const int*>(block_memory_), 0);
- if (!block_header_.ParseFromArray(static_cast<char*>(block_memory_) + sizeof(int),
- *static_cast<const int*>(block_memory_))) {
- FATAL_ERROR("A StorageBlockLayout created a malformed StorageBlockHeader.");
- }
+ CHECK(block_header_.ParseFromArray(static_cast<char*>(block_memory_) + sizeof(int),
+ *static_cast<const int*>(block_memory_)))
+ << "A StorageBlockLayout created a malformed StorageBlockHeader.";
// We mark a newly-created block as dirty, so that in the rare case that a
// block is evicted before anything is inserted into it, we still write it
@@ -109,10 +108,10 @@ StorageBlock::StorageBlock(const CatalogRelationSchema &relation,
// to disk.
dirty_ = true;
- DEBUG_ASSERT(block_header_.IsInitialized());
- DEBUG_ASSERT(StorageBlockLayout::DescriptionIsValid(relation_, block_header_.layout()));
- DEBUG_ASSERT(block_header_.index_size_size() == block_header_.layout().index_description_size());
- DEBUG_ASSERT(block_header_.index_size_size() == block_header_.index_consistent_size());
+ DCHECK(block_header_.IsInitialized());
+ DCHECK(StorageBlockLayout::DescriptionIsValid(relation_, block_header_.layout()));
+ DCHECK_EQ(block_header_.index_size_size(), block_header_.layout().index_description_size());
+ DCHECK_EQ(block_header_.index_size_size(), block_header_.index_consistent_size());
} else {
if (block_memory_size < sizeof(int)) {
throw MalformedBlock();
@@ -204,7 +203,7 @@ bool StorageBlock::insertTuple(const Tuple &tuple) {
TupleStorageSubBlock::InsertResult tuple_store_insert_result = tuple_store_->insertTuple(tuple);
if (tuple_store_insert_result.inserted_id < 0) {
- DEBUG_ASSERT(tuple_store_insert_result.ids_mutated == false);
+ DCHECK(!tuple_store_insert_result.ids_mutated);
if (empty_before) {
throw TupleTooLargeForBlock(tuple.getByteSize());
} else {
@@ -218,11 +217,10 @@ bool StorageBlock::insertTuple(const Tuple &tuple) {
update_succeeded = rebuildIndexes(true);
if (!update_succeeded) {
tuple_store_->deleteTuple(tuple_store_insert_result.inserted_id);
- if (!rebuildIndexes(true)) {
- // It should always be possible to rebuild an index with the tuples
- // which it originally contained.
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ // It should always be possible to rebuild an index with the tuples which
+ // it originally contained.
+ CHECK(rebuildIndexes(true))
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
}
} else {
update_succeeded = insertEntryInIndexes(tuple_store_insert_result.inserted_id);
@@ -588,10 +586,9 @@ StorageBlock::UpdateResult StorageBlock::update(
const unordered_map<attribute_id, unique_ptr<const Scalar>> &assignments,
const Predicate *predicate,
InsertDestinationInterface *relocation_destination) {
- if (relation_.getID() != relocation_destination->getRelation().getID()) {
- FATAL_ERROR("StorageBlock::update() called with a relocation_destination "
- "that does not belong to the same relation.");
- }
+ CHECK_EQ(relation_.getID(), relocation_destination->getRelation().getID())
+ << "StorageBlock::update() called with a relocation_destination "
+ << "that does not belong to the same relation.";
UpdateResult retval;
// TODO(chasseur): Be smarter and only update indexes that need to be updated.
@@ -651,13 +648,11 @@ StorageBlock::UpdateResult StorageBlock::update(
} else {
// Make a copy of the tuple with the updated values.
std::vector<TypedValue> updated_tuple_values;
- for (CatalogRelationSchema::const_iterator attr_it = relation_.begin();
- attr_it != relation_.end();
- ++attr_it) {
+ for (const CatalogAttribute &attr : relation_) {
std::unordered_map<attribute_id, TypedValue>::iterator update_it
- = updated_values->find(attr_it->getID());
+ = updated_values->find(attr.getID());
if (update_it == updated_values->end()) {
- updated_tuple_values.emplace_back(tuple_store_->getAttributeValueTyped(*match_it, attr_it->getID()));
+ updated_tuple_values.emplace_back(tuple_store_->getAttributeValueTyped(*match_it, attr.getID()));
updated_tuple_values.back().ensureNotReference();
} else {
updated_tuple_values.emplace_back(std::move(update_it->second));
@@ -889,9 +884,9 @@ void StorageBlock::sort(const PtrVector<Scalar> &order_by, // NOLINT(build/incl
// the method used. Average-case asymptotics is definitely better in the
// later. Need to do an analysis of the two methods.
- DEBUG_ASSERT(order_by.size() == sort_is_ascending.size());
- DEBUG_ASSERT(order_by.size() == null_first.size());
- DEBUG_ASSERT(order_by.size() > 0);
+ DCHECK_EQ(order_by.size(), sort_is_ascending.size());
+ DCHECK_EQ(order_by.size(), null_first.size());
+ DCHECK_GT(order_by.size(), 0u);
// TODO(shoban): We should use reverse_iterator in conjunction with rbegin()
// and rend() for better readability, if PtrVector supports it.
@@ -958,16 +953,14 @@ void StorageBlock::deleteTuples(const Predicate *predicate) {
// Delete tuples from the TupleStorageSubBlock.
if (tuple_store_->bulkDeleteTuples(matches.get())) {
// If the tuple-ID sequence was mutated, rebuild all indices.
- if (!rebuildIndexes(true)) {
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ CHECK(rebuildIndexes(true))
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
} else if (rebuild_some_indices) {
// Rebuild any remaining indices that don't support ad-hoc removal.
for (PtrVector<IndexSubBlock>::iterator it = indices_.begin(); it != indices_.end(); ++it) {
if (!it->supportsAdHocRemove()) {
- if (!it->rebuild()) {
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ CHECK(it->rebuild())
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
}
}
}
@@ -982,7 +975,7 @@ TupleStorageSubBlock* StorageBlock::CreateTupleStorageSubBlock(
const bool new_block,
void *sub_block_memory,
const std::size_t sub_block_memory_size) {
- DEBUG_ASSERT(description.IsInitialized());
+ DCHECK(description.IsInitialized());
switch (description.sub_block_type()) {
case TupleStorageSubBlockDescription::PACKED_ROW_STORE:
return new PackedRowStoreTupleStorageSubBlock(relation,
@@ -1016,7 +1009,7 @@ TupleStorageSubBlock* StorageBlock::CreateTupleStorageSubBlock(
sub_block_memory_size);
default:
if (new_block) {
- FATAL_ERROR("A StorageBlockLayout provided an unknown TupleStorageSubBlockType.");
+ LOG(FATAL) << "A StorageBlockLayout provided an unknown TupleStorageSubBlockType.";
} else {
throw MalformedBlock();
}
@@ -1029,7 +1022,7 @@ IndexSubBlock* StorageBlock::CreateIndexSubBlock(
const bool new_block,
void *sub_block_memory,
const std::size_t sub_block_memory_size) {
- DEBUG_ASSERT(description.IsInitialized());
+ DCHECK(description.IsInitialized());
switch (description.sub_block_type()) {
case IndexSubBlockDescription::BLOOM_FILTER:
return new BloomFilterIndexSubBlock(tuple_store,
@@ -1070,7 +1063,7 @@ IndexSubBlock* StorageBlock::CreateIndexSubBlock(
#endif
default:
if (new_block) {
- FATAL_ERROR("A StorageBlockLayout provided an unknown IndexBlockType.");
+ LOG(FATAL) << "A StorageBlockLayout provided an unknown IndexBlockType.";
} else {
throw MalformedBlock();
}
@@ -1078,9 +1071,9 @@ IndexSubBlock* StorageBlock::CreateIndexSubBlock(
}
bool StorageBlock::insertEntryInIndexes(const tuple_id new_tuple) {
- DEBUG_ASSERT(ad_hoc_insert_supported_);
- DEBUG_ASSERT(new_tuple >= 0);
- DEBUG_ASSERT(all_indices_consistent_);
+ DCHECK(ad_hoc_insert_supported_);
+ DCHECK_GE(new_tuple, 0);
+ DCHECK(all_indices_consistent_);
for (PtrVector<IndexSubBlock>::iterator it = indices_.begin();
it != indices_.end();
@@ -1111,9 +1104,8 @@ bool StorageBlock::insertEntryInIndexes(const tuple_id new_tuple) {
if (tuple_store_->deleteTuple(new_tuple)) {
// The tuple-ID sequence was mutated, so rebuild all indices.
- if (!rebuildIndexes(true)) {
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ CHECK(rebuildIndexes(true))
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
} else if (rebuild_some_indices) {
// Rebuild those indices that were modified that don't support ad-hoc
// removal.
@@ -1121,11 +1113,10 @@ bool StorageBlock::insertEntryInIndexes(const tuple_id new_tuple) {
fixer_it != it;
++fixer_it) {
if (!fixer_it->supportsAdHocRemove()) {
- if (!fixer_it->rebuild()) {
- // It should always be possible to rebuild an index with the
- // tuples which it originally contained.
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ // It should always be possible to rebuild an index with the
+ // tuples which it originally contained.
+ CHECK(fixer_it->rebuild())
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
}
}
}
@@ -1139,8 +1130,8 @@ bool StorageBlock::insertEntryInIndexes(const tuple_id new_tuple) {
bool StorageBlock::bulkInsertEntriesInIndexes(TupleIdSequence *new_tuples,
const bool roll_back_on_failure) {
- DEBUG_ASSERT(ad_hoc_insert_supported_);
- DEBUG_ASSERT(all_indices_consistent_);
+ DCHECK(ad_hoc_insert_supported_);
+ DCHECK(all_indices_consistent_);
// If 'roll_back_on_failure' is false, we will allow some indices to become
// inconsistent.
@@ -1177,9 +1168,8 @@ bool StorageBlock::bulkInsertEntriesInIndexes(TupleIdSequence *new_tuples,
if (tuple_store_->bulkDeleteTuples(new_tuples)) {
// The tuple-ID sequence was mutated, so rebuild all indices.
- if (!rebuildIndexes(true)) {
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ CHECK(rebuildIndexes(true))
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
} else if (rebuild_some_indices) {
// Rebuild those indices that were modified that don't support ad-hoc
// removal.
@@ -1187,11 +1177,10 @@ bool StorageBlock::bulkInsertEntriesInIndexes(TupleIdSequence *new_tuples,
fixer_it != it;
++fixer_it) {
if (!fixer_it->supportsAdHocRemove()) {
- if (!fixer_it->rebuild()) {
- // It should always be possible to rebuild an index with the
- // tuples which it originally contained.
- FATAL_ERROR("Rebuilding an IndexSubBlock failed after removing tuples.");
- }
+ // It should always be possible to rebuild an index with the
+ // tuples which it originally contained.
+ CHECK(fixer_it->rebuild())
+ << "Rebuilding an IndexSubBlock failed after removing tuples.";
}
}
}
@@ -1338,12 +1327,11 @@ AggregationState* StorageBlock::aggregateHelperValueAccessor(
#endif // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
void StorageBlock::updateHeader() {
- DEBUG_ASSERT(*static_cast<const int*>(block_memory_) == block_header_.ByteSize());
+ DCHECK_EQ(*static_cast<const int*>(block_memory_), block_header_.ByteSize());
- if (!block_header_.SerializeToArray(static_cast<char*>(block_memory_) + sizeof(int),
- block_header_.ByteSize())) {
- FATAL_ERROR("Failed to do binary serialization of StorageBlockHeader in StorageBlock::updateHeader()");
- }
+ CHECK(block_header_.SerializeToArray(static_cast<char*>(block_memory_) + sizeof(int),
+ block_header_.ByteSize()))
+ << "Failed to do binary serialization of StorageBlockHeader in StorageBlock::updateHeader()";
}
void StorageBlock::invalidateAllIndexes() {
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/StorageBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.hpp b/storage/StorageBlock.hpp
index 3ae3812..b79455a 100644
--- a/storage/StorageBlock.hpp
+++ b/storage/StorageBlock.hpp
@@ -35,6 +35,8 @@
#include "utility/Macros.hpp"
#include "utility/PtrVector.hpp"
+#include "glog/logging.h"
+
namespace quickstep {
class AggregationHandle;
@@ -182,7 +184,7 @@ class StorageBlock : public StorageBlockBase {
}
inline bool indexIsConsistent(const std::size_t index_id) const {
- DEBUG_ASSERT(index_id < indices_consistent_.size());
+ DCHECK_LT(index_id, indices_consistent_.size());
return indices_consistent_[index_id];
}
@@ -207,7 +209,7 @@ class StorageBlock : public StorageBlockBase {
* @return The specified IndexSubBlock in this block.
**/
inline const IndexSubBlock& getIndexSubBlock(const std::size_t index_id) const {
- DEBUG_ASSERT(index_id < indices_.size());
+ DCHECK_LT(index_id, indices_.size());
return indices_[index_id];
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a12548e4/storage/StorageBlockLayout.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlockLayout.cpp b/storage/StorageBlockLayout.cpp
index e28fc55..9df9620 100644
--- a/storage/StorageBlockLayout.cpp
+++ b/storage/StorageBlockLayout.cpp
@@ -1,6 +1,6 @@
/**
* Copyright 2011-2015 Quickstep Technologies LLC.
- * Copyright 2015 Pivotal Software, Inc.
+ * Copyright 2015-2016 Pivotal Software, Inc.
* Copyright 2016, Quickstep Research Group, Computer Sciences Department,
* University of Wisconsin\u2014Madison.
*
@@ -23,8 +23,6 @@
#include <string>
#include <vector>
-#include "glog/logging.h"
-
#include "catalog/CatalogRelationSchema.hpp"
#include "storage/StorageBlockLayout.pb.h"
#include "storage/StorageConstants.hpp"
@@ -32,6 +30,8 @@
#include "storage/SubBlockTypeRegistry.hpp"
#include "utility/Macros.hpp"
+#include "glog/logging.h"
+
using std::size_t;
using std::string;
using std::strlen;
@@ -51,7 +51,7 @@ StorageBlockLayout::StorageBlockLayout(const CatalogRelationSchema &relation,
// TODO(chasseur): Align sub-blocks to cache line boundaries.
void StorageBlockLayout::finalize() {
- CHECK(DescriptionIsValid(relation_, layout_description_))
+ DCHECK(DescriptionIsValid(relation_, layout_description_))
<< "Called StorageBlockLayout::finalize() with incomplete or invalid layout.";
// Reset the header and copy the layout from this StorageBlockLayout.
@@ -68,7 +68,7 @@ void StorageBlockLayout::finalize() {
block_header_.add_index_consistent(true);
}
- DEBUG_ASSERT(block_header_.IsInitialized());
+ DCHECK(block_header_.IsInitialized());
size_t header_size = getBlockHeaderSize();
if (header_size > layout_description_.num_slots() * kSlotSizeBytes) {
@@ -131,19 +131,18 @@ void StorageBlockLayout::finalize() {
block_header_.set_tuple_store_size(sub_block_space - allocated_sub_block_space);
- DEBUG_ASSERT(block_header_.IsInitialized());
- DEBUG_ASSERT(header_size == getBlockHeaderSize());
+ DCHECK(block_header_.IsInitialized());
+ DCHECK(header_size == getBlockHeaderSize());
}
void StorageBlockLayout::copyHeaderTo(void *dest) const {
- DEBUG_ASSERT(DescriptionIsValid(relation_, layout_description_));
- DEBUG_ASSERT(block_header_.IsInitialized());
+ DCHECK(DescriptionIsValid(relation_, layout_description_));
+ DCHECK(block_header_.IsInitialized());
*static_cast<int*>(dest) = block_header_.ByteSize();
- if (!block_header_.SerializeToArray(static_cast<char*>(dest) + sizeof(int),
- block_header_.ByteSize())) {
- FATAL_ERROR("Failed to do binary serialization of StorageBlockHeader in StorageBlockLayout::copyHeaderTo()");
- }
+ CHECK(block_header_.SerializeToArray(static_cast<char*>(dest) + sizeof(int),
+ block_header_.ByteSize()))
+ << "Failed to do binary serialization of StorageBlockHeader in StorageBlockLayout::copyHeaderTo()";
}
StorageBlockLayout* StorageBlockLayout::GenerateDefaultLayout(const CatalogRelationSchema &relation,
@@ -170,7 +169,7 @@ bool StorageBlockLayout::DescriptionIsValid(const CatalogRelationSchema &relatio
}
std::size_t StorageBlockLayout::estimateTuplesPerBlock() const {
- DEBUG_ASSERT(block_header_.IsInitialized());
+ DCHECK(block_header_.IsInitialized());
return ((layout_description_.num_slots() * kSlotSizeBytes) - getBlockHeaderSize())
/ estimated_bytes_per_tuple_;
}