quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbdeshm...@apache.org
Subject [07/14] incubator-quickstep git commit: Refactor ScalarAttribute to take benefit of ColumnAccessors
Date Wed, 19 Oct 2016 21:16:44 GMT
Refactor ScalarAttribute to take benefit of ColumnAccessors


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

Branch: refs/heads/fix-fasthash-destructor
Commit: e84524686d77397912052772224d7cfe8dec824a
Parents: 262ad5a
Author: Saket Saurabh <ssaurabh@cs.wisc.edu>
Authored: Fri Sep 23 12:42:40 2016 -0500
Committer: Saket Saurabh <ssaurabh@cs.wisc.edu>
Committed: Tue Oct 11 11:36:57 2016 -0500

----------------------------------------------------------------------
 expressions/scalar/ScalarAttribute.cpp          | 43 ++++++++++++++++----
 storage/BasicColumnStoreValueAccessor.hpp       |  2 +-
 storage/PackedRowStoreValueAccessor.hpp         |  2 +-
 storage/ValueAccessor.hpp                       |  4 +-
 ...kedRowStoreTupleStorageSubBlock_unittest.cpp | 10 ++---
 .../comparisons/AsciiStringComparators-inl.hpp  |  8 ++--
 types/operations/comparisons/Comparison-inl.hpp |  4 +-
 .../comparisons/LiteralComparators-inl.hpp      | 10 ++---
 .../PatternMatchingComparators-inl.hpp          |  2 +-
 9 files changed, 55 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/expressions/scalar/ScalarAttribute.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarAttribute.cpp b/expressions/scalar/ScalarAttribute.cpp
index 08dc9dd..b29286b 100644
--- a/expressions/scalar/ScalarAttribute.cpp
+++ b/expressions/scalar/ScalarAttribute.cpp
@@ -100,18 +100,43 @@ ColumnVector* ScalarAttribute::getAllValues(ValueAccessor *accessor,
                                                           accessor->getNumTuples());
       accessor->beginIteration();
       if (result_type.isNullable()) {
-        while (accessor->next()) {
-          const void *value = accessor->template getUntypedValue<true>(attr_id);
-          if (value == nullptr) {
-            result->appendNullValue();
-          } else {
-            result->appendUntypedValue(value);
+        if (accessor->isColumnAccessorSupported()) {
+          // If ColumnAccessor is supported on the underlying accessor, we have a fast strided
+          // column accessor available for the iteration on the underlying block.
+          // Since the attributes can be null, ColumnAccessor template takes a 'true' argument.
+          std::unique_ptr<const ColumnAccessor<true>>
+              column_accessor(accessor->template getColumnAccessor<true>(attr_id));
+          while (accessor->next()) {
+            const void *value = column_accessor->getUntypedValue();  // Fast strided access.
+            if (value == nullptr) {
+              result->appendNullValue();
+            } else {
+              result->appendUntypedValue(value);
+            }
+          }
+        } else {
+          while (accessor->next()) {
+            const void *value = accessor->template getUntypedValue<true>(attr_id);
+            if (value == nullptr) {
+              result->appendNullValue();
+            } else {
+              result->appendUntypedValue(value);
+            }
           }
         }
       } else {
-        while (accessor->next()) {
-          result->appendUntypedValue(
-              accessor->template getUntypedValue<false>(attr_id));
+        if (accessor->isColumnAccessorSupported()) {
+          // Since the attributes cannot be null, ColumnAccessor template takes a 'false'
argument.
+          std::unique_ptr<const ColumnAccessor<false>>
+              column_accessor(accessor->template getColumnAccessor<false>(attr_id));
+          while (accessor->next()) {
+            result->appendUntypedValue(column_accessor->getUntypedValue());  // Fast
strided access.
+          }
+        } else {
+          while (accessor->next()) {
+            result->appendUntypedValue(
+                accessor->template getUntypedValue<false>(attr_id));
+          }
         }
       }
       return result;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/storage/BasicColumnStoreValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/storage/BasicColumnStoreValueAccessor.hpp b/storage/BasicColumnStoreValueAccessor.hpp
index 22d3c0b..7516dc9 100644
--- a/storage/BasicColumnStoreValueAccessor.hpp
+++ b/storage/BasicColumnStoreValueAccessor.hpp
@@ -81,7 +81,7 @@ class BasicColumnStoreValueAccessorHelper {
   template <bool check_null = true>
   inline const ColumnAccessor<check_null>* getColumnAccessor(const tuple_id &current_tuple_position,
                                                              const attribute_id attr_id)
const {
-    DEBUG_ASSERT(relation_.hasAttributeWithId(attr_id));
+    DCHECK(relation_.hasAttributeWithId(attr_id));
     const void* base_location = static_cast<const char*>(column_stripes_[attr_id]);
     const std::size_t stride = relation_.getAttributeById(attr_id)->getType().maximumByteLength();
     std::unique_ptr<ColumnAccessor<check_null>> column_accessor;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/storage/PackedRowStoreValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/storage/PackedRowStoreValueAccessor.hpp b/storage/PackedRowStoreValueAccessor.hpp
index 7eb2d41..9d43955 100644
--- a/storage/PackedRowStoreValueAccessor.hpp
+++ b/storage/PackedRowStoreValueAccessor.hpp
@@ -78,7 +78,7 @@ class PackedRowStoreValueAccessorHelper {
   template <bool check_null = true>
   inline const ColumnAccessor<check_null>* getColumnAccessor(const tuple_id &current_tuple_position,
                                                              const attribute_id attr_id)
const {
-    DEBUG_ASSERT(relation_.hasAttributeWithId(attr_id));
+    DCHECK(relation_.hasAttributeWithId(attr_id));
     const void* base_location = static_cast<const char*>(tuple_storage_)
         + relation_.getFixedLengthAttributeOffset(attr_id);
     const std::size_t stride = relation_.getFixedByteLength();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/storage/ValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/storage/ValueAccessor.hpp b/storage/ValueAccessor.hpp
index 3b58a7c..e4a2906 100644
--- a/storage/ValueAccessor.hpp
+++ b/storage/ValueAccessor.hpp
@@ -1016,9 +1016,9 @@ class ColumnAccessor {
    * @return An untyped pointer to the attribute value for the current tuple.
    **/
   inline const void* getUntypedValue() const {
-    DEBUG_ASSERT(current_tuple_position_ < num_tuples_);
+    DCHECK(current_tuple_position_ < num_tuples_);
     if (check_null) {
-      DEBUG_ASSERT(null_bitmap_ != nullptr);
+      DCHECK(null_bitmap_ != nullptr);
       if ((nullable_base_ != -1)
           && null_bitmap_->getBit(current_tuple_position_ * nullable_stride_ +
nullable_base_)) {
         return nullptr;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/storage/tests/PackedRowStoreTupleStorageSubBlock_unittest.cpp
----------------------------------------------------------------------
diff --git a/storage/tests/PackedRowStoreTupleStorageSubBlock_unittest.cpp b/storage/tests/PackedRowStoreTupleStorageSubBlock_unittest.cpp
index a6f6606..924f9b1 100644
--- a/storage/tests/PackedRowStoreTupleStorageSubBlock_unittest.cpp
+++ b/storage/tests/PackedRowStoreTupleStorageSubBlock_unittest.cpp
@@ -250,7 +250,7 @@ class PackedRowStoreTupleStorageSubBlockTest : public ::testing::TestWithParam<b
                                                     tuple_store_->getAttributeValueTyped(tid,
2)));
     }
   }
-  
+
   template<bool check_null>
   void checkColumnAccessor() {
     initializeNewBlock(kSubBlockSize);
@@ -269,7 +269,7 @@ class PackedRowStoreTupleStorageSubBlockTest : public ::testing::TestWithParam<b
       while (accessor->next()) {
         const void *va_value = column_accessor->getUntypedValue();
         std::unique_ptr<Tuple> expected_tuple(createSampleTuple(tid));
-         
+
         if (expected_tuple->getAttributeValue(value_accessor_id).isNull()) {
           ASSERT_TRUE(va_value == nullptr);
         } else {
@@ -406,11 +406,11 @@ TEST_P(PackedRowStoreTupleStorageSubBlockTest, InsertInBatchTest) {
   EXPECT_EQ(row_capacity - 1, tuple_store_->getMaxTupleID());
   EXPECT_EQ(row_capacity, tuple_store_->numTuples());
 }
-  
+
 TEST_P(PackedRowStoreTupleStorageSubBlockTest, ColumnAccessorTest) {
-  if (GetParam()) { // when true, the attributes can be nullable.
+  if (GetParam()) {   // when true, the attributes can be nullable.
     checkColumnAccessor<true>();
-  } else { // when false, the attributes are non-null.
+  } else {   // when false, the attributes are non-null.
     checkColumnAccessor<false>();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/types/operations/comparisons/AsciiStringComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/AsciiStringComparators-inl.hpp b/types/operations/comparisons/AsciiStringComparators-inl.hpp
index b048c60..87d7168 100644
--- a/types/operations/comparisons/AsciiStringComparators-inl.hpp
+++ b/types/operations/comparisons/AsciiStringComparators-inl.hpp
@@ -280,8 +280,8 @@ TupleIdSequence* AsciiStringUncheckedComparator<ComparisonFunctor,
             left_column_accessor(accessor->template getColumnAccessor<left_nullable>(left_id));
         std::unique_ptr<const ColumnAccessor<right_nullable>>
             right_column_accessor(accessor->template getColumnAccessor<right_nullable>(right_id));
-        DEBUG_ASSERT(left_column_accessor != nullptr);
-        DEBUG_ASSERT(right_column_accessor != nullptr);
+        DCHECK(left_column_accessor != nullptr);
+        DCHECK(right_column_accessor != nullptr);
         while (accessor->next()) {
           const void *left_value = left_column_accessor->getUntypedValue();
           const void *right_value = right_column_accessor->getUntypedValue();
@@ -357,7 +357,7 @@ TupleIdSequence* AsciiStringUncheckedComparator<ComparisonFunctor,
         // column accessor available for the iteration on the underlying block.
         std::unique_ptr<const ColumnAccessor<va_nullable>>
             column_accessor(accessor->template getColumnAccessor<va_nullable>(value_accessor_attr_id));
-        DEBUG_ASSERT(column_accessor != nullptr);
+        DCHECK(column_accessor != nullptr);
         while (accessor->next()) {
           const void *va_value = column_accessor->getUntypedValue();
           result->set(accessor->getCurrentPosition(),
@@ -488,7 +488,7 @@ TupleIdSequence* AsciiStringUncheckedComparator<ComparisonFunctor,
             // column accessor available for the iteration on the underlying block.
             std::unique_ptr<const ColumnAccessor<va_nullable>>
                 column_accessor(accessor->template getColumnAccessor<va_nullable>(value_accessor_attr_id));
-            DEBUG_ASSERT(column_accessor != nullptr);
+            DCHECK(column_accessor != nullptr);
             while (accessor->next()) {
               const void *cv_value
                   = column_vector.template getUntypedValue<cv_nullable>(cv_pos);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/types/operations/comparisons/Comparison-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/Comparison-inl.hpp b/types/operations/comparisons/Comparison-inl.hpp
index 96771bf..c892a16 100644
--- a/types/operations/comparisons/Comparison-inl.hpp
+++ b/types/operations/comparisons/Comparison-inl.hpp
@@ -316,8 +316,8 @@ TupleIdSequence* UncheckedComparator::compareSingleValueAccessorDefaultImpl(
             left_column_accessor(accessor->template getColumnAccessor<left_nullable>(left_id));
         std::unique_ptr<const ColumnAccessor<right_nullable>>
             right_column_accessor(accessor->template getColumnAccessor<right_nullable>(right_id));
-        DEBUG_ASSERT(left_column_accessor != nullptr);
-        DEBUG_ASSERT(right_column_accessor != nullptr);
+        DCHECK(left_column_accessor != nullptr);
+        DCHECK(right_column_accessor != nullptr);
         while (accessor->next()) {
           result->set(accessor->getCurrentPosition(),
                       this->compareDataPtrs(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/types/operations/comparisons/LiteralComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/LiteralComparators-inl.hpp b/types/operations/comparisons/LiteralComparators-inl.hpp
index 31eec13..fd59e2e 100644
--- a/types/operations/comparisons/LiteralComparators-inl.hpp
+++ b/types/operations/comparisons/LiteralComparators-inl.hpp
@@ -280,8 +280,8 @@ TupleIdSequence* LiteralUncheckedComparator<ComparisonFunctor,
             left_column_accessor(accessor->template getColumnAccessor<left_nullable>(left_id));
         std::unique_ptr<const ColumnAccessor<right_nullable>>
             right_column_accessor(accessor->template getColumnAccessor<right_nullable>(right_id));
-        DEBUG_ASSERT(left_column_accessor != nullptr);
-        DEBUG_ASSERT(right_column_accessor != nullptr);
+        DCHECK(left_column_accessor != nullptr);
+        DCHECK(right_column_accessor != nullptr);
         while (accessor->next()) {
           const void *left_value = left_column_accessor->getUntypedValue();
           const void *right_value = right_column_accessor->getUntypedValue();
@@ -363,7 +363,7 @@ TupleIdSequence* LiteralUncheckedComparator<ComparisonFunctor,
         // column accessor available for the iteration on the underlying block.
         std::unique_ptr<const ColumnAccessor<va_nullable>>
             column_accessor(accessor->template getColumnAccessor<va_nullable>(value_accessor_attr_id));
-        DEBUG_ASSERT(column_accessor != nullptr);
+        DCHECK(column_accessor != nullptr);
         while (accessor->next()) {
           const void *va_value = column_accessor->getUntypedValue();
           result->set(accessor->getCurrentPosition(),
@@ -497,7 +497,7 @@ TupleIdSequence* LiteralUncheckedComparator<ComparisonFunctor,
           // column accessor available for the iteration on the underlying block.
           std::unique_ptr<const ColumnAccessor<va_nullable>>
               column_accessor(accessor->template getColumnAccessor<va_nullable>(value_accessor_attr_id));
-          DEBUG_ASSERT(column_accessor != nullptr);
+          DCHECK(column_accessor != nullptr);
           while (accessor->next()) {
             const void *cv_value
                 = native_column_vector.getUntypedValue<cv_nullable>(cv_pos);
@@ -554,7 +554,7 @@ TypedValue LiteralUncheckedComparator<ComparisonFunctor,
       // column accessor available for the iteration on the underlying block.
       std::unique_ptr<const ColumnAccessor<left_nullable>>
           column_accessor(accessor->template getColumnAccessor<left_nullable>(value_accessor_id));
-      DEBUG_ASSERT(column_accessor != nullptr);
+      DCHECK(column_accessor != nullptr);
       while (accessor->next()) {
         const void *va_value = column_accessor->getUntypedValue();
         if (left_nullable && !va_value) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e8452468/types/operations/comparisons/PatternMatchingComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/PatternMatchingComparators-inl.hpp b/types/operations/comparisons/PatternMatchingComparators-inl.hpp
index ca0f45e..a7f0777 100644
--- a/types/operations/comparisons/PatternMatchingComparators-inl.hpp
+++ b/types/operations/comparisons/PatternMatchingComparators-inl.hpp
@@ -247,7 +247,7 @@ TupleIdSequence* PatternMatchingUncheckedComparator<is_like_pattern,
is_negation
         std::unique_ptr<const ColumnAccessor<left_nullable>>
             column_accessor
             (accessor->template getColumnAccessor<left_nullable>(value_accessor_attr_id));
-        DEBUG_ASSERT(column_accessor != nullptr);
+        DCHECK(column_accessor != nullptr);
         while (accessor->next()) {
           const void *va_value = column_accessor->getUntypedValue();
           result->set(accessor->getCurrentPosition(),


Mime
View raw message