quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hakanmemiso...@apache.org
Subject incubator-quickstep git commit: Works for NativeColumnVector.
Date Tue, 23 Aug 2016 00:29:56 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/columnvector-append b430e77ad -> 2d30109db


Works for NativeColumnVector.


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

Branch: refs/heads/columnvector-append
Commit: 2d30109db12990a8c01f7262ebe3ffb5d99404ae
Parents: b430e77
Author: Hakan Memisoglu <hakanmemisoglu@apache.org>
Authored: Mon Aug 22 19:29:28 2016 -0500
Committer: Hakan Memisoglu <hakanmemisoglu@apache.org>
Committed: Mon Aug 22 19:29:28 2016 -0500

----------------------------------------------------------------------
 types/containers/ColumnVector.hpp               | 15 +++++++---
 types/containers/ColumnVectorsValueAccessor.hpp |  8 +++--
 utility/BitVector.hpp                           | 31 ++++++++++++++++++--
 3 files changed, 45 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2d30109d/types/containers/ColumnVector.hpp
----------------------------------------------------------------------
diff --git a/types/containers/ColumnVector.hpp b/types/containers/ColumnVector.hpp
index 3953a7f..def1bcf 100644
--- a/types/containers/ColumnVector.hpp
+++ b/types/containers/ColumnVector.hpp
@@ -398,14 +398,16 @@ class NativeColumnVector : public ColumnVector {
     }
     // Let's be generous about new reserved space.
     std::size_t new_actual_length = actual_length_ + casted_column_vector->actual_length_;
-    std::size_t new_reserved_lenth = 0;
+    std::size_t new_reserved_length = 0;
     if (new_actual_length > reserved_length_) {
-      new_reserved_length_ = 2 * new_actual_length;
+      new_reserved_length = 2 * new_actual_length;
     } else {
-      new_reserved_length_ = reserved_length_;
+      new_reserved_length = reserved_length_;
     }
 
-    void *new_buffer = std::realloc(values_, new_reserved_length);
+    void *new_buffer = std::realloc(values_,
+                                    type_length_ * new_reserved_length);
+
     if (new_buffer == nullptr) {
       return false;
     }
@@ -417,6 +419,11 @@ class NativeColumnVector : public ColumnVector {
 
     reserved_length_ = new_reserved_length;
     actual_length_ = new_actual_length;
+
+    if (null_bitmap_) {
+      return null_bitmap_->append((casted_column_vector->null_bitmap_).get());
+    }
+
     return true;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2d30109d/types/containers/ColumnVectorsValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/types/containers/ColumnVectorsValueAccessor.hpp b/types/containers/ColumnVectorsValueAccessor.hpp
index 4f37eb8..a6b8022 100644
--- a/types/containers/ColumnVectorsValueAccessor.hpp
+++ b/types/containers/ColumnVectorsValueAccessor.hpp
@@ -98,11 +98,13 @@ class ColumnVectorsValueAccessor : public ValueAccessor {
     } else {
       ColumnVector *old_column = columns_[index];
       old_column->append(column);
-      const int appended_column_length
-          = column->isNative()
+      if (index == columns_.size() - 1) {
+        const int appended_column_length
+            = column->isNative()
               ? static_cast<const NativeColumnVector*>(column)->size()
               : static_cast<const IndirectColumnVector*>(column)->size();
-      column_length_ += appended_column_length;
+        column_length_ += appended_column_length;
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2d30109d/utility/BitVector.hpp
----------------------------------------------------------------------
diff --git a/utility/BitVector.hpp b/utility/BitVector.hpp
index bb76315..c47d150 100644
--- a/utility/BitVector.hpp
+++ b/utility/BitVector.hpp
@@ -829,6 +829,33 @@ class BitVector {
     return num_bits_;
   }
 
+  bool append(BitVector *other) {
+    std::size_t total_data_array_size = data_array_size_ + other->data_array_size_;
+
+    std::size_t *new_data_array_ = reinterpret_cast<std::size_t*>(std::realloc(data_array_,
total_data_array_size));
+    if (new_data_array_ == nullptr) {
+      return false;
+    }
+    // Swap pointers.
+    std::swap(data_array_, new_data_array_);
+
+    // Copy other BitVector's data.
+    std::memcpy(reinterpret_cast<std::uint8_t*>(data_array_) + data_array_size_,
+                other->data_array_,
+                other->data_array_size_);
+
+    // Not complete (it is working only under vector<std::size_t> impl.)
+    const std::size_t excess_bits_at_original = num_bits_ % kSizeTBits;
+    const std::size_t old_num_bits = num_bits_;
+    // Update private fields to make shiftTailForward work correctly.
+    data_array_size_ = total_data_array_size;
+    num_bits_ = num_bits_ + other->num_bits_;
+
+    shiftTailForward(old_num_bits, excess_bits_at_original);
+
+    return true;
+  }
+
  private:
   // This works as long as the bit-width of size_t is power of 2:
   static const std::size_t kLowerOrderMask = (sizeof(std::size_t) << 3) - 1;
@@ -1166,8 +1193,8 @@ class BitVector {
   const bool owned_;
   const bool short_version_;  // Vector is 32 bits or less, so we use not even a full size_t.
   std::size_t *data_array_;
-  const std::size_t num_bits_;
-  const std::size_t data_array_size_;
+  std::size_t num_bits_;
+  std::size_t data_array_size_;
 
   DISALLOW_COPY_AND_ASSIGN(BitVector);
 };


Mime
View raw message