| 56 | } |
| 57 | |
| 58 | Result<std::shared_ptr<RecordBatch>> MakeBatch( |
| 59 | std::function<Result<std::shared_ptr<Array>>(int64_t length, double null_probability)> |
| 60 | array_factory, |
| 61 | int64_t length) { |
| 62 | ArrayVector columns; |
| 63 | FieldVector fields; |
| 64 | |
| 65 | struct ColumnSpec { |
| 66 | std::string name; |
| 67 | double null_probability; |
| 68 | }; |
| 69 | for (auto spec : {ColumnSpec{"with_nulls", 0.2}, ColumnSpec{"without_nulls", 0.0}}) { |
| 70 | ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Array> column, |
| 71 | array_factory(length, spec.null_probability)); |
| 72 | columns.push_back(column); |
| 73 | fields.push_back(field(spec.name, column->type())); |
| 74 | } |
| 75 | return RecordBatch::Make(schema(std::move(fields)), length, std::move(columns)); |
| 76 | } |
| 77 | |
| 78 | Result<RecordBatchVector> Batches() { |
| 79 | ::arrow::random::RandomArrayGenerator gen(/*seed=*/42); |