Repository: arrow
Updated Branches:
  refs/heads/master da24c1a0a -> d946e7917


ARROW-354: Fix comparison of arrays of empty strings

Author: Uwe L. Korn <[email protected]>

Closes #189 from xhochy/ARROW-354 and squashes the following commits:

8f75d78 [Uwe L. Korn] ARROW-354: Fix comparison of arrays of empty strings


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

Branch: refs/heads/master
Commit: d946e7917d55cb220becd6469ae93430f2e60764
Parents: da24c1a
Author: Uwe L. Korn <[email protected]>
Authored: Sat Oct 29 04:36:03 2016 -0400
Committer: Wes McKinney <[email protected]>
Committed: Sat Oct 29 04:36:03 2016 -0400

----------------------------------------------------------------------
 cpp/src/arrow/types/string-test.cc | 12 ++++++++++++
 cpp/src/arrow/types/string.cc      |  2 ++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/d946e791/cpp/src/arrow/types/string-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/types/string-test.cc 
b/cpp/src/arrow/types/string-test.cc
index d897e30..af87a14 100644
--- a/cpp/src/arrow/types/string-test.cc
+++ b/cpp/src/arrow/types/string-test.cc
@@ -129,6 +129,18 @@ TEST_F(TestStringContainer, TestGetString) {
   }
 }
 
+TEST_F(TestStringContainer, TestEmptyStringComparison) {
+  offsets_ = {0, 0, 0, 0, 0, 0};
+  offsets_buf_ = test::to_buffer(offsets_);
+  length_ = offsets_.size() - 1;
+
+  auto strings_a = std::make_shared<StringArray>(
+      length_, offsets_buf_, nullptr, null_count_, null_bitmap_);
+  auto strings_b = std::make_shared<StringArray>(
+      length_, offsets_buf_, nullptr, null_count_, null_bitmap_);
+  ASSERT_TRUE(strings_a->Equals(strings_b));
+}
+
 // ----------------------------------------------------------------------
 // String builder tests
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/d946e791/cpp/src/arrow/types/string.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/types/string.cc b/cpp/src/arrow/types/string.cc
index d692e13..f6d26df 100644
--- a/cpp/src/arrow/types/string.cc
+++ b/cpp/src/arrow/types/string.cc
@@ -56,6 +56,8 @@ bool BinaryArray::EqualsExact(const BinaryArray& other) const 
{
       offset_buffer_->Equals(*other.offset_buffer_, (length_ + 1) * 
sizeof(int32_t));
   if (!equal_offsets) { return false; }
 
+  if (!data_buffer_ && !(other.data_buffer_)) { return true; }
+
   return data_buffer_->Equals(*other.data_buffer_, data_buffer_->size());
 }
 

Reply via email to