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

Method MakeRandomArray

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

ValueOrDieMethod · 0.80
precisionMethod · 0.45
ViewMethod · 0.45

Tested by

no test coverage detected