| 177 | |
| 178 | template <typename Offset> |
| 179 | Result<OffsetBufferOpOutcome> PutOffsets(const Buffer& src, Offset first_offset, |
| 180 | Offset* dst, Range* values_range) { |
| 181 | if (src.size() == 0) { |
| 182 | // It's allowed to have an empty offsets buffer for a 0-length array |
| 183 | // (see Array::Validate) |
| 184 | values_range->offset = 0; |
| 185 | values_range->length = 0; |
| 186 | return OffsetBufferOpOutcome::kOk; |
| 187 | } |
| 188 | |
| 189 | // Get the range of offsets to transfer from src |
| 190 | auto src_begin = src.data_as<Offset>(); |
| 191 | auto src_end = reinterpret_cast<const Offset*>(src.data() + src.size()); |
| 192 | |
| 193 | // Compute the range of values which is spanned by this range of offsets |
| 194 | values_range->offset = src_begin[0]; |
| 195 | values_range->length = *src_end - values_range->offset; |
| 196 | if (ARROW_PREDICT_FALSE(first_offset > |
| 197 | std::numeric_limits<Offset>::max() - values_range->length)) { |
| 198 | return OffsetBufferOpOutcome::kOffsetOverflow; |
| 199 | } |
| 200 | |
| 201 | // Write offsets into dst, ensuring that the first offset written is |
| 202 | // first_offset |
| 203 | auto displacement = first_offset - src_begin[0]; |
| 204 | // NOTE: Concatenate can be called during IPC reads to append delta dictionaries. |
| 205 | // Avoid UB on non-validated input by doing the addition in the unsigned domain. |
| 206 | // (the result can later be validated using Array::ValidateFull) |
| 207 | std::transform(src_begin, src_end, dst, [displacement](Offset offset) { |
| 208 | return SafeSignedAdd(offset, displacement); |
| 209 | }); |
| 210 | return OffsetBufferOpOutcome::kOk; |
| 211 | } |
| 212 | |
| 213 | template <typename offset_type> |
| 214 | Result<OffsetBufferOpOutcome> PutListViewOffsets(const ArrayData& input, |
nothing calls this directly
no test coverage detected