| 76 | } |
| 77 | |
| 78 | Result<RecordBatchVector> Batches() { |
| 79 | ::arrow::random::RandomArrayGenerator gen(/*seed=*/42); |
| 80 | RecordBatchVector batches; |
| 81 | |
| 82 | auto append_batch = [&](auto array_factory, int64_t length) -> Status { |
| 83 | ARROW_ASSIGN_OR_RAISE(auto batch, MakeBatch(array_factory, length)); |
| 84 | batches.push_back(batch); |
| 85 | return Status::OK(); |
| 86 | }; |
| 87 | |
| 88 | // Ideally, we should exercise all possible inference kinds (see inference_internal.h) |
| 89 | auto make_nulls = [&](int64_t length, double null_probability) { |
| 90 | return MakeArrayOfNull(null(), length); |
| 91 | }; |
| 92 | auto make_ints = [&](int64_t length, double null_probability) { |
| 93 | return gen.Int64(length, /*min=*/-1'000'000, /*max=*/1'000'000, null_probability); |
| 94 | }; |
| 95 | auto make_floats = [&](int64_t length, double null_probability) { |
| 96 | return gen.Float64(length, /*min=*/-100.0, /*max=*/100.0, null_probability); |
| 97 | }; |
| 98 | auto make_booleans = [&](int64_t length, double null_probability) { |
| 99 | return gen.Boolean(length, /*true_probability=*/0.8, null_probability); |
| 100 | }; |
| 101 | auto make_dates = [&](int64_t length, double null_probability) { |
| 102 | return gen.Date64(length, /*min=*/1, /*max=*/365 * 60, null_probability); |
| 103 | }; |
| 104 | auto make_times = [&](int64_t length, double null_probability) { |
| 105 | return gen.Int32(length, /*min=*/0, /*max=*/86399, null_probability) |
| 106 | ->View(time32(TimeUnit::SECOND)); |
| 107 | }; |
| 108 | |
| 109 | std::string timezone; |
| 110 | auto make_timestamps = [&](int64_t length, double null_probability) { |
| 111 | return gen.Int64(length, /*min=*/1, /*max=*/1764079190, null_probability) |
| 112 | ->View(timestamp(TimeUnit::SECOND, timezone)); |
| 113 | }; |
| 114 | auto make_timestamps_ns = [&](int64_t length, double null_probability) { |
| 115 | return gen |
| 116 | .Int64(length, /*min=*/1, /*max=*/1764079190LL * 1'000'000'000, null_probability) |
| 117 | ->View(timestamp(TimeUnit::NANO, timezone)); |
| 118 | }; |
| 119 | |
| 120 | auto make_strings = [&](int64_t length, double null_probability) { |
| 121 | return gen.String(length, /*min_length=*/3, /*max_length=*/15, null_probability); |
| 122 | }; |
| 123 | auto make_string_with_repeats = [&](int64_t length, double null_probability) { |
| 124 | // `unique` should be less than `auto_dict_max_cardinality` in fuzz target |
| 125 | return gen.StringWithRepeats(length, /*unique=*/10, /*min_length=*/3, |
| 126 | /*max_length=*/15, null_probability); |
| 127 | }; |
| 128 | |
| 129 | RETURN_NOT_OK(append_batch(make_nulls, /*length=*/2000)); |
| 130 | RETURN_NOT_OK(append_batch(make_ints, /*length=*/500)); |
| 131 | RETURN_NOT_OK(append_batch(make_floats, /*length=*/150)); |
| 132 | RETURN_NOT_OK(append_batch(make_booleans, /*length=*/500)); |
| 133 | |
| 134 | RETURN_NOT_OK(append_batch(make_dates, /*length=*/200)); |
| 135 | RETURN_NOT_OK(append_batch(make_times, /*length=*/400)); |
nothing calls this directly
no test coverage detected