| 99 | size_t GetBytesForSchema() { return sizeof(int32_t) + sizeof(bool); } |
| 100 | |
| 101 | void MinimalEndToEndScan( |
| 102 | size_t num_batches, size_t batch_size, const std::string& factory_name, |
| 103 | std::function<Result<std::shared_ptr<acero::ExecNodeOptions>>(size_t, size_t)> |
| 104 | options_factory) { |
| 105 | // ensure arrow::dataset node factories are in the registry |
| 106 | ::arrow::dataset::internal::Initialize(); |
| 107 | |
| 108 | // A ScanNode is constructed from a Dataset (whose batches will be scanned), and |
| 109 | // ScanOptions (to specify a filter for predicate pushdown, a projection to skip |
| 110 | // materialization of unnecessary columns, |
| 111 | // ...) |
| 112 | RecordBatchVector batches = GetBatches(num_batches, batch_size); |
| 113 | |
| 114 | std::shared_ptr<Dataset> dataset = |
| 115 | std::make_shared<InMemoryDataset>(GetSchema(), batches); |
| 116 | |
| 117 | ASSERT_OK_AND_ASSIGN(std::shared_ptr<acero::ExecNodeOptions> node_options, |
| 118 | options_factory(num_batches, batch_size)); |
| 119 | |
| 120 | // construct the scan node |
| 121 | acero::Declaration scan(factory_name, std::move(node_options)); |
| 122 | |
| 123 | // pipe the scan node into a filter node |
| 124 | compute::Expression b_is_true = equal(field_ref("b"), literal(true)); |
| 125 | acero::Declaration filter("filter", {std::move(scan)}, |
| 126 | acero::FilterNodeOptions{b_is_true}); |
| 127 | |
| 128 | // pipe the filter node into a project node |
| 129 | // NB: we're using the project node factory which preserves fragment/batch index |
| 130 | // tagging, so we *can* reorder later if we choose. The tags will not appear in |
| 131 | // our output. |
| 132 | compute::Expression a_times_2 = call("multiply", {field_ref("a"), literal(2)}); |
| 133 | acero::Declaration project("project", {std::move(filter)}, |
| 134 | acero::ProjectNodeOptions{{a_times_2}, {"a*2"}}); |
| 135 | |
| 136 | // Consume the plan and transform into a table |
| 137 | ASSERT_OK_AND_ASSIGN(std::shared_ptr<Table> collected, |
| 138 | acero::DeclarationToTable(std::move(project))); |
| 139 | |
| 140 | ASSERT_GT(collected->num_rows(), 0); |
| 141 | } |
| 142 | |
| 143 | void ScanOnly( |
| 144 | size_t num_batches, size_t batch_size, const std::string& factory_name, |
no test coverage detected