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

Function RecordBatch__from_arrays

r/src/recordbatch.cpp:281–307  ·  view source on GitHub ↗

[[arrow::export]]

Source from the content-addressed store, hash-verified

279
280// [[arrow::export]]
281std::shared_ptr<arrow::RecordBatch> RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) {
282 bool infer_schema = !Rf_inherits(schema_sxp, "Schema");
283
284 int num_fields;
285 StopIfNotOk(arrow::r::count_fields(lst, &num_fields));
286
287 // schema + metadata
288 std::shared_ptr<arrow::Schema> schema;
289 StopIfNotOk(arrow::r::InferSchemaFromDots(lst, schema_sxp, num_fields, schema));
290 StopIfNotOk(arrow::r::AddMetadataFromDots(lst, num_fields, schema));
291
292 // RecordBatch
293 if (!infer_schema) {
294 return RecordBatch__from_arrays__known_schema(schema, lst);
295 }
296
297 // RecordBatch
298 std::vector<std::shared_ptr<arrow::Array>> arrays(num_fields);
299 StopIfNotOk(
300 arrow::r::CollectRecordBatchArrays(lst, schema, num_fields, infer_schema, arrays));
301
302 // extract number of rows, and check their consistency
303 int64_t num_rows = 0;
304 StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows));
305
306 return arrow::RecordBatch::Make(schema, num_rows, arrays);
307}
308
309// [[arrow::export]]
310r_vec_size RecordBatch__ReferencedBufferSize(

Callers 1

Calls 8

StopIfNotOkFunction · 0.85
count_fieldsFunction · 0.85
InferSchemaFromDotsFunction · 0.85
AddMetadataFromDotsFunction · 0.85
CollectRecordBatchArraysFunction · 0.85
MakeFunction · 0.50

Tested by

no test coverage detected