Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cpp/src/arrow/compute/kernels/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/compute/kernels/filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down