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

Function PreallocateValuesArray

cpp/src/arrow/compute/kernels/ree_util_internal.cc:60–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60Result<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
88Result<std::shared_ptr<ArrayData>> PreallocateREEArray(
89 std::shared_ptr<RunEndEncodedType> ree_type, bool has_validity_buffer,

Callers

nothing calls this directly

Calls 7

AllocateEmptyBitmapFunction · 0.85
is_base_binary_likeFunction · 0.85
offset_bit_widthFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeFunction · 0.50
idMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected