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

Function NullableArray

cpp/src/parquet/arrow/test_util.h:195–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193// This helper function only supports (size/2) nulls.
194template <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.
221template <typename ArrowType>

Callers

nothing calls this directly

Calls 15

random_float16_numbersFunction · 0.85
random_realFunction · 0.85
randintFunction · 0.85
default_memory_poolFunction · 0.85
fixed_size_binaryFunction · 0.85
resizeMethod · 0.80
Float16Class · 0.50
random_bytesFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
AppendValuesMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected