You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/03/18 20:47:18 UTC
arrow git commit: ARROW-639: [C++] Invalid offset in slices
Repository: arrow
Updated Branches:
refs/heads/master 019f90d75 -> 98c949018
ARROW-639: [C++] Invalid offset in slices
Fix incrementing offest_ twice in Slice
Author: Miki Tebeka <mi...@gmail.com>
Closes #387 from tebeka/ARROW-639 and squashes the following commits:
6520f4c [Miki Tebeka] fix lint error
95fca13 [Miki Tebeka] [ARROW-639] [C++] Invalid offset in slices
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/98c94901
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/98c94901
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/98c94901
Branch: refs/heads/master
Commit: 98c9490180aed2b24be395e80f50e7f606fadcd5
Parents: 019f90d
Author: Miki Tebeka <mi...@gmail.com>
Authored: Sat Mar 18 16:47:13 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Sat Mar 18 16:47:13 2017 -0400
----------------------------------------------------------------------
cpp/src/arrow/array-string-test.cc | 14 ++++++++++++++
cpp/src/arrow/array.h | 4 ++--
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/98c94901/cpp/src/arrow/array-string-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-string-test.cc b/cpp/src/arrow/array-string-test.cc
index cf2ff41..ed38acd 100644
--- a/cpp/src/arrow/array-string-test.cc
+++ b/cpp/src/arrow/array-string-test.cc
@@ -165,6 +165,20 @@ TEST_F(TestStringArray, CompareNullByteSlots) {
equal_array.Array::Slice(1)->RangeEquals(0, 2, 0, equal_array2.Array::Slice(1)));
}
+TEST_F(TestStringArray, TestSliceGetString) {
+ StringBuilder builder(default_memory_pool());
+
+ builder.Append("a");
+ builder.Append("b");
+ builder.Append("c");
+
+ std::shared_ptr<Array> array;
+ ASSERT_OK(builder.Finish(&array));
+ auto s = array->Slice(1, 10);
+ auto arr = std::dynamic_pointer_cast<StringArray>(s);
+ ASSERT_EQ(arr->GetString(0), "b");
+}
+
// ----------------------------------------------------------------------
// String builder tests
http://git-wip-us.apache.org/repos/asf/arrow/blob/98c94901/cpp/src/arrow/array.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array.h b/cpp/src/arrow/array.h
index ecc8ce5..50faf08 100644
--- a/cpp/src/arrow/array.h
+++ b/cpp/src/arrow/array.h
@@ -322,8 +322,8 @@ class ARROW_EXPORT BinaryArray : public Array {
// Account for base offset
i += offset_;
- const int32_t pos = raw_value_offsets_[i + offset_];
- *out_length = raw_value_offsets_[i + offset_ + 1] - pos;
+ const int32_t pos = raw_value_offsets_[i];
+ *out_length = raw_value_offsets_[i + 1] - pos;
return raw_data_ + pos;
}