[[arrow::export]]
| 279 | |
| 280 | // [[arrow::export]] |
| 281 | std::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]] |
| 310 | r_vec_size RecordBatch__ReferencedBufferSize( |
no test coverage detected