This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 99db64c3bba8d24aa98c58750d3156a53ded9d8a
Author: Neal Richardson <neal.p.richard...@gmail.com>
AuthorDate: Thu Oct 3 07:58:38 2019 -0400

    ARROW-6773: [C++] Fix filter kernel when filtering with a boolean Array 
slice
    
    Closes #5570 from nealrichardson/fix-filter-slice and squashes the 
following commits:
    
    3a772fcc5 <Neal Richardson> Lint again
    f7e9475b7 <Neal Richardson> lint
    96220d179 <Neal Richardson> Test and fix for bug in filter kernel with a 
slice
    
    Authored-by: Neal Richardson <neal.p.richard...@gmail.com>
    Signed-off-by: Benjamin Kietzman <bengil...@gmail.com>
---
 cpp/src/arrow/compute/kernels/filter.cc      | 4 +---
 cpp/src/arrow/compute/kernels/filter_test.cc | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/cpp/src/arrow/compute/kernels/filter.cc 
b/cpp/src/arrow/compute/kernels/filter.cc
index f985886..86545aa 100644
--- a/cpp/src/arrow/compute/kernels/filter.cc
+++ b/cpp/src/arrow/compute/kernels/filter.cc
@@ -65,10 +65,8 @@ class FilterIndexSequence {
 
 // TODO(bkietz) this can be optimized
 static int64_t OutputSize(const BooleanArray& filter) {
-  auto offset = filter.offset();
-  auto length = filter.length();
   int64_t size = 0;
-  for (auto i = offset; i < offset + length; ++i) {
+  for (auto i = 0; i < filter.length(); ++i) {
     if (filter.IsNull(i) || filter.Value(i)) {
       ++size;
     }
diff --git a/cpp/src/arrow/compute/kernels/filter_test.cc 
b/cpp/src/arrow/compute/kernels/filter_test.cc
index 37f609e..bb685f4 100644
--- a/cpp/src/arrow/compute/kernels/filter_test.cc
+++ b/cpp/src/arrow/compute/kernels/filter_test.cc
@@ -151,6 +151,10 @@ TYPED_TEST(TestFilterKernelWithNumeric, FilterNumeric) {
   this->AssertFilter("[7, 8, 9]", "[null, 1, 0]", "[null, 8]");
   this->AssertFilter("[7, 8, 9]", "[1, null, 1]", "[7, null, 9]");
 
+  this->AssertFilterArrays(ArrayFromJSON(this->type_singleton(), "[7, 8, 9]"),
+                           ArrayFromJSON(boolean(), "[0, 1, 1, 1, 0, 
1]")->Slice(3, 3),
+                           ArrayFromJSON(this->type_singleton(), "[7, 9]"));
+
   std::shared_ptr<Array> arr;
   ASSERT_RAISES(Invalid, this->Filter(this->type_singleton(), "[7, 8, 9]", 
"[]", &arr));
 }

Reply via email to