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-75: Fix handling of empty strings
Date Tue, 22 Mar 2016 21:16:03 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 4ec034bbe -> 093f9bd8c


ARROW-75: Fix handling of empty strings

Fixes [ARROW-75](https://issues.apache.org/jira/browse/ARROW-75) (and changes Python tests
to verify that behavior).

Author: Dan Robinson <danrobinson010@gmail.com>

Closes #32 from danrobinson/ARROW-75 and squashes the following commits:

cb8e527 [Dan Robinson] ARROW-75: remove whitespace
9604a21 [Dan Robinson] ARROW-75: Changed tests
722df19 [Dan Robinson] ARROW-75: Fixed braces
1ef3b75 [Dan Robinson] ARROW-75: Fix handling 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/093f9bd8
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/093f9bd8
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/093f9bd8

Branch: refs/heads/master
Commit: 093f9bd8c30b1b77b3e6e7a4123cab9a6dd9daa1
Parents: 4ec034b
Author: Dan Robinson <danrobinson010@gmail.com>
Authored: Tue Mar 22 14:15:38 2016 -0700
Committer: Wes McKinney <wes@cloudera.com>
Committed: Tue Mar 22 14:15:38 2016 -0700

----------------------------------------------------------------------
 cpp/src/arrow/types/primitive.h    | 4 +++-
 cpp/src/arrow/types/string-test.cc | 2 +-
 python/pyarrow/tests/test_array.py | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/093f9bd8/cpp/src/arrow/types/primitive.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/types/primitive.h b/cpp/src/arrow/types/primitive.h
index 1073bb6..22ab59c 100644
--- a/cpp/src/arrow/types/primitive.h
+++ b/cpp/src/arrow/types/primitive.h
@@ -168,7 +168,9 @@ class PrimitiveBuilder : public ArrayBuilder {
       int32_t new_capacity = util::next_power2(length_ + length);
       RETURN_NOT_OK(Resize(new_capacity));
     }
-    memcpy(raw_buffer() + length_, values, length * elsize_);
+    if (length > 0) {
+      memcpy(raw_buffer() + length_, values, length * elsize_);
+    }
 
     if (null_bytes != nullptr) {
       AppendNulls(null_bytes, length);

http://git-wip-us.apache.org/repos/asf/arrow/blob/093f9bd8/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 8e82fd9..6381093 100644
--- a/cpp/src/arrow/types/string-test.cc
+++ b/cpp/src/arrow/types/string-test.cc
@@ -181,7 +181,7 @@ class TestStringBuilder : public TestBuilder {
 };
 
 TEST_F(TestStringBuilder, TestScalarAppend) {
-  std::vector<std::string> strings = {"a", "bb", "", "", "ccc"};
+  std::vector<std::string> strings = {"", "bb", "a", "", "ccc"};
   std::vector<uint8_t> is_null = {0, 0, 0, 1, 0};
 
   int N = strings.size();

http://git-wip-us.apache.org/repos/asf/arrow/blob/093f9bd8/python/pyarrow/tests/test_array.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index 034c157..36aaaa4 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -39,13 +39,13 @@ class TestArrayAPI(unittest.TestCase):
         assert result == expected
 
     def test_string_format(self):
-        arr = pyarrow.from_pylist(['foo', None, 'bar'])
+        arr = pyarrow.from_pylist(['', None, 'foo'])
         result = fmt.array_format(arr)
         expected = """\
 [
-  'foo',
+  '',
   NA,
-  'bar'
+  'foo'
 ]"""
         assert result == expected
 


Mime
View raw message