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

Method FromStructArray

cpp/src/arrow/record_batch.cc:250–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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