Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9FF4B200C3B for ; Sat, 18 Mar 2017 21:47:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9E681160B7F; Sat, 18 Mar 2017 20:47:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E5B52160B7A for ; Sat, 18 Mar 2017 21:47:19 +0100 (CET) Received: (qmail 34525 invoked by uid 500); 18 Mar 2017 20:47:19 -0000 Mailing-List: contact commits-help@arrow.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@arrow.apache.org Delivered-To: mailing list commits@arrow.apache.org Received: (qmail 34516 invoked by uid 99); 18 Mar 2017 20:47:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Mar 2017 20:47:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E9C80DFD73; Sat, 18 Mar 2017 20:47:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wesm@apache.org To: commits@arrow.apache.org Message-Id: <7774078c529a4288889e3f5eed827e3a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: arrow git commit: ARROW-639: [C++] Invalid offset in slices Date: Sat, 18 Mar 2017 20:47:18 +0000 (UTC) archived-at: Sat, 18 Mar 2017 20:47:20 -0000 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 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 Authored: Sat Mar 18 16:47:13 2017 -0400 Committer: Wes McKinney 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; + ASSERT_OK(builder.Finish(&array)); + auto s = array->Slice(1, 10); + auto arr = std::dynamic_pointer_cast(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; }