[[dataset::export]]
| 276 | |
| 277 | // [[dataset::export]] |
| 278 | std::shared_ptr<acero::ExecNode> ExecNode_Scan( |
| 279 | const std::shared_ptr<acero::ExecPlan>& plan, |
| 280 | const std::shared_ptr<ds::Dataset>& dataset, |
| 281 | const std::shared_ptr<compute::Expression>& filter, cpp11::list projection) { |
| 282 | arrow::dataset::internal::Initialize(); |
| 283 | |
| 284 | // TODO: pass in FragmentScanOptions |
| 285 | auto options = std::make_shared<ds::ScanOptions>(); |
| 286 | |
| 287 | options->use_threads = arrow::r::GetBoolOption("arrow.use_threads", true); |
| 288 | options->dataset_schema = dataset->schema(); |
| 289 | |
| 290 | // This filter is only used for predicate pushdown; |
| 291 | // you still need to pass it to a FilterNode after to handle any other components |
| 292 | options->filter = *filter; |
| 293 | |
| 294 | // ScanNode needs to know which fields to materialize. |
| 295 | // It will pull them from this projection to prune the scan, |
| 296 | // but you still need to Project after |
| 297 | std::vector<compute::Expression> exprs; |
| 298 | for (SEXP expr : projection) { |
| 299 | auto expr_ptr = cpp11::as_cpp<std::shared_ptr<compute::Expression>>(expr); |
| 300 | exprs.push_back(*expr_ptr); |
| 301 | } |
| 302 | cpp11::strings field_names(projection.attr(R_NamesSymbol)); |
| 303 | options->projection = call( |
| 304 | "make_struct", std::move(exprs), |
| 305 | compute::MakeStructOptions{cpp11::as_cpp<std::vector<std::string>>(field_names)}); |
| 306 | |
| 307 | return MakeExecNodeOrStop("scan", plan.get(), {}, |
| 308 | ds::ScanNodeOptions{dataset, options}); |
| 309 | } |
| 310 | |
| 311 | // [[dataset::export]] |
| 312 | void ExecPlan_Write( |
no test coverage detected