| 2934 | } |
| 2935 | |
| 2936 | Status C_NAME(size_t thread_index) { |
| 2937 | ThreadLocalData& tld = thread_local_data_[thread_index]; |
| 2938 | if (tld.batch[CUSTOMER::C_NAME].kind() == Datum::NONE) { |
| 2939 | RETURN_NOT_OK(C_CUSTKEY(thread_index)); |
| 2940 | const int32_t* c_custkey = reinterpret_cast<const int32_t*>( |
| 2941 | tld.batch[CUSTOMER::C_CUSTKEY].array()->buffers[1]->data()); |
| 2942 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<Buffer> offset_buff, |
| 2943 | AllocateBuffer((tld.to_generate + 1) * sizeof(int32_t))); |
| 2944 | int32_t* offsets = reinterpret_cast<int32_t*>(offset_buff->mutable_data()); |
| 2945 | const char* customer = "Customer#"; |
| 2946 | const size_t customer_length = std::strlen(customer); |
| 2947 | offsets[0] = 0; |
| 2948 | for (int64_t irow = 0; irow < tld.to_generate; irow++) { |
| 2949 | int num_digits = GetNumDigits(c_custkey[irow]); |
| 2950 | int num_chars = std::max(num_digits, 9); |
| 2951 | offsets[irow + 1] = |
| 2952 | static_cast<int32_t>(offsets[irow] + num_chars + customer_length); |
| 2953 | } |
| 2954 | ARROW_ASSIGN_OR_RAISE(std::unique_ptr<Buffer> str_buff, |
| 2955 | AllocateBuffer(offsets[tld.to_generate])); |
| 2956 | char* str = reinterpret_cast<char*>(str_buff->mutable_data()); |
| 2957 | for (int64_t irow = 0; irow < tld.to_generate; irow++) { |
| 2958 | char* out = str + offsets[irow]; |
| 2959 | std::memcpy(out, customer, customer_length); |
| 2960 | AppendNumberPaddedToNineDigits(out + customer_length, c_custkey[irow]); |
| 2961 | } |
| 2962 | ArrayData ad(utf8(), tld.to_generate, |
| 2963 | {nullptr, std::move(offset_buff), std::move(str_buff)}); |
| 2964 | tld.batch[CUSTOMER::C_NAME] = std::move(ad); |
| 2965 | } |
| 2966 | return Status::OK(); |
| 2967 | } |
| 2968 | |
| 2969 | Status C_ADDRESS(size_t thread_index) { |
| 2970 | ThreadLocalData& tld = thread_local_data_[thread_index]; |
nothing calls this directly
no test coverage detected