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

Function RandomStringTable

cpp/src/parquet/arrow/reader_writer_benchmark.cc:227–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225int32_t kInfiniteUniqueValues = -1;
226
227std::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
246static void BM_WriteBinaryColumn(::benchmark::State& state) {
247 std::shared_ptr<Table> table =

Callers 2

BM_WriteBinaryColumnFunction · 0.85

Calls 6

CastFunction · 0.85
StringWithRepeatsMethod · 0.80
fieldFunction · 0.70
MakeFunction · 0.50
schemaFunction · 0.50
StringMethod · 0.45

Tested by

no test coverage detected