| 225 | int32_t kInfiniteUniqueValues = -1; |
| 226 | |
| 227 | std::shared_ptr<Table> RandomStringTable(std::shared_ptr<::arrow::DataType> type, |
| 228 | int64_t length, int64_t unique_values, |
| 229 | int64_t null_percentage) { |
| 230 | std::shared_ptr<::arrow::Array> arr; |
| 231 | ::arrow::random::RandomArrayGenerator generator(/*seed=*/500); |
| 232 | double null_probability = static_cast<double>(null_percentage) / 100.0; |
| 233 | if (unique_values == kInfiniteUniqueValues) { |
| 234 | arr = generator.String(length, /*min_length=*/3, /*max_length=*/32, |
| 235 | /*null_probability=*/null_probability); |
| 236 | } else { |
| 237 | arr = generator.StringWithRepeats(length, /*unique=*/unique_values, |
| 238 | /*min_length=*/3, /*max_length=*/32, |
| 239 | /*null_probability=*/null_probability); |
| 240 | } |
| 241 | arr = *::arrow::compute::Cast(*arr, type); |
| 242 | return Table::Make( |
| 243 | ::arrow::schema({::arrow::field("column", type, null_percentage > 0)}), {arr}); |
| 244 | } |
| 245 | |
| 246 | static void BM_WriteBinaryColumn(::benchmark::State& state) { |
| 247 | std::shared_ptr<Table> table = |