| 193 | // This helper function only supports (size/2) nulls. |
| 194 | template <typename ArrowType> |
| 195 | ::arrow::enable_if_floating_point<ArrowType, Status> NullableArray( |
| 196 | size_t size, size_t num_nulls, uint32_t seed, std::shared_ptr<Array>* out) { |
| 197 | using c_type = typename ArrowType::c_type; |
| 198 | std::vector<c_type> values; |
| 199 | if constexpr (::arrow::is_half_float_type<ArrowType>::value) { |
| 200 | values.resize(size); |
| 201 | test::random_float16_numbers(static_cast<int>(size), 0, ::arrow::util::Float16(-1e4f), |
| 202 | ::arrow::util::Float16(1e4f), values.data()); |
| 203 | } else { |
| 204 | ::arrow::random_real(size, seed, static_cast<c_type>(-1e10), |
| 205 | static_cast<c_type>(1e10), &values); |
| 206 | } |
| 207 | std::vector<uint8_t> valid_bytes(size, 1); |
| 208 | |
| 209 | for (size_t i = 0; i < num_nulls; i++) { |
| 210 | valid_bytes[i * 2] = 0; |
| 211 | } |
| 212 | |
| 213 | ::arrow::NumericBuilder<ArrowType> builder; |
| 214 | if (values.size() > 0) { |
| 215 | RETURN_NOT_OK(builder.AppendValues(values.data(), values.size(), valid_bytes.data())); |
| 216 | } |
| 217 | return builder.Finish(out); |
| 218 | } |
| 219 | |
| 220 | // This helper function only supports (size/2) nulls. |
| 221 | template <typename ArrowType> |
nothing calls this directly
no test coverage detected