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

Function MakeStructArray

cpp/src/parquet/arrow/reader_writer_benchmark.cc:565–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565static std::shared_ptr<Array> MakeStructArray(::arrow::random::RandomArrayGenerator* rng,
566 const ArrayVector& children,
567 double null_probability,
568 bool propagate_validity = false) {
569 ARROW_CHECK_GT(children.size(), 0);
570 const int64_t length = children[0]->length();
571
572 std::shared_ptr<::arrow::Buffer> null_bitmap;
573 if (null_probability > 0.0) {
574 null_bitmap = rng->NullBitmap(length, null_probability);
575 if (propagate_validity) {
576 // HACK: the Parquet writer currently doesn't allow non-empty list
577 // entries where a parent node is null (for instance, a struct-of-list
578 // where the outer struct is marked null but the inner list value is
579 // non-empty).
580 for (const auto& child : children) {
581 null_bitmap = *::arrow::internal::BitmapOr(
582 ::arrow::default_memory_pool(), null_bitmap->data(), 0,
583 child->null_bitmap_data(), 0, length, 0);
584 }
585 }
586 }
587 FieldVector fields(children.size());
588 char field_name = 'a';
589 for (size_t i = 0; i < children.size(); ++i) {
590 fields[i] = field(std::string{field_name++}, children[i]->type(),
591 /*nullable=*/null_probability > 0.0);
592 }
593 return *::arrow::StructArray::Make(children, std::move(fields), null_bitmap);
594}
595
596// Make a (int32, int64) struct array
597static std::shared_ptr<Array> MakeStructArray(::arrow::random::RandomArrayGenerator* rng,

Callers 4

BM_ReadStructColumnFunction · 0.85

Calls 11

BitmapOrFunction · 0.85
default_memory_poolFunction · 0.85
NullBitmapMethod · 0.80
Int32Method · 0.80
fieldFunction · 0.70
MakeFunction · 0.50
sizeMethod · 0.45
lengthMethod · 0.45
dataMethod · 0.45
typeMethod · 0.45
Int64Method · 0.45

Tested by

no test coverage detected