| 216 | } // namespace |
| 217 | |
| 218 | AsyncGenerator<std::optional<ExecBatch>> MakeIntegerBatchGen( |
| 219 | const std::vector<std::function<int64_t(int)>>& gens, |
| 220 | const std::shared_ptr<Schema>& schema, int num_batches, int batch_size) { |
| 221 | struct IntegerBatchGenState { |
| 222 | IntegerBatchGenState(const std::vector<std::function<int64_t(int)>>& gens, |
| 223 | const std::shared_ptr<Schema>& schema, int num_batches, |
| 224 | int batch_size) |
| 225 | : gens(gens), schema(schema), num_batches(num_batches), batch_size(batch_size) {} |
| 226 | |
| 227 | std::optional<ExecBatch> Next() { |
| 228 | if (batch_index >= num_batches) { |
| 229 | return std::nullopt; |
| 230 | } |
| 231 | Result<ExecBatch> batch_res = MakeIntegerBatch(gens, schema, batch_row, batch_size); |
| 232 | if (!batch_res.ok()) { |
| 233 | return std::nullopt; |
| 234 | } |
| 235 | ++batch_index; |
| 236 | batch_row += batch_size; |
| 237 | return batch_res.ValueOrDie(); |
| 238 | } |
| 239 | |
| 240 | std::vector<std::function<int64_t(int)>> gens; |
| 241 | std::shared_ptr<Schema> schema; |
| 242 | int num_batches; |
| 243 | int batch_size; |
| 244 | int batch_index = 0; |
| 245 | int batch_row = 0; |
| 246 | }; |
| 247 | auto state = |
| 248 | std::make_shared<IntegerBatchGenState>(gens, schema, num_batches, batch_size); |
| 249 | return [state]() { |
| 250 | return DeferNotOk(::arrow::io::default_io_context().executor()->Submit( |
| 251 | [state]() { return state->Next(); })); |
| 252 | }; |
| 253 | } |
| 254 | |
| 255 | BatchesWithSchema MakeBasicBatches() { |
| 256 | BatchesWithSchema out; |
no test coverage detected