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

Function MakeStructArray

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

Source from the content-addressed store, hash-verified

605}
606
607static std::shared_ptr<Array> MakeStructArray(::arrow::random::RandomArrayGenerator* rng,
608 const ArrayVector& children,
609 double null_probability,
610 bool propagate_validity = false) {
611 ARROW_CHECK_GT(children.size(), 0);
612 const int64_t length = children[0]->length();
613
614 std::shared_ptr<::arrow::Buffer> null_bitmap;
615 if (null_probability > 0.0) {
616 null_bitmap = rng->NullBitmap(length, null_probability);
617 if (propagate_validity) {
618 // HACK: the Parquet writer currently doesn't allow non-empty list
619 // entries where a parent node is null (for instance, a struct-of-list
620 // where the outer struct is marked null but the inner list value is
621 // non-empty).
622 for (const auto& child : children) {
623 null_bitmap = *::arrow::internal::BitmapOr(
624 ::arrow::default_memory_pool(), null_bitmap->data(), 0,
625 child->null_bitmap_data(), 0, length, 0);
626 }
627 }
628 }
629 FieldVector fields(children.size());
630 char field_name = 'a';
631 for (size_t i = 0; i < children.size(); ++i) {
632 fields[i] = field(std::string{field_name++}, children[i]->type(),
633 /*nullable=*/null_probability > 0.0);
634 }
635 return *::arrow::StructArray::Make(children, std::move(fields), null_bitmap);
636}
637
638// Make a (int32, int64) struct array
639static 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