sparrow-ipc 1.0.1
Loading...
Searching...
No Matches
deserialize.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <span>
5#include <vector>
6
7#include <sparrow/buffer/buffer.hpp>
8#include <sparrow/record_batch.hpp>
9
11
12namespace sparrow_ipc
13{
14 [[nodiscard]] inline sparrow::buffer<uint8_t> make_zeroed_buffer(std::size_t size)
15 {
16 return sparrow::buffer<uint8_t>(size, uint8_t{0}, sparrow::buffer<uint8_t>::default_allocator{});
17 }
18
19 template <class T>
20 [[nodiscard]] sparrow::buffer<uint8_t> make_typed_zeroed_buffer(std::size_t count)
21 {
22 return make_zeroed_buffer(count * sizeof(T));
23 }
24
25 template <class T>
26 [[nodiscard]] sparrow::buffer<uint8_t> make_zero_offset_buffer()
27 {
29 }
30
31 template <typename CHILD>
32 [[nodiscard]] CHILD** make_owned_children(std::vector<CHILD>&& children)
33 {
34 if (children.empty())
35 {
36 return nullptr;
37 }
38 auto** child_ptrs = new CHILD*[children.size()];
39 for (std::size_t i = 0; i < children.size(); ++i)
40 {
41 child_ptrs[i] = new CHILD(children[i]);
42 }
43 return child_ptrs;
44 }
45
50 {
51 std::optional<sparrow::record_batch> schema;
52 std::vector<sparrow::record_batch> batches;
53 };
54
65 deserialize_stream_to_record_batches(std::span<const uint8_t> data);
66
86 [[nodiscard]] SPARROW_IPC_API std::vector<sparrow::record_batch>
87 deserialize_stream(std::span<const uint8_t> data);
88
111 deserialize_file(std::span<const uint8_t> data);
112}
#define SPARROW_IPC_API
Definition config.hpp:12
sparrow::buffer< uint8_t > make_zero_offset_buffer()
SPARROW_IPC_API record_batch_stream deserialize_file(std::span< const uint8_t > data)
Deserializes Arrow IPC file format into a record_batch_stream.
SPARROW_IPC_API record_batch_stream deserialize_stream_to_record_batches(std::span< const uint8_t > data)
Deserializes an Arrow IPC stream into a record_batch_stream.
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.
sparrow::buffer< uint8_t > make_zeroed_buffer(std::size_t size)
sparrow::buffer< uint8_t > make_typed_zeroed_buffer(std::size_t count)
CHILD ** make_owned_children(std::vector< CHILD > &&children)
Result of stream deserialization containing optional schema and record batches.
std::vector< sparrow::record_batch > batches
std::optional< sparrow::record_batch > schema