| 554 | } |
| 555 | |
| 556 | std::shared_ptr<Array> RandomArrayGenerator::StringWithRepeats( |
| 557 | int64_t size, int64_t unique, int32_t min_length, int32_t max_length, |
| 558 | double null_probability, int64_t alignment, MemoryPool* memory_pool) { |
| 559 | ARROW_CHECK_LE(unique, size); |
| 560 | |
| 561 | // Generate a random string dictionary without any nulls |
| 562 | auto array = String(unique, min_length, max_length, /*null_probability=*/0); |
| 563 | auto dictionary = std::dynamic_pointer_cast<StringArray>(array); |
| 564 | |
| 565 | // Generate random indices to sample the dictionary with |
| 566 | auto id_array = Int64(size, 0, unique - 1, null_probability); |
| 567 | auto indices = std::dynamic_pointer_cast<Int64Array>(id_array); |
| 568 | StringBuilder builder; |
| 569 | |
| 570 | for (int64_t i = 0; i < size; ++i) { |
| 571 | if (indices->IsValid(i)) { |
| 572 | const auto index = indices->Value(i); |
| 573 | const auto value = dictionary->GetView(index); |
| 574 | ABORT_NOT_OK(builder.Append(value)); |
| 575 | } else { |
| 576 | ABORT_NOT_OK(builder.AppendNull()); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | std::shared_ptr<Array> result; |
| 581 | ABORT_NOT_OK(builder.Finish(&result)); |
| 582 | return result; |
| 583 | } |
| 584 | |
| 585 | std::shared_ptr<Array> RandomArrayGenerator::FixedSizeBinary( |
| 586 | int64_t size, int32_t byte_width, double null_probability, uint8_t min_byte, |