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

Method MakeRandomArray

cpp/src/arrow/testing/random.cc:408–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406 }
407
408 std::shared_ptr<Array> MakeRandomArray(int64_t size, double null_probability,
409 int64_t alignment, MemoryPool* memory_pool) {
410 static constexpr int32_t kMaxDigitsInInteger =
411 std::is_same_v<DecimalType, Decimal32Type> ? 9 : 18;
412 static_assert(
413 kMaxDigitsInInteger >= DecimalType::kByteWidth,
414 "inconsistent decimal metadata: kMaxPrecision doesn't match kByteWidth");
415
416 const auto& decimal_type = checked_cast<const DecimalType&>(*type_);
417
418 auto digits_to_generate = decimal_type.precision();
419 auto values = checked_pointer_cast<typename TypeTraits<IntArrowType>::ArrayType>(
420 rng_->Numeric<IntArrowType>(size, -1 * MaxDecimalInteger(digits_to_generate),
421 MaxDecimalInteger(digits_to_generate),
422 null_probability, alignment, memory_pool));
423
424 return values->View(type_).ValueOrDie();
425 }
426};
427
428} // namespace

Callers

nothing calls this directly

Calls 3

ValueOrDieMethod · 0.80
precisionMethod · 0.45
ViewMethod · 0.45

Tested by

no test coverage detected