| 58 | } |
| 59 | |
| 60 | Result<std::shared_ptr<ArrayData>> PreallocateValuesArray( |
| 61 | const std::shared_ptr<DataType>& value_type, bool has_validity_buffer, int64_t length, |
| 62 | MemoryPool* pool, int64_t data_buffer_size) { |
| 63 | std::vector<std::shared_ptr<Buffer>> values_data_buffers; |
| 64 | std::shared_ptr<Buffer> validity_buffer = NULLPTR; |
| 65 | if (has_validity_buffer) { |
| 66 | ARROW_ASSIGN_OR_RAISE(validity_buffer, AllocateEmptyBitmap(length, pool)); |
| 67 | } |
| 68 | ARROW_ASSIGN_OR_RAISE(auto values_buffer, AllocateValuesBuffer(length, *value_type, |
| 69 | pool, data_buffer_size)); |
| 70 | if (is_base_binary_like(value_type->id())) { |
| 71 | const int offset_byte_width = offset_bit_width(value_type->id()) / 8; |
| 72 | ARROW_ASSIGN_OR_RAISE(auto offsets_buffer, |
| 73 | AllocateBuffer((length + 1) * offset_byte_width, pool)); |
| 74 | // Ensure the first offset is zero |
| 75 | memset(offsets_buffer->mutable_data(), 0, offset_byte_width); |
| 76 | offsets_buffer->ZeroPadding(); |
| 77 | values_data_buffers = {std::move(validity_buffer), std::move(offsets_buffer), |
| 78 | std::move(values_buffer)}; |
| 79 | } else { |
| 80 | values_data_buffers = {std::move(validity_buffer), std::move(values_buffer)}; |
| 81 | } |
| 82 | auto data = ArrayData::Make(value_type, length, std::move(values_data_buffers), |
| 83 | kUnknownNullCount); |
| 84 | DCHECK(!(has_validity_buffer && length > 0) || data->buffers[0]); |
| 85 | return data; |
| 86 | } |
| 87 | |
| 88 | Result<std::shared_ptr<ArrayData>> PreallocateREEArray( |
| 89 | std::shared_ptr<RunEndEncodedType> ree_type, bool has_validity_buffer, |
nothing calls this directly
no test coverage detected