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

Function GenRandomRecords

cpp/src/arrow/acero/hash_join_node_test.cc:393–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391};
392
393std::vector<std::shared_ptr<Array>> GenRandomRecords(
394 Random64Bit& rng, const std::vector<RandomDataType>& data_types, int num_rows) {
395 std::vector<std::shared_ptr<Array>> result;
396 random::RandomArrayGenerator rag(static_cast<random::SeedType>(rng.next()));
397 for (size_t i = 0; i < data_types.size(); ++i) {
398 if (data_types[i].is_fixed_length) {
399 switch (data_types[i].fixed_length) {
400 case 0:
401 result.push_back(rag.Boolean(num_rows, 0.5, data_types[i].null_probability));
402 break;
403 case 1:
404 result.push_back(rag.UInt8(num_rows, std::numeric_limits<uint8_t>::min(),
405 std::numeric_limits<uint8_t>::max(),
406 data_types[i].null_probability));
407 break;
408 case 2:
409 result.push_back(rag.UInt16(num_rows, std::numeric_limits<uint16_t>::min(),
410 std::numeric_limits<uint16_t>::max(),
411 data_types[i].null_probability));
412 break;
413 case 4:
414 result.push_back(rag.UInt32(num_rows, std::numeric_limits<uint32_t>::min(),
415 std::numeric_limits<uint32_t>::max(),
416 data_types[i].null_probability));
417 break;
418 case 8:
419 result.push_back(rag.UInt64(num_rows, std::numeric_limits<uint64_t>::min(),
420 std::numeric_limits<uint64_t>::max(),
421 data_types[i].null_probability));
422 break;
423 default:
424 result.push_back(rag.FixedSizeBinary(num_rows, data_types[i].fixed_length,
425 data_types[i].null_probability));
426 break;
427 }
428 } else {
429 if (data_types[i].is_large_string) {
430 // Generate LargeString if is_large_string flag is true
431 result.push_back(rag.LargeString(num_rows, data_types[i].min_string_length,
432 data_types[i].max_string_length,
433 data_types[i].null_probability));
434 } else {
435 result.push_back(rag.String(num_rows, data_types[i].min_string_length,
436 data_types[i].max_string_length,
437 data_types[i].null_probability));
438 }
439 }
440 }
441 return result;
442}
443
444// Index < 0 means appending null values to all columns.
445//

Callers 2

GenRandomUniqueRecordsFunction · 0.85
GenRandomJoinTablesFunction · 0.85

Calls 11

push_backMethod · 0.80
UInt8Method · 0.80
UInt16Method · 0.80
UInt32Method · 0.80
UInt64Method · 0.80
LargeStringMethod · 0.80
nextMethod · 0.45
sizeMethod · 0.45
BooleanMethod · 0.45
FixedSizeBinaryMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected