1111namespace sparrow_ipc
1212{
1313 void deserialize_schema_message (
14- const uint8_t * buf_ptr ,
14+ std::span< const uint8_t > data ,
1515 size_t & current_offset,
1616 std::optional<std::string>& name,
1717 std::optional<std::vector<sparrow::metadata_pair>>& metadata
1818 )
1919 {
20- const uint32_t schema_meta_len = *(reinterpret_cast <const uint32_t *>(buf_ptr + current_offset));
20+ const uint32_t schema_meta_len = *(reinterpret_cast <const uint32_t *>(data. data () + current_offset));
2121 current_offset += sizeof (uint32_t );
22- const auto schema_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
22+ const auto schema_message = org::apache::arrow::flatbuf::GetMessage (data. data () + current_offset);
2323 if (schema_message->header_type () != org::apache::arrow::flatbuf::MessageHeader::Schema)
2424 {
2525 throw std::runtime_error (" Expected Schema message at the start of the buffer." );
@@ -56,10 +56,10 @@ namespace sparrow_ipc
5656 }
5757
5858 const org::apache::arrow::flatbuf::RecordBatch*
59- deserialize_record_batch_message (const uint8_t * buf_ptr , size_t & current_offset)
59+ deserialize_record_batch_message (std::span< const uint8_t > data , size_t & current_offset)
6060 {
6161 current_offset += sizeof (uint32_t );
62- const auto batch_message = org::apache::arrow::flatbuf::GetMessage (buf_ptr + current_offset);
62+ const auto batch_message = org::apache::arrow::flatbuf::GetMessage (data. data () + current_offset);
6363 if (batch_message->header_type () != org::apache::arrow::flatbuf::MessageHeader::RecordBatch)
6464 {
6565 throw std::runtime_error (" Expected RecordBatch message, but got a different type." );
@@ -225,7 +225,7 @@ namespace sparrow_ipc
225225 return arrays;
226226 }
227227
228- std::vector<sparrow::record_batch> deserialize_stream (const uint8_t * buf_ptr )
228+ std::vector<sparrow::record_batch> deserialize_stream (std::span< const uint8_t > data )
229229 {
230230 const org::apache::arrow::flatbuf::Schema* schema = nullptr ;
231231 std::vector<sparrow::record_batch> record_batches;
@@ -234,7 +234,7 @@ namespace sparrow_ipc
234234 std::vector<sparrow::data_type> field_types;
235235 do
236236 {
237- const EncapsulatedMessage encapsulated_message = create_encapsulated_message (buf_ptr );
237+ const EncapsulatedMessage encapsulated_message = create_encapsulated_message (data );
238238 const org::apache::arrow::flatbuf::Message* message = encapsulated_message.flat_buffer_message ();
239239 switch (message->header_type ())
240240 {
@@ -280,8 +280,8 @@ namespace sparrow_ipc
280280 throw std::runtime_error (" Unknown message header type." );
281281 }
282282 const size_t encapsulated_message_total_length = encapsulated_message.total_length ();
283- buf_ptr += encapsulated_message_total_length;
284- if (is_end_of_stream (std::span< const uint8_t >{buf_ptr , 8 } ))
283+ data = data. subspan ( encapsulated_message_total_length) ;
284+ if (is_end_of_stream (data. subspan ( 0 , 8 ) ))
285285 {
286286 break ;
287287 }
0 commit comments