MCPcopy Create free account
hub / github.com/apache/arrow / ResizeFixedLengthBuffers

Method ResizeFixedLengthBuffers

cpp/src/arrow/compute/light_array_internal.cc:239–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239Status ResizableArrayData::ResizeFixedLengthBuffers(int num_rows_new) {
240 ARROW_DCHECK(num_rows_new >= 0);
241 if (num_rows_new <= num_rows_allocated_) {
242 num_rows_ = num_rows_new;
243 return Status::OK();
244 }
245
246 int num_rows_allocated_new = 1 << log_num_rows_min_;
247 while (num_rows_allocated_new < num_rows_new) {
248 num_rows_allocated_new *= 2;
249 }
250
251 if (buffers_[kFixedLengthBuffer] == NULLPTR) {
252 ARROW_DCHECK(buffers_[kValidityBuffer] == NULLPTR &&
253 buffers_[kVariableLengthBuffer] == NULLPTR);
254
255 ARROW_ASSIGN_OR_RAISE(
256 buffers_[kValidityBuffer],
257 AllocateResizableBuffer(
258 bit_util::BytesForBits(num_rows_allocated_new) + kNumPaddingBytes, pool_));
259 memset(mutable_data(kValidityBuffer), 0,
260 bit_util::BytesForBits(num_rows_allocated_new) + kNumPaddingBytes);
261 if (column_metadata_.is_fixed_length) {
262 if (column_metadata_.fixed_length == 0) {
263 ARROW_ASSIGN_OR_RAISE(
264 buffers_[kFixedLengthBuffer],
265 AllocateResizableBuffer(
266 bit_util::BytesForBits(num_rows_allocated_new) + kNumPaddingBytes,
267 pool_));
268 memset(mutable_data(kFixedLengthBuffer), 0,
269 bit_util::BytesForBits(num_rows_allocated_new) + kNumPaddingBytes);
270 } else {
271 ARROW_ASSIGN_OR_RAISE(
272 buffers_[kFixedLengthBuffer],
273 AllocateResizableBuffer(
274 num_rows_allocated_new * column_metadata_.fixed_length + kNumPaddingBytes,
275 pool_));
276 }
277 } else {
278 ARROW_ASSIGN_OR_RAISE(
279 buffers_[kFixedLengthBuffer],
280 AllocateResizableBuffer(
281 (num_rows_allocated_new + 1) * sizeof(uint32_t) + kNumPaddingBytes, pool_));
282 }
283
284 ARROW_ASSIGN_OR_RAISE(
285 buffers_[kVariableLengthBuffer],
286 AllocateResizableBuffer(sizeof(uint64_t) + kNumPaddingBytes, pool_));
287
288 var_len_buf_size_ = sizeof(uint64_t);
289 } else {
290 ARROW_DCHECK(buffers_[kValidityBuffer] != NULLPTR &&
291 buffers_[kVariableLengthBuffer] != NULLPTR);
292
293 int64_t bytes_for_bits_before =
294 bit_util::BytesForBits(num_rows_allocated_) + kNumPaddingBytes;
295 int64_t bytes_for_bits_after =
296 bit_util::BytesForBits(num_rows_allocated_new) + kNumPaddingBytes;

Callers 2

AppendSelectedMethod · 0.45
AppendNullsMethod · 0.45

Calls 6

AllocateResizableBufferFunction · 0.85
BytesForBitsFunction · 0.85
OKFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
mutable_dataFunction · 0.50
ResizeMethod · 0.45

Tested by

no test coverage detected