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

Method FromStructArray

cpp/src/arrow/record_batch.cc:251–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251Result<std::shared_ptr<RecordBatch>> RecordBatch::FromStructArray(
252 const std::shared_ptr<Array>& array, MemoryPool* memory_pool) {
253 if (array->type_id() != Type::STRUCT) {
254 return Status::TypeError("Cannot construct record batch from array of type ",
255 *array->type());
256 }
257 // Push the struct array's validity map and slicing (if any) into the child arrays
258 // by calling Flatten
259 const std::shared_ptr<StructArray>& struct_array =
260 internal::checked_pointer_cast<StructArray>(array);
261 ARROW_ASSIGN_OR_RAISE(std::vector<std::shared_ptr<Array>> fields,
262 struct_array->Flatten(memory_pool));
263 return Make(arrow::schema(array->type()->fields()), array->length(), std::move(fields));
264}
265
266namespace {
267

Callers 1

GetSampleRecordBatchFunction · 0.80

Calls 9

TypeErrorFunction · 0.70
MakeFunction · 0.70
schemaFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
type_idMethod · 0.45
typeMethod · 0.45
FlattenMethod · 0.45
fieldsMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected