| 391 | }; |
| 392 | |
| 393 | std::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 | // |