@@ -150,8 +150,8 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
150
150
151
151
// arrow_arr.buffers[0] is the validity bitmap
152
152
// arrow_arr.buffers[1] is the data buffer
153
- const uint8_t * validity_bitmap = static_cast <const uint8_t *>(arrow_arr.buffers [0 ]);
154
- const uint8_t * data_buffer = static_cast <const uint8_t *>(arrow_arr.buffers [1 ]);
153
+ const auto validity_bitmap = static_cast <const uint8_t *>(arrow_arr.buffers [0 ]);
154
+ const auto data_buffer = static_cast <const uint8_t *>(arrow_arr.buffers [1 ]);
155
155
156
156
// Calculate the size of the validity and data buffers
157
157
int64_t validity_size = (arrow_arr.length + arrow_alignment - 1 ) / arrow_alignment;
@@ -183,10 +183,10 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
183
183
batch_builder.Finish (batch_message_offset);
184
184
185
185
// III - Append the RecordBatch message to the final buffer
186
- uint32_t batch_meta_len = batch_builder.GetSize (); // Get the size of the batch metadata
187
- int64_t aligned_batch_meta_len = align_to_8 (batch_meta_len); // Calculate the padded length
186
+ const uint32_t batch_meta_len = batch_builder.GetSize (); // Get the size of the batch metadata
187
+ const int64_t aligned_batch_meta_len = align_to_8 (batch_meta_len); // Calculate the padded length
188
188
189
- size_t current_size = final_buffer.size (); // Get the current size (which is the end of the Schema message)
189
+ const size_t current_size = final_buffer.size (); // Get the current size (which is the end of the Schema message)
190
190
// Resize the buffer to append the new message
191
191
final_buffer.resize (current_size + sizeof (uint32_t ) + aligned_batch_meta_len + body_len);
192
192
uint8_t * dst = final_buffer.data () + current_size; // Get a pointer to where the new message will start
@@ -207,7 +207,8 @@ std::vector<uint8_t> serialize_primitive_array(const sparrow::primitive_array<T>
207
207
else
208
208
{
209
209
// If validity_bitmap is null, it means there are no nulls
210
- memset (dst, 0xFF , validity_size);
210
+ constexpr uint8_t no_nulls_bitmap = 0xFF ;
211
+ memset (dst, no_nulls_bitmap, validity_size);
211
212
}
212
213
dst += validity_size;
213
214
if (data_buffer)
@@ -230,7 +231,7 @@ sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_
230
231
size_t current_offset = 0 ;
231
232
232
233
// I - Deserialize the Schema message
233
- uint32_t schema_meta_len;
234
+ uint32_t schema_meta_len = 0 ;
234
235
memcpy (&schema_meta_len, buf_ptr + current_offset, sizeof (schema_meta_len));
235
236
current_offset += sizeof (uint32_t );
236
237
auto schema_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
@@ -248,7 +249,7 @@ sparrow::primitive_array<T> deserialize_primitive_array(const std::vector<uint8_
248
249
current_offset += schema_meta_len;
249
250
250
251
// II - Deserialize the RecordBatch message
251
- uint32_t batch_meta_len;
252
+ uint32_t batch_meta_len = 0 ;
252
253
memcpy (&batch_meta_len, buf_ptr + current_offset, sizeof (batch_meta_len));
253
254
current_offset += sizeof (uint32_t );
254
255
auto batch_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
0 commit comments