felipecrv commented on code in PR #35750:
URL: https://github.com/apache/arrow/pull/35750#discussion_r1218613817
##########
cpp/src/arrow/compute/kernels/vector_selection_test.cc:
##########
@@ -78,63 +118,102 @@ TEST(GetTakeIndices, NullValidityBuffer) {
ValidateOutput(indices);
AssertArraysEqual(*expected_indices, *indices_array, /*verbose=*/true);
+ ASSERT_OK_AND_ASSIGN(auto ree_filter, REEncode(filter));
+ ASSERT_OK_AND_ASSIGN(
+ auto indices_from_ree,
+ internal::GetTakeIndices(*ree_filter->data(), FilterOptions::DROP));
+ auto indices_from_ree_array = MakeArray(indices);
+ ValidateOutput(indices_from_ree);
+ AssertArraysEqual(*expected_indices, *indices_from_ree_array,
/*verbose=*/true);
+
ASSERT_OK_AND_ASSIGN(
indices, internal::GetTakeIndices(*filter.data(),
FilterOptions::EMIT_NULL));
indices_array = MakeArray(indices);
ValidateOutput(indices);
AssertArraysEqual(*expected_indices, *indices_array, /*verbose=*/true);
+
+ ASSERT_OK_AND_ASSIGN(
+ indices_from_ree,
+ internal::GetTakeIndices(*ree_filter->data(), FilterOptions::EMIT_NULL));
+ indices_from_ree_array = MakeArray(indices);
+ ValidateOutput(indices_from_ree);
+ AssertArraysEqual(*expected_indices, *indices_from_ree_array,
/*verbose=*/true);
}
template <typename IndexArrayType>
void CheckGetTakeIndicesCase(const Array& untyped_filter) {
const auto& filter = checked_cast<const BooleanArray&>(untyped_filter);
+ ASSERT_OK_AND_ASSIGN(auto ree_filter, REEncode(*filter.data()));
+
ASSERT_OK_AND_ASSIGN(std::shared_ptr<ArrayData> drop_indices,
internal::GetTakeIndices(*filter.data(),
FilterOptions::DROP));
+ ASSERT_OK_AND_ASSIGN(
+ std::shared_ptr<ArrayData> drop_indices_from_ree,
+ internal::GetTakeIndices(*ree_filter->data(), FilterOptions::DROP));
// Verify DROP indices
{
IndexArrayType indices(drop_indices);
+ IndexArrayType indices_from_ree(drop_indices);
ValidateOutput(indices);
+ ValidateOutput(indices_from_ree);
int64_t out_position = 0;
for (int64_t i = 0; i < filter.length(); ++i) {
if (filter.IsValid(i)) {
if (filter.Value(i)) {
ASSERT_EQ(indices.Value(out_position), i);
+ ASSERT_EQ(indices_from_ree.Value(out_position), i);
++out_position;
}
}
}
ASSERT_EQ(out_position, indices.length());
+ ASSERT_EQ(out_position, indices_from_ree.length());
+
// Check that the end length agrees with the output of GetFilterOutputSize
ASSERT_EQ(out_position,
internal::GetFilterOutputSize(*filter.data(),
FilterOptions::DROP));
+ ASSERT_EQ(out_position,
+ internal::GetFilterOutputSize(*ree_filter->data(),
FilterOptions::DROP));
}
ASSERT_OK_AND_ASSIGN(
std::shared_ptr<ArrayData> emit_indices,
internal::GetTakeIndices(*filter.data(), FilterOptions::EMIT_NULL));
+ ASSERT_OK_AND_ASSIGN(
+ std::shared_ptr<ArrayData> emit_indices_from_ree,
+ internal::GetTakeIndices(*ree_filter->data(), FilterOptions::EMIT_NULL));
// Verify EMIT_NULL indices
{
IndexArrayType indices(emit_indices);
+ IndexArrayType indices_from_ree(emit_indices);
ValidateOutput(indices);
+ ValidateOutput(indices_from_ree);
int64_t out_position = 0;
for (int64_t i = 0; i < filter.length(); ++i) {
if (filter.IsValid(i)) {
if (filter.Value(i)) {
ASSERT_EQ(indices.Value(out_position), i);
+ ASSERT_EQ(indices_from_ree.Value(out_position), i);
++out_position;
}
} else {
ASSERT_TRUE(indices.IsNull(out_position));
+ ASSERT_TRUE(indices_from_ree.IsNull(out_position));
++out_position;
}
}
ASSERT_EQ(out_position, indices.length());
+ ASSERT_EQ(out_position, indices_from_ree.length());
+
// Check that the end length agrees with the output of GetFilterOutputSize
ASSERT_EQ(out_position,
internal::GetFilterOutputSize(*filter.data(),
FilterOptions::EMIT_NULL));
+ ASSERT_OK_AND_ASSIGN(auto ree_filter, REEncode(*filter.data()));
Review Comment:
You're right. I'm removing it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]