| 284 | /// memory later. |
| 285 | template <bool IS_BINARY> |
| 286 | Status PaimonJniRowReader::WriteStringOrBinarySlot( |
| 287 | const arrow::Array* array, const int row_idx, void* slot, MemPool* tuple_data_pool) { |
| 288 | std::string_view v; |
| 289 | uint32_t jbuffer_size = 0; |
| 290 | if constexpr (IS_BINARY) { |
| 291 | const arrow::BinaryArray* binary_array = |
| 292 | static_cast<const arrow::BinaryArray*>(array); |
| 293 | v = binary_array->Value(row_idx); |
| 294 | } else { |
| 295 | const arrow::StringArray* string_array = |
| 296 | static_cast<const arrow::StringArray*>(array); |
| 297 | v = string_array->Value(row_idx); |
| 298 | } |
| 299 | |
| 300 | jbuffer_size = v.size(); |
| 301 | // Allocate memory and copy the bytes from the JVM to the RowBatch. |
| 302 | char* buffer = |
| 303 | reinterpret_cast<char*>(tuple_data_pool->TryAllocateUnaligned(jbuffer_size)); |
| 304 | if (UNLIKELY(buffer == nullptr)) { |
| 305 | string details = strings::Substitute("Failed to allocate $0 bytes for $1.", |
| 306 | jbuffer_size, IS_BINARY ? "binary" : "string"); |
| 307 | return tuple_data_pool->mem_tracker()->MemLimitExceeded( |
| 308 | nullptr, details, jbuffer_size); |
| 309 | } |
| 310 | |
| 311 | memcpy(buffer, v.data(), jbuffer_size); |
| 312 | reinterpret_cast<StringValue*>(slot)->Assign(buffer, jbuffer_size); |
| 313 | return Status::OK(); |
| 314 | } |
| 315 | } // namespace impala |
nothing calls this directly
no test coverage detected