MCPcopy Create free account
hub / github.com/apache/arrow / CheckTakeRandom

Function CheckTakeRandom

cpp/src/arrow/compute/kernels/vector_selection_test.cc:2263–2280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2261
2262template <typename ValuesType, typename IndexType>
2263void CheckTakeRandom(const std::shared_ptr<Array>& values, int64_t indices_length,
2264 double null_probability, random::RandomArrayGenerator* rand) {
2265 using IndexCType = typename IndexType::c_type;
2266 IndexCType max_index = GetMaxIndex<IndexCType>(values->length());
2267 auto indices = rand->Numeric<IndexType>(indices_length, static_cast<IndexCType>(0),
2268 max_index, null_probability);
2269 auto indices_no_nulls = rand->Numeric<IndexType>(
2270 indices_length, static_cast<IndexCType>(0), max_index, /*null_probability=*/0.0);
2271 ValidateTakeXA<ValuesType>(values, indices);
2272 ValidateTakeXA<ValuesType>(values, indices_no_nulls);
2273 // Sliced indices array
2274 if (indices_length >= 2) {
2275 indices = indices->Slice(1, indices_length - 2);
2276 indices_no_nulls = indices_no_nulls->Slice(1, indices_length - 2);
2277 ValidateTakeXA<ValuesType>(values, indices);
2278 ValidateTakeXA<ValuesType>(values, indices_no_nulls);
2279 }
2280}
2281
2282template <typename ValuesType>
2283struct TakeRandomTest {

Callers

nothing calls this directly

Calls 2

lengthMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected