| 2635 | } |
| 2636 | |
| 2637 | void ModifyComments(size_t thread_index, const char* review, |
| 2638 | const std::vector<int64_t>& indices) { |
| 2639 | ThreadLocalData& tld = thread_local_data_[thread_index]; |
| 2640 | const int32_t* offsets = reinterpret_cast<const int32_t*>( |
| 2641 | tld.batch[SUPPLIER::S_COMMENT].array()->buffers[1]->data()); |
| 2642 | char* str = reinterpret_cast<char*>( |
| 2643 | tld.batch[SUPPLIER::S_COMMENT].array()->buffers[2]->mutable_data()); |
| 2644 | const char* customer = "Customer"; |
| 2645 | const int32_t customer_length = static_cast<int32_t>(std::strlen(customer)); |
| 2646 | const int32_t review_length = static_cast<int32_t>(std::strlen(review)); |
| 2647 | |
| 2648 | auto it = std::lower_bound(indices.begin(), indices.end(), tld.suppkey_start); |
| 2649 | for (; it != indices.end() && *it < tld.suppkey_start + tld.to_generate; it++) { |
| 2650 | int64_t idx_in_batch = *it - tld.suppkey_start; |
| 2651 | char* out = str + offsets[idx_in_batch]; |
| 2652 | int32_t str_length = offsets[idx_in_batch + 1] - offsets[idx_in_batch]; |
| 2653 | std::uniform_int_distribution<int32_t> gap_dist( |
| 2654 | 0, str_length - customer_length - review_length); |
| 2655 | int32_t gap = gap_dist(tld.rng); |
| 2656 | int32_t total_length = customer_length + gap + review_length; |
| 2657 | std::uniform_int_distribution<int32_t> start_dist(0, str_length - total_length); |
| 2658 | int32_t start = start_dist(tld.rng); |
| 2659 | std::memcpy(out + start, customer, customer_length); |
| 2660 | std::memcpy(out + start + customer_length + gap, review, review_length); |
| 2661 | } |
| 2662 | } |
| 2663 | |
| 2664 | struct ThreadLocalData { |
| 2665 | random::pcg32_fast rng; |
nothing calls this directly
no test coverage detected