@@ -164,7 +164,7 @@ class RecordBatchSerializer {
164
164
std::shared_ptr<Buffer> bitmap;
165
165
RETURN_NOT_OK (GetTruncatedBitmap (arr.offset (), arr.length (), arr.null_bitmap (),
166
166
options_.memory_pool , &bitmap));
167
- out_->body_buffers .emplace_back (bitmap);
167
+ out_->body_buffers .emplace_back (std::move ( bitmap) );
168
168
} else {
169
169
// Push a dummy zero-length buffer, not to be copied
170
170
out_->body_buffers .emplace_back (kNullBuffer );
@@ -222,8 +222,9 @@ class RecordBatchSerializer {
222
222
RETURN_NOT_OK (
223
223
result->Resize (actual_length + sizeof (int64_t ), /* shrink_to_fit= */ true ));
224
224
}
225
- *reinterpret_cast <int64_t *>(result->mutable_data ()) =
226
- bit_util::ToLittleEndian (prefixed_length);
225
+ int64_t prefixed_length_little_endian = bit_util::ToLittleEndian (prefixed_length);
226
+ util::SafeStore (result->mutable_data (), prefixed_length_little_endian);
227
+
227
228
*out = SliceBuffer (std::move (result), /* offset=*/ 0 , actual_length + sizeof (int64_t ));
228
229
229
230
return Status::OK ();
@@ -415,7 +416,7 @@ class RecordBatchSerializer {
415
416
std::shared_ptr<Buffer> data;
416
417
RETURN_NOT_OK (GetTruncatedBitmap (array.offset (), array.length (), array.values (),
417
418
options_.memory_pool , &data));
418
- out_->body_buffers .emplace_back (data);
419
+ out_->body_buffers .emplace_back (std::move ( data) );
419
420
return Status::OK ();
420
421
}
421
422
@@ -442,7 +443,7 @@ class RecordBatchSerializer {
442
443
data->size () - byte_offset);
443
444
data = SliceBuffer (data, byte_offset, buffer_length);
444
445
}
445
- out_->body_buffers .emplace_back (data);
446
+ out_->body_buffers .emplace_back (std::move ( data) );
446
447
return Status::OK ();
447
448
}
448
449
@@ -464,8 +465,8 @@ class RecordBatchSerializer {
464
465
data = SliceBuffer (data, start_offset, slice_length);
465
466
}
466
467
467
- out_->body_buffers .emplace_back (value_offsets);
468
- out_->body_buffers .emplace_back (data);
468
+ out_->body_buffers .emplace_back (std::move ( value_offsets) );
469
+ out_->body_buffers .emplace_back (std::move ( data) );
469
470
return Status::OK ();
470
471
}
471
472
@@ -566,7 +567,7 @@ class RecordBatchSerializer {
566
567
RETURN_NOT_OK (GetTruncatedBuffer (
567
568
offset, length, static_cast <int32_t >(sizeof (UnionArray::type_code_t )),
568
569
array.type_codes (), options_.memory_pool , &type_codes));
569
- out_->body_buffers .emplace_back (type_codes);
570
+ out_->body_buffers .emplace_back (std::move ( type_codes) );
570
571
571
572
--max_recursion_depth_;
572
573
for (int i = 0 ; i < array.num_fields (); ++i) {
@@ -585,7 +586,7 @@ class RecordBatchSerializer {
585
586
RETURN_NOT_OK (GetTruncatedBuffer (
586
587
offset, length, static_cast <int32_t >(sizeof (UnionArray::type_code_t )),
587
588
array.type_codes (), options_.memory_pool , &type_codes));
588
- out_->body_buffers .emplace_back (type_codes);
589
+ out_->body_buffers .emplace_back (std::move ( type_codes) );
589
590
590
591
--max_recursion_depth_;
591
592
const auto & type = checked_cast<const UnionType&>(*array.type ());
@@ -640,7 +641,7 @@ class RecordBatchSerializer {
640
641
641
642
value_offsets = std::move (shifted_offsets_buffer);
642
643
}
643
- out_->body_buffers .emplace_back (value_offsets);
644
+ out_->body_buffers .emplace_back (std::move ( value_offsets) );
644
645
645
646
// Visit children and slice accordingly
646
647
for (int i = 0 ; i < type.num_fields (); ++i) {
0 commit comments