| 1380 | |
| 1381 | template <typename ValuesType, typename IndexType> |
| 1382 | void ValidateTakeXAImpl(const std::shared_ptr<Array>& values, |
| 1383 | const std::shared_ptr<Array>& indices, |
| 1384 | const std::shared_ptr<Array>& result) { |
| 1385 | using ValuesArrayType = typename TypeTraits<ValuesType>::ArrayType; |
| 1386 | using IndexArrayType = typename TypeTraits<IndexType>::ArrayType; |
| 1387 | auto typed_values = checked_pointer_cast<ValuesArrayType>(values); |
| 1388 | auto typed_result = checked_pointer_cast<ValuesArrayType>(result); |
| 1389 | auto typed_indices = checked_pointer_cast<IndexArrayType>(indices); |
| 1390 | for (int64_t i = 0; i < indices->length(); ++i) { |
| 1391 | if (typed_indices->IsNull(i) || typed_values->IsNull(typed_indices->Value(i))) { |
| 1392 | ASSERT_TRUE(result->IsNull(i)) << i; |
| 1393 | // The value of a null element is undefined, but right |
| 1394 | // out of the Take kernel it is expected to be 0. |
| 1395 | if constexpr (is_primitive(ValuesType::type_id)) { |
| 1396 | if constexpr (ValuesType::type_id == Type::BOOL) { |
| 1397 | ASSERT_EQ(typed_result->Value(i), false); |
| 1398 | } else { |
| 1399 | ASSERT_EQ(typed_result->Value(i), 0); |
| 1400 | } |
| 1401 | } |
| 1402 | } else { |
| 1403 | ASSERT_FALSE(result->IsNull(i)) << i; |
| 1404 | ASSERT_EQ(typed_result->GetView(i), typed_values->GetView(typed_indices->Value(i))) |
| 1405 | << i; |
| 1406 | } |
| 1407 | } |
| 1408 | // DoCheckTakeCACWithArrays transforms the indices which has a risk of |
| 1409 | // overflow, so we only call it if the index type is not too wide. |
| 1410 | if (indices->type()->byte_width() <= 4) { |
| 1411 | auto cast_options = CastOptions::Safe(TypeHolder{int64()}); |
| 1412 | ASSERT_OK_AND_ASSIGN(auto indices64, Cast(indices, cast_options)); |
| 1413 | DoCheckTakeCACWithArrays(values, indices64.make_array(), /*expected=*/result); |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | template <typename ValuesType> |
| 1418 | void ValidateTakeXA(const std::shared_ptr<Array>& values, |
nothing calls this directly
no test coverage detected