arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-543: C++: Lazily computed null_counts counts number of non-null entries
Date Wed, 08 Feb 2017 20:05:36 GMT
Repository: arrow
Updated Branches:
  refs/heads/master b99d049c3 -> 4440e4011


ARROW-543: C++: Lazily computed null_counts counts number of non-null entries

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #329 from xhochy/ARROW-543 and squashes the following commits:

191792b [Uwe L. Korn] ARROW-543: C++: Lazily computed null_counts counts number of non-null
entries


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/4440e401
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/4440e401
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/4440e401

Branch: refs/heads/master
Commit: 4440e4011d88967a53054486f9eb0a0363a1c217
Parents: b99d049
Author: Uwe L. Korn <uwelk@xhochy.com>
Authored: Wed Feb 8 15:05:29 2017 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Wed Feb 8 15:05:29 2017 -0500

----------------------------------------------------------------------
 cpp/src/arrow/array-test.cc | 8 ++++----
 cpp/src/arrow/array.cc      | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/4440e401/cpp/src/arrow/array-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 45130d8..45ab274 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -88,20 +88,20 @@ TEST_F(TestArray, TestEquality) {
 }
 
 TEST_F(TestArray, SliceRecomputeNullCount) {
-  std::vector<uint8_t> valid_bytes = {1, 0, 1, 1, 0, 1, 0, 0};
+  std::vector<uint8_t> valid_bytes = {1, 0, 1, 1, 0, 1, 0, 0, 0};
 
   auto array = MakeArrayFromValidBytes(valid_bytes, pool_);
 
-  ASSERT_EQ(4, array->null_count());
+  ASSERT_EQ(5, array->null_count());
 
   auto slice = array->Slice(1, 4);
   ASSERT_EQ(2, slice->null_count());
 
   slice = array->Slice(4);
-  ASSERT_EQ(1, slice->null_count());
+  ASSERT_EQ(4, slice->null_count());
 
   slice = array->Slice(0);
-  ASSERT_EQ(4, slice->null_count());
+  ASSERT_EQ(5, slice->null_count());
 
   // No bitmap, compute 0
   std::shared_ptr<MutableBuffer> data;

http://git-wip-us.apache.org/repos/asf/arrow/blob/4440e401/cpp/src/arrow/array.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.cc b/cpp/src/arrow/array.cc
index 39459a0..bf368d9 100644
--- a/cpp/src/arrow/array.cc
+++ b/cpp/src/arrow/array.cc
@@ -48,13 +48,14 @@ Array::Array(const std::shared_ptr<DataType>& type, int32_t
length,
       null_count_(null_count),
       null_bitmap_(null_bitmap),
       null_bitmap_data_(nullptr) {
+  if (null_count_ == 0) { null_bitmap_ = nullptr; }
   if (null_bitmap_) { null_bitmap_data_ = null_bitmap_->data(); }
 }
 
 int32_t Array::null_count() const {
   if (null_count_ < 0) {
     if (null_bitmap_) {
-      null_count_ = CountSetBits(null_bitmap_data_, offset_, length_);
+      null_count_ = length_ - CountSetBits(null_bitmap_data_, offset_, length_);
     } else {
       null_count_ = 0;
     }


Mime
View raw message