| 588 | } |
| 589 | |
| 590 | Result<Datum> RandomVString(random::pcg32_fast& rng, int64_t num_rows, int32_t min_length, |
| 591 | int32_t max_length) { |
| 592 | std::uniform_int_distribution<int32_t> length_dist(min_length, max_length); |
| 593 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<Buffer> offset_buff, |
| 594 | AllocateBuffer((num_rows + 1) * sizeof(int32_t))); |
| 595 | int32_t* offsets = reinterpret_cast<int32_t*>(offset_buff->mutable_data()); |
| 596 | offsets[0] = 0; |
| 597 | for (int64_t i = 1; i <= num_rows; i++) offsets[i] = offsets[i - 1] + length_dist(rng); |
| 598 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<Buffer> str_buff, |
| 599 | AllocateBuffer(offsets[num_rows])); |
| 600 | char* str = reinterpret_cast<char*>(str_buff->mutable_data()); |
| 601 | |
| 602 | // Spec says to pick random alphanumeric characters from a set of at least |
| 603 | // 64 symbols. Now, let's think critically here: 26 letters in the alphabet, |
| 604 | // so 52 total for upper and lower case, and 10 possible digits gives 62 |
| 605 | // characters... |
| 606 | // dbgen solves this by including a space and a comma as well, so we'll |
| 607 | // copy that. |
| 608 | const char alpha_numerics[65] = |
| 609 | "0123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ,"; |
| 610 | std::uniform_int_distribution<int> char_dist(0, 63); |
| 611 | for (int32_t i = 0; i < offsets[num_rows]; i++) str[i] = alpha_numerics[char_dist(rng)]; |
| 612 | |
| 613 | ArrayData ad(utf8(), num_rows, {nullptr, std::move(offset_buff), std::move(str_buff)}); |
| 614 | return ad; |
| 615 | } |
| 616 | |
| 617 | void GeneratePhoneNumber(char* out, random::pcg32_fast& rng, int32_t country) { |
| 618 | std::uniform_int_distribution<int32_t> three_digit(100, 999); |
no test coverage detected