sparrow-ipc 0.3.0
Loading...
Searching...
No Matches
deserializer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iterator>
4#include <ranges>
5#include <span>
6
7#include <sparrow/record_batch.hpp>
8
10
11namespace sparrow_ipc
12{
13 template <std::ranges::input_range R>
14 requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch>
16 {
17 public:
18
19 deserializer(R& data)
20 : m_data(&data)
21 {
22 }
23
24 void deserialize(std::span<const uint8_t> data)
25 {
26 // Insert at the end of m_data container the deserialized record batches
27 auto& container = *m_data;
28 auto deserialized_batches = sparrow_ipc::deserialize_stream(data);
29 container.insert(
30 std::end(container),
31 std::make_move_iterator(std::begin(deserialized_batches)),
32 std::make_move_iterator(std::end(deserialized_batches))
33 );
34 }
35
36 deserializer& operator<<(std::span<const uint8_t> data)
37 {
38 deserialize(data);
39 return *this;
40 }
41
42 private:
43
44 R* m_data;
45 };
46}
void deserialize(std::span< const uint8_t > data)
deserializer & operator<<(std::span< const uint8_t > data)
SPARROW_IPC_API std::vector< sparrow::record_batch > deserialize_stream(std::span< const uint8_t > data)
Deserializes an Arrow IPC stream from binary data into a vector of record batches.