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/06/09 03:41:46 UTC
[49/50] [abbrv] incubator-quickstep git commit: Minor Improvements in
Storage.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/ColumnStoreUtil.hpp
----------------------------------------------------------------------
diff --git a/storage/ColumnStoreUtil.hpp b/storage/ColumnStoreUtil.hpp
index eec452c..8ff9837 100644
--- a/storage/ColumnStoreUtil.hpp
+++ b/storage/ColumnStoreUtil.hpp
@@ -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.
@@ -30,7 +30,6 @@ namespace quickstep {
class BasicColumnStoreTupleStorageSubBlock;
class CatalogRelationSchema;
class ComparisonPredicate;
-class CompressedColumnStoreTupleStorageSubBlock;
class TupleIdSequence;
namespace column_store_util {
@@ -41,8 +40,7 @@ namespace column_store_util {
/**
* @brief An iterator over the values in a column stripe. Used internally by
- * BasicColumnStoreTupleStorageSubBlock and
- * CompressedColumnStoreTupleStorageSubBlock.
+ * BasicColumnStoreTupleStorageSubBlock.
**/
class ColumnStripeIterator : public std::iterator<std::random_access_iterator_tag, void*> {
public:
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedColumnStoreTupleStorageSubBlock.cpp b/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
index 1173a84..cf14367 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.
@@ -44,9 +44,10 @@
#include "types/operations/comparisons/ComparisonFactory.hpp"
#include "types/operations/comparisons/ComparisonID.hpp"
#include "utility/BitVector.hpp"
-#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 +79,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.");
- }
+ CHECK(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 +163,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;
@@ -201,8 +201,8 @@ std::size_t CompressedColumnStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const void* CompressedColumnStoreTupleStorageSubBlock::getAttributeValue(
const tuple_id tuple,
const attribute_id attr) const {
- DEBUG_ASSERT(hasTupleWithID(tuple));
- DEBUG_ASSERT(supportsUntypedGetAttributeValue(attr));
+ DCHECK(hasTupleWithID(tuple));
+ DCHECK(supportsUntypedGetAttributeValue(attr));
if (dictionary_coded_attributes_[attr]) {
return dictionaries_.atUnchecked(attr).getUntypedValueForCode<true>(
@@ -215,7 +215,7 @@ const void* CompressedColumnStoreTupleStorageSubBlock::getAttributeValue(
TypedValue CompressedColumnStoreTupleStorageSubBlock::getAttributeValueTyped(
const tuple_id tuple,
const attribute_id attr) const {
- DEBUG_ASSERT(hasTupleWithID(tuple));
+ DCHECK(hasTupleWithID(tuple));
if (dictionary_coded_attributes_[attr]) {
return dictionaries_.atUnchecked(attr).getTypedValueForCode(
@@ -258,7 +258,7 @@ ValueAccessor* CompressedColumnStoreTupleStorageSubBlock::createValueAccessor(
}
bool CompressedColumnStoreTupleStorageSubBlock::deleteTuple(const tuple_id tuple) {
- DEBUG_ASSERT(hasTupleWithID(tuple));
+ DCHECK(hasTupleWithID(tuple));
if (compression_info_.uncompressed_attribute_has_nulls(sort_column_id_)
&& uncompressed_column_null_bitmaps_[sort_column_id_].getBit(tuple)) {
@@ -408,8 +408,8 @@ void CompressedColumnStoreTupleStorageSubBlock::rebuild() {
std::uint32_t CompressedColumnStoreTupleStorageSubBlock::compressedGetCode(
const tuple_id tid,
const attribute_id attr_id) const {
- DEBUG_ASSERT(hasTupleWithID(tid));
- DEBUG_ASSERT((dictionary_coded_attributes_[attr_id]) || (truncated_attributes_[attr_id]));
+ DCHECK(hasTupleWithID(tid));
+ DCHECK((dictionary_coded_attributes_[attr_id]) || (truncated_attributes_[attr_id]));
const void *code_location = getAttributePtr<false>(tid, attr_id);
switch (compression_info_.attribute_size(attr_id)) {
case 1:
@@ -419,9 +419,8 @@ std::uint32_t CompressedColumnStoreTupleStorageSubBlock::compressedGetCode(
case 4:
return *static_cast<const std::uint32_t*>(code_location);
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::compressedGetCode()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::compressedGetCode()";
}
}
@@ -561,9 +560,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -601,9 +599,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()";
}
}
return matches;
@@ -700,9 +697,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getCodesInRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCodesInRange()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -740,9 +736,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getCodesInRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCodesInRange()";
}
}
}
@@ -831,7 +826,7 @@ void CompressedColumnStoreTupleStorageSubBlock::shiftUncompressedNullBitmaps(
std::pair<tuple_id, tuple_id> CompressedColumnStoreTupleStorageSubBlock::getCompressedSortColumnRange(
const std::pair<std::uint32_t, std::uint32_t> code_range) const {
- DEBUG_ASSERT(dictionary_coded_attributes_[sort_column_id_] || truncated_attributes_[sort_column_id_]);
+ DCHECK(dictionary_coded_attributes_[sort_column_id_] || truncated_attributes_[sort_column_id_]);
const void *attr_stripe = column_stripes_[sort_column_id_];
pair<tuple_id, tuple_id> tuple_range;
@@ -861,9 +856,8 @@ std::pair<tuple_id, tuple_id> CompressedColumnStoreTupleStorageSubBlock::getComp
- static_cast<const uint32_t*>(attr_stripe);
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << sort_column_id_
- << " in CompressedColumnStoreTupleStorageSubBlock::getCompressedSortColumnRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << sort_column_id_
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCompressedSortColumnRange()";
}
}
@@ -893,9 +887,8 @@ std::pair<tuple_id, tuple_id> CompressedColumnStoreTupleStorageSubBlock::getComp
- static_cast<const uint32_t*>(attr_stripe);
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << sort_column_id_
- << " in CompressedColumnStoreTupleStorageSubBlock::getCompressedSortColumnRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << sort_column_id_
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCompressedSortColumnRange()";
}
}
@@ -945,9 +938,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingComparison()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingComparison()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -982,9 +974,8 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingComparison()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingComparison()";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp b/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
index 163e7df..504c15d 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.
@@ -42,7 +42,8 @@
#include "types/operations/comparisons/ComparisonFactory.hpp"
#include "types/operations/comparisons/ComparisonID.hpp"
#include "utility/BitVector.hpp"
-#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
using std::equal_to;
using std::greater;
@@ -71,10 +72,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.");
- }
+ CHECK(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 +138,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;
@@ -176,8 +176,8 @@ std::size_t CompressedPackedRowStoreTupleStorageSubBlock::EstimateBytesPerTuple(
const void* CompressedPackedRowStoreTupleStorageSubBlock::getAttributeValue(
const tuple_id tuple,
const attribute_id attr) const {
- DEBUG_ASSERT(hasTupleWithID(tuple));
- DEBUG_ASSERT(supportsUntypedGetAttributeValue(attr));
+ DCHECK(hasTupleWithID(tuple));
+ DCHECK(supportsUntypedGetAttributeValue(attr));
if (dictionary_coded_attributes_[attr]) {
return dictionaries_.atUnchecked(attr).getUntypedValueForCode<true>(
@@ -190,7 +190,7 @@ const void* CompressedPackedRowStoreTupleStorageSubBlock::getAttributeValue(
TypedValue CompressedPackedRowStoreTupleStorageSubBlock::getAttributeValueTyped(
const tuple_id tuple,
const attribute_id attr) const {
- DEBUG_ASSERT(hasTupleWithID(tuple));
+ DCHECK(hasTupleWithID(tuple));
if (dictionary_coded_attributes_[attr]) {
return dictionaries_.atUnchecked(attr).getTypedValueForCode(
@@ -237,7 +237,7 @@ ValueAccessor* CompressedPackedRowStoreTupleStorageSubBlock::createValueAccessor
}
bool CompressedPackedRowStoreTupleStorageSubBlock::deleteTuple(const tuple_id tuple) {
- DEBUG_ASSERT(hasTupleWithID(tuple));
+ DCHECK(hasTupleWithID(tuple));
if (tuple == *static_cast<const tuple_id*>(sub_block_memory_) - 1) {
// Simply truncate if only removing the last tuple.
@@ -347,8 +347,8 @@ void CompressedPackedRowStoreTupleStorageSubBlock::rebuild() {
std::uint32_t CompressedPackedRowStoreTupleStorageSubBlock::compressedGetCode(
const tuple_id tid,
const attribute_id attr_id) const {
- DEBUG_ASSERT(hasTupleWithID(tid));
- DEBUG_ASSERT((dictionary_coded_attributes_[attr_id]) || (truncated_attributes_[attr_id]));
+ DCHECK(hasTupleWithID(tid));
+ DCHECK((dictionary_coded_attributes_[attr_id]) || (truncated_attributes_[attr_id]));
const void *code_location = static_cast<const char*>(tuple_storage_)
+ tid * tuple_length_bytes_
+ attribute_offsets_[attr_id];
@@ -360,9 +360,8 @@ std::uint32_t CompressedPackedRowStoreTupleStorageSubBlock::compressedGetCode(
case 4:
return *static_cast<const std::uint32_t*>(code_location);
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::compressedGetCodeInl()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::compressedGetCodeInl()";
}
}
@@ -426,9 +425,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -469,9 +467,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesExcludingNull()";
}
}
return matches;
@@ -536,9 +533,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -579,9 +575,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange()";
}
}
return matches;
@@ -659,9 +654,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyingComparison()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyingComparison()";
}
if (filter != nullptr) {
matches->intersectWith(*filter);
@@ -699,9 +693,8 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
}
break;
default:
- FATAL_ERROR("Unexpected byte-length (not 1, 2, or 4) for compressed "
- "attribute ID " << attr_id
- << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyingComparison()");
+ LOG(FATAL) << "Unexpected byte-length (not 1, 2, or 4) for compressed attribute ID " << attr_id
+ << " in CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyingComparison()";
}
}
return matches;
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/CompressedTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedTupleStorageSubBlock.cpp b/storage/CompressedTupleStorageSubBlock.cpp
index 53379f6..bd29a4e 100644
--- a/storage/CompressedTupleStorageSubBlock.cpp
+++ b/storage/CompressedTupleStorageSubBlock.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.
@@ -24,12 +24,11 @@
#include <utility>
#include <vector>
+#include "catalog/CatalogAttribute.hpp"
#include "catalog/CatalogRelationSchema.hpp"
#include "catalog/CatalogTypedefs.hpp"
#include "compression/CompressionDictionary.hpp"
-#include "compression/CompressionDictionaryLite.hpp"
#include "expressions/predicate/ComparisonPredicate.hpp"
-#include "expressions/predicate/Predicate.hpp"
#include "expressions/scalar/Scalar.hpp"
#include "expressions/scalar/ScalarAttribute.hpp"
#include "storage/CompressedBlockBuilder.hpp"
@@ -39,10 +38,11 @@
#include "storage/TupleIdSequence.hpp"
#include "storage/ValueAccessor.hpp"
#include "storage/ValueAccessorUtil.hpp"
-#include "types/TypedValue.hpp"
-#include "types/containers/Tuple.hpp"
+#include "types/Type.hpp"
+#include "types/TypeID.hpp"
#include "types/operations/comparisons/ComparisonID.hpp"
-#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
using std::ceil;
using std::floor;
@@ -158,93 +158,90 @@ tuple_id CompressedTupleStorageSubBlock::bulkInsertTuplesWithRemappedAttributes(
TupleIdSequence* CompressedTupleStorageSubBlock::getMatchesForPredicate(
const ComparisonPredicate &predicate,
const TupleIdSequence *filter) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
+ DCHECK(builder_.get() == nullptr);
// Determine if the predicate is a comparison of a compressed attribute with
// a literal.
- if (predicate.isAttributeLiteralComparisonPredicate()) {
- const CatalogAttribute *comparison_attribute = NULL;
- if (predicate.getLeftOperand().hasStaticValue()) {
- DEBUG_ASSERT(predicate.getRightOperand().getDataSource() == Scalar::kAttribute);
- comparison_attribute
- = &(static_cast<const ScalarAttribute&>(predicate.getRightOperand()).getAttribute());
- } else {
- DEBUG_ASSERT(predicate.getLeftOperand().getDataSource() == Scalar::kAttribute);
- comparison_attribute
- = &(static_cast<const ScalarAttribute&>(predicate.getLeftOperand()).getAttribute());
- }
- const attribute_id comparison_attribute_id = comparison_attribute->getID();
-
- DEBUG_ASSERT(comparison_attribute->getParent().getID() == relation_.getID());
- if (dictionary_coded_attributes_[comparison_attribute_id]
- || truncated_attributes_[comparison_attribute_id]) {
- const CompressionDictionary *dictionary = nullptr;
- if (dictionary_coded_attributes_[comparison_attribute_id]) {
- dictionary = static_cast<const CompressionDictionary*>(
- dictionaries_.find(comparison_attribute_id)->second);
+ CHECK(predicate.isAttributeLiteralComparisonPredicate())
+ << "Called CompressedTupleStorageSubBlock::getMatchesForPredicate()"
+ << " with a predicate that can only be evaluated with a simple scan.";
+
+ const CatalogAttribute *comparison_attribute = nullptr;
+ if (predicate.getLeftOperand().hasStaticValue()) {
+ DCHECK_EQ(Scalar::kAttribute, predicate.getRightOperand().getDataSource());
+ comparison_attribute
+ = &(static_cast<const ScalarAttribute&>(predicate.getRightOperand()).getAttribute());
+ } else {
+ DCHECK_EQ(Scalar::kAttribute, predicate.getLeftOperand().getDataSource());
+ comparison_attribute
+ = &(static_cast<const ScalarAttribute&>(predicate.getLeftOperand()).getAttribute());
+ }
+ const attribute_id comparison_attribute_id = comparison_attribute->getID();
+
+ DCHECK_EQ(relation_.getID(), comparison_attribute->getParent().getID());
+ DCHECK(dictionary_coded_attributes_[comparison_attribute_id] ||
+ truncated_attributes_[comparison_attribute_id])
+ << "Called CompressedTupleStorageSubBlock::getMatchesForPredicate()"
+ << " with a predicate that can only be evaluated with a simple scan.";
+
+ const CompressionDictionary *dictionary = nullptr;
+ if (dictionary_coded_attributes_[comparison_attribute_id]) {
+ dictionary = static_cast<const CompressionDictionary*>(
+ dictionaries_.find(comparison_attribute_id)->second);
+ }
+ PredicateTransformResult result
+ = CompressedAttributePredicateTransformer::TransformPredicateOnCompressedAttribute(
+ relation_,
+ predicate,
+ dictionary,
+ GetMaxTruncatedValue(compression_info_.attribute_size(comparison_attribute_id)));
+
+ pair<uint32_t, uint32_t> match_range;
+ switch (result.type) {
+ case PredicateTransformResultType::kAll:
+ if (filter == nullptr) {
+ return getExistenceMap();
+ } else {
+ TupleIdSequence *filter_copy = new TupleIdSequence(filter->length());
+ filter_copy->assignFrom(*filter);
+ return filter_copy;
}
- PredicateTransformResult result
- = CompressedAttributePredicateTransformer::TransformPredicateOnCompressedAttribute(
- relation_,
- predicate,
- dictionary,
- GetMaxTruncatedValue(compression_info_.attribute_size(comparison_attribute_id)));
-
- pair<uint32_t, uint32_t> match_range;
- switch (result.type) {
- case PredicateTransformResultType::kAll:
- if (filter == nullptr) {
- return getExistenceMap();
+ // Pass through to base version to get all tuples.
+ return TupleStorageSubBlock::getMatchesForPredicate(predicate, filter);
+ case PredicateTransformResultType::kNone:
+ // No matches.
+ return new TupleIdSequence(*static_cast<const tuple_id*>(sub_block_memory_));
+ case PredicateTransformResultType::kBasicComparison:
+ switch (result.comp) {
+ case ComparisonID::kEqual:
+ return getEqualCodes(comparison_attribute_id, result.first_literal, filter);
+ case ComparisonID::kNotEqual:
+ if (result.exclude_nulls) {
+ return getNotEqualCodesExcludingNull(comparison_attribute_id,
+ result.first_literal,
+ result.second_literal,
+ filter);
} else {
- TupleIdSequence *filter_copy = new TupleIdSequence(filter->length());
- filter_copy->assignFrom(*filter);
- return filter_copy;
+ return getNotEqualCodes(comparison_attribute_id,
+ result.first_literal,
+ filter);
}
- // Pass through to base version to get all tuples.
- return TupleStorageSubBlock::getMatchesForPredicate(predicate, filter);
- case PredicateTransformResultType::kNone:
- // No matches.
- return new TupleIdSequence(*static_cast<const tuple_id*>(sub_block_memory_));
- case PredicateTransformResultType::kBasicComparison:
- switch (result.comp) {
- case ComparisonID::kEqual:
- return getEqualCodes(comparison_attribute_id, result.first_literal, filter);
- case ComparisonID::kNotEqual:
- if (result.exclude_nulls) {
- return getNotEqualCodesExcludingNull(comparison_attribute_id,
- result.first_literal,
- result.second_literal,
- filter);
- } else {
- return getNotEqualCodes(comparison_attribute_id,
+ case ComparisonID::kLess:
+ return getLessCodes(comparison_attribute_id, result.first_literal, filter);
+ case ComparisonID::kGreaterOrEqual:
+ return getGreaterOrEqualCodes(comparison_attribute_id,
result.first_literal,
filter);
- }
- case ComparisonID::kLess:
- return getLessCodes(comparison_attribute_id, result.first_literal, filter);
- case ComparisonID::kGreaterOrEqual:
- return getGreaterOrEqualCodes(comparison_attribute_id,
- result.first_literal,
- filter);
- default:
- FATAL_ERROR("Unexpected ComparisonID in CompressedTupleStorageSubBlock::"
- "getMatchesForPredicate()");
- }
- case PredicateTransformResultType::kRangeComparison:
- match_range.first = result.first_literal;
- match_range.second = result.second_literal;
- return getCodesInRange(comparison_attribute_id, match_range, filter);
default:
- FATAL_ERROR("Unexpected PredicateTransformResultType in CompressedTupleStorageSubBlock::"
- "getMatchesForPredicate()");
+ LOG(FATAL) << "Unexpected ComparisonID in CompressedTupleStorageSubBlock::getMatchesForPredicate()";
}
- } else {
- FATAL_ERROR("Called CompressedTupleStorageSubBlock::getMatchesForPredicate() "
- "with a predicate that can only be evaluated with a simple scan.");
- }
- } else {
- FATAL_ERROR("Called CompressedTupleStorageSubBlock::getMatchesForPredicate() "
- "with a predicate that can only be evaluated with a simple scan.");
+ case PredicateTransformResultType::kRangeComparison:
+ match_range.first = result.first_literal;
+ match_range.second = result.second_literal;
+ return getCodesInRange(comparison_attribute_id, match_range, filter);
+ default:
+ LOG(FATAL)
+ << "Unexpected PredicateTransformResultType in CompressedTupleStorageSubBlock::getMatchesForPredicate()";
}
}
@@ -253,7 +250,7 @@ bool CompressedTupleStorageSubBlock::compressedComparisonIsAlwaysTrueForTruncate
const attribute_id left_attr_id,
const TypedValue &right_literal,
const Type &right_literal_type) const {
- DEBUG_ASSERT(truncated_attributes_[left_attr_id]);
+ DCHECK(truncated_attributes_[left_attr_id]);
return CompressedAttributePredicateTransformer::CompressedComparisonIsAlwaysTrueForTruncatedAttribute(
comp,
@@ -267,7 +264,7 @@ bool CompressedTupleStorageSubBlock::compressedComparisonIsAlwaysFalseForTruncat
const attribute_id left_attr_id,
const TypedValue &right_literal,
const Type &right_literal_type) const {
- DEBUG_ASSERT(truncated_attributes_[left_attr_id]);
+ DCHECK(truncated_attributes_[left_attr_id]);
return CompressedAttributePredicateTransformer::CompressedComparisonIsAlwaysFalseForTruncatedAttribute(
comp,
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/CompressedTupleStorageSubBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/CompressedTupleStorageSubBlock.hpp b/storage/CompressedTupleStorageSubBlock.hpp
index 19ebc7f..a5a0c5a 100644
--- a/storage/CompressedTupleStorageSubBlock.hpp
+++ b/storage/CompressedTupleStorageSubBlock.hpp
@@ -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.
@@ -30,21 +30,23 @@
#include "compression/CompressionDictionary.hpp"
#include "compression/CompressionDictionaryLite.hpp"
#include "storage/CompressedBlockBuilder.hpp"
+#include "storage/StorageBlockInfo.hpp"
#include "storage/StorageBlockLayout.pb.h"
-#include "storage/StorageErrors.hpp"
-#include "storage/TupleIdSequence.hpp"
#include "storage/TupleStorageSubBlock.hpp"
#include "types/operations/comparisons/ComparisonID.hpp"
-#include "types/TypedValue.hpp"
#include "utility/Macros.hpp"
#include "utility/PtrMap.hpp"
+#include "glog/logging.h"
+
namespace quickstep {
class CatalogRelationSchema;
class ComparisonPredicate;
class Tuple;
-class TupleStorageSubBlockDescription;
+class TupleIdSequence;
+class Type;
+class TypedValue;
class ValueAccessor;
/** \addtogroup Storage
@@ -141,8 +143,8 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
void setAttributeValueInPlaceTyped(const tuple_id tuple,
const attribute_id attr,
const TypedValue &value) override {
- FATAL_ERROR("Called CompressedTupleStorageSubBlock::setAttributeValueInPlaceTyped(), "
- "which is not supported.");
+ LOG(FATAL) << "Called CompressedTupleStorageSubBlock::setAttributeValueInPlaceTyped(), "
+ << "which is not supported.";
}
// This override can more efficiently evaluate comparisons between a
@@ -184,7 +186,7 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* attempted.
**/
bool compressedUnbuiltBlockAttributeMayBeCompressed(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() != nullptr);
+ DCHECK(builder_.get() != nullptr);
return builder_->attributeMayBeCompressed(attr_id);
}
@@ -199,7 +201,7 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* compressed, false otherwise.
**/
inline bool compressedAttributeIsDictionaryCompressed(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
+ DCHECK(builder_.get() == nullptr);
return dictionary_coded_attributes_[attr_id];
}
@@ -213,7 +215,7 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* is truncated, false otherwise.
**/
inline bool compressedAttributeIsTruncationCompressed(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
+ DCHECK(builder_.get() == nullptr);
return truncated_attributes_[attr_id];
}
@@ -231,8 +233,8 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* is a Long.
**/
inline bool compressedTruncatedAttributeIsInt(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
- DEBUG_ASSERT(truncated_attributes_[attr_id]);
+ DCHECK(builder_.get() == nullptr);
+ DCHECK(truncated_attributes_[attr_id]);
return truncated_attribute_is_int_[attr_id];
}
@@ -247,7 +249,7 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* uncompressed).
**/
std::size_t compressedGetCompressedAttributeSize(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
+ DCHECK(builder_.get() == nullptr);
return compression_info_.attribute_size(attr_id);
}
@@ -262,15 +264,13 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
* by attr_id.
**/
const CompressionDictionary& compressedGetDictionary(const attribute_id attr_id) const {
- DEBUG_ASSERT(builder_.get() == nullptr);
+ DCHECK(builder_.get() == nullptr);
PtrMap<attribute_id, CompressionDictionaryLite>::const_iterator dict_it
= dictionaries_.find(attr_id);
- if (dict_it == dictionaries_.end()) {
- FATAL_ERROR("Called CompressedTupleStorageSubBlock::getCompressionDictionary() "
- "for an attribute which is not dictionary-compressed.");
- } else {
- return static_cast<const CompressionDictionary&>(*(dict_it->second));
- }
+ DCHECK(dict_it != dictionaries_.end())
+ << "Called CompressedTupleStorageSubBlock::getCompressionDictionary() "
+ << "for an attribute which is not dictionary-compressed.";
+ return static_cast<const CompressionDictionary&>(*(dict_it->second));
}
/**
@@ -340,8 +340,8 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
case 4:
return std::numeric_limits<std::uint32_t>::max() - 1;
default:
- FATAL_ERROR("Unexpected byte_length for truncated value in "
- "CompressedTupleStorageSubBlock::GetMaxTruncatedValue()");
+ LOG(FATAL) << "Unexpected byte_length for truncated value in "
+ << "CompressedTupleStorageSubBlock::GetMaxTruncatedValue()";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/PackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/PackedRowStoreTupleStorageSubBlock.cpp b/storage/PackedRowStoreTupleStorageSubBlock.cpp
index ef83a29..a2fe7ca 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.");
- }
+ CHECK(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/66ccceed/storage/SplitRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SplitRowStoreTupleStorageSubBlock.cpp b/storage/SplitRowStoreTupleStorageSubBlock.cpp
index 6c70d0f..747e20d 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.");
- }
+ CHECK(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/66ccceed/storage/StorageBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp
index fdd438d..6e9b12f 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;
@@ -91,57 +91,30 @@ StorageBlock::StorageBlock(const CatalogRelationSchema &relation,
all_indices_inconsistent_(false),
relation_(relation) {
if (new_block) {
- if (block_memory_size_ < layout.getBlockHeaderSize()) {
- throw BlockMemoryTooSmall("StorageBlock", block_memory_size_);
- }
-
- layout.copyHeaderTo(block_memory_);
- DEBUG_ASSERT(*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.");
- }
-
// 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
// (and the header plus any sub-block specific fixed data structures) back
// 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());
- } else {
- if (block_memory_size < sizeof(int)) {
- throw MalformedBlock();
- }
- if (*static_cast<const int*>(block_memory_) <= 0) {
- throw MalformedBlock();
- }
- if (*static_cast<const int*>(block_memory_) + sizeof(int) > block_memory_size_) {
- throw MalformedBlock();
- }
+ DCHECK_GE(block_memory_size_, layout.getBlockHeaderSize())
+ << "BlockMemoryTooSmall: " << block_memory_size_ << " bytes is too small for StorageBlock";
- if (!block_header_.ParseFromArray(static_cast<char*>(block_memory_) + sizeof(int),
- *static_cast<const int*>(block_memory_))) {
- throw MalformedBlock();
- }
- if (!block_header_.IsInitialized()) {
- throw MalformedBlock();
- }
- if (!StorageBlockLayout::DescriptionIsValid(relation_, block_header_.layout())) {
- throw MalformedBlock();
- }
- if (block_header_.index_size_size() != block_header_.layout().index_description_size()) {
- throw MalformedBlock();
- }
- if (block_header_.index_size_size() != block_header_.index_consistent_size()) {
- throw MalformedBlock();
- }
+ layout.copyHeaderTo(block_memory_);
+ } else {
+ DCHECK_GT(*static_cast<const int*>(block_memory_), 0);
+ DCHECK_LE(*static_cast<const int*>(block_memory_) + sizeof(int), block_memory_size_);
}
+ CHECK(block_header_.ParseFromArray(static_cast<char*>(block_memory_) + sizeof(int),
+ *static_cast<const int*>(block_memory_)))
+ << "A StorageBlockLayout created a malformed StorageBlockHeader.";
+
+ CHECK(block_header_.IsInitialized());
+ CHECK(StorageBlockLayout::DescriptionIsValid(relation_, block_header_.layout()));
+ CHECK_EQ(block_header_.index_size_size(), block_header_.layout().index_description_size());
+ CHECK_EQ(block_header_.index_size_size(), block_header_.index_consistent_size());
+
size_t block_size_from_metadata = *static_cast<const int*>(block_memory_) + sizeof(int);
block_size_from_metadata += block_header_.tuple_store_size();
for (int index_num = 0;
@@ -204,7 +177,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 +191,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 +560,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 +622,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 +858,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 +927,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 +949,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 +983,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 +996,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 +1037,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 +1045,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 +1078,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 +1087,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 +1104,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 +1142,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 +1151,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 +1301,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/66ccceed/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/66ccceed/storage/StorageBlockLayout.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlockLayout.cpp b/storage/StorageBlockLayout.cpp
index e28fc55..65beed3 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;
@@ -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_;
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/TupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/TupleStorageSubBlock.cpp b/storage/TupleStorageSubBlock.cpp
index aafcd33..2e4eae4 100644
--- a/storage/TupleStorageSubBlock.cpp
+++ b/storage/TupleStorageSubBlock.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.
@@ -22,8 +22,6 @@
#endif
#include "storage/TupleIdSequence.hpp"
-#include "storage/ValueAccessor.hpp"
-#include "utility/Macros.hpp"
#ifdef QUICKSTEP_DEBUG
#include "catalog/CatalogAttribute.hpp"
@@ -33,6 +31,8 @@
#include "types/containers/Tuple.hpp"
#endif
+#include "glog/logging.h"
+
namespace quickstep {
tuple_id TupleStorageSubBlock::numTuples() const {
@@ -49,7 +49,7 @@ tuple_id TupleStorageSubBlock::numTuples() const {
}
}
// Should have at least one tuple, otherwise isEmpty() would have been true.
- DEBUG_ASSERT(count > 0);
+ DCHECK_GT(count, 0);
return count;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/66ccceed/storage/TupleStorageSubBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/TupleStorageSubBlock.hpp b/storage/TupleStorageSubBlock.hpp
index 6da4698..8cee3b9 100644
--- a/storage/TupleStorageSubBlock.hpp
+++ b/storage/TupleStorageSubBlock.hpp
@@ -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.
@@ -18,6 +18,7 @@
#ifndef QUICKSTEP_STORAGE_TUPLE_STORAGE_SUB_BLOCK_HPP_
#define QUICKSTEP_STORAGE_TUPLE_STORAGE_SUB_BLOCK_HPP_
+#include <cstddef>
#include <unordered_map>
#include <vector>
@@ -28,6 +29,8 @@
#include "types/TypedValue.hpp"
#include "utility/Macros.hpp"
+#include "glog/logging.h"
+
namespace quickstep {
class CatalogRelationSchema;
@@ -404,9 +407,9 @@ class TupleStorageSubBlock {
**/
virtual TupleIdSequence* getMatchesForPredicate(const ComparisonPredicate &predicate,
const TupleIdSequence *filter) const {
- FATAL_ERROR("Called TupleStorageSubBlock::getMatchesForPredicate() on a "
- "TupleStorageStorageBlock that does not provide any non-scan "
- "method for evaluating predicates.");
+ LOG(FATAL) << "Called TupleStorageSubBlock::getMatchesForPredicate() on a "
+ << "TupleStorageStorageBlock that does not provide any non-scan "
+ << "method for evaluating predicates.";
}
/**