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

Function MakeIntegerBatchGen

cpp/src/arrow/acero/test_util_internal.cc:218–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216} // namespace
217
218AsyncGenerator<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
255BatchesWithSchema MakeBasicBatches() {
256 BatchesWithSchema out;

Callers 1

Calls 3

DeferNotOkFunction · 0.85
executorMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected