|
sparrow-ipc 0.2.0
|
A class for serializing Apache Arrow record batches to an output stream. More...
#include <serializer.hpp>
Public Member Functions | |
| template<writable_stream TStream> | |
| serializer (TStream &stream, std::optional< CompressionType > compression=std::nullopt) | |
| Constructs a serializer object with a reference to a stream. | |
| ~serializer () | |
| Destructor for the serializer. | |
| void | write (const sparrow::record_batch &rb) |
| Writes a record batch to the serializer. | |
| template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch> | |
| void | write (const R &record_batches) |
| Writes a collection of record batches to the stream. | |
| serializer & | operator<< (const sparrow::record_batch &rb) |
| template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch> | |
| serializer & | operator<< (const R &record_batches) |
| serializer & | operator<< (serializer &(*manip)(serializer &)) |
| void | end () |
| Finalizes the serialization process by writing end-of-stream marker. | |
A class for serializing Apache Arrow record batches to an output stream.
The serializer class provides functionality to serialize single or multiple record batches into a binary format suitable for storage or transmission. It ensures schema consistency across multiple record batches and optimizes memory allocation by pre-calculating required buffer sizes.
The serializer supports two main usage patterns:
The class validates that all record batches have consistent schemas and throws std::invalid_argument if inconsistencies are detected or if an empty collection is provided.
Memory efficiency is achieved through:
Definition at line 34 of file serializer.hpp.
|
inline |
Constructs a serializer object with a reference to a stream.
| TStream | The type of the stream to be used for serialization. |
| stream | Reference to the stream object that will be used for serialization operations. The serializer stores a pointer to this stream for later use. |
| compression | Optional: The compression type to use for record batch bodies. |
Definition at line 47 of file serializer.hpp.
| sparrow_ipc::serializer::~serializer | ( | ) |
Destructor for the serializer.
Ensures proper cleanup by calling end() if the serializer has not been explicitly ended. This guarantees that any pending data is flushed and resources are properly released before the object is destroyed.
| void sparrow_ipc::serializer::end | ( | ) |
Finalizes the serialization process by writing end-of-stream marker.
This method writes an end-of-stream marker to the output stream and flushes any buffered data. It can be called multiple times safely as it tracks whether the stream has already been ended to prevent duplicate operations.
|
inline |
|
inline |
|
inline |
|
inline |
Writes a collection of record batches to the stream.
This method efficiently adds multiple record batches to the serialization stream by first calculating the total required size and reserving memory space to minimize reallocations during the append operations.
| R | The type of the record batch collection (must be iterable) |
| record_batches | A collection of record batches to append to the stream |
The method performs the following operations:
Definition at line 85 of file serializer.hpp.
| void sparrow_ipc::serializer::write | ( | const sparrow::record_batch & | rb | ) |
Writes a record batch to the serializer.
| rb | The record batch to write to the serializer |