|
sparrow-ipc 2.0.0
|
Namespaces | |
| namespace | utils |
Classes | |
| class | any_output_stream |
| Type-erased wrapper for any stream-like object. More... | |
| class | arrow_array_private_data |
| class | chunk_serializer |
| A serializer that writes record batches to chunked memory streams. More... | |
| class | chunked_memory_output_stream |
| An output stream that writes data into separate memory chunks. More... | |
| class | CompressionCache |
| class | deserializer |
| class | dictionary_cache |
| Caches dictionaries during deserialization. More... | |
| struct | dictionary_info |
| Information about a dictionary used for encoding. More... | |
| struct | dictionary_metadata |
| class | dictionary_tracker |
| Tracks dictionaries during serialization. More... | |
| class | memory_output_stream |
| An output stream that writes data to a contiguous memory buffer. More... | |
| class | non_owning_arrow_schema_private_data |
| struct | record_batch_block |
| Represents a block entry in the Arrow IPC file footer. More... | |
| struct | record_batch_stream |
| Result of stream deserialization containing optional schema and record batches. More... | |
| struct | serialized_record_batch_info |
| Information about a serialized record batch block. More... | |
| class | serializer |
| A class for serializing Apache Arrow record batches to an output stream. More... | |
| class | stream_file_serializer |
| A class for serializing Apache Arrow record batches to the IPC file format. More... | |
Concepts | |
| concept | writable_stream |
| Concept for stream-like types that support write operations. | |
| concept | ArrowPrivateData |
Enumerations | |
| enum class | CompressionType : std::uint8_t { LZ4_FRAME , ZSTD } |
Functions | |
| SPARROW_IPC_API void | release_arrow_array_children_and_dictionary (ArrowArray *array) |
| template<ArrowPrivateData T> | |
| void | arrow_array_release (ArrowArray *array) |
| template<ArrowPrivateData T, typename Arg> | |
| void | fill_arrow_array (ArrowArray &array, int64_t length, int64_t null_count, int64_t offset, size_t children_count, ArrowArray **children, ArrowArray *dictionary, Arg &&private_data_arg) |
| template<ArrowPrivateData T, typename Arg> | |
| ArrowArray | make_arrow_array (int64_t length, int64_t null_count, int64_t offset, size_t children_count, ArrowArray **children, ArrowArray *dictionary, Arg &&private_data_arg) |
| template<class T> requires std::same_as<T, ArrowArray> || std::same_as<T, ArrowSchema> | |
| void | release_common_non_owning_arrow (T &t) |
Release the children and dictionnary of an ArrowArray or ArrowSchema. | |
| SPARROW_IPC_API void | release_non_owning_arrow_schema (ArrowSchema *schema) |
| template<sparrow::input_metadata_container M = std::vector<sparrow::metadata_pair>> | |
| void | fill_non_owning_arrow_schema (ArrowSchema &schema, std::string_view format, std::string_view name, std::optional< M > metadata, std::optional< std::unordered_set< sparrow::ArrowFlag > > flags, size_t children_count, ArrowSchema **children, ArrowSchema *dictionary) |
| template<sparrow::input_metadata_container M = std::vector<sparrow::metadata_pair>> | |
| ArrowSchema | make_non_owning_arrow_schema (std::string_view format, std::string_view name, std::optional< M > metadata, std::optional< std::unordered_set< sparrow::ArrowFlag > > flags, size_t children_count, ArrowSchema **children, ArrowSchema *dictionary) |
| SPARROW_IPC_API std::span< const std::uint8_t > | compress (const CompressionType compression_type, const std::span< const std::uint8_t > &data, CompressionCache &cache) |
| SPARROW_IPC_API size_t | get_compressed_size (const CompressionType compression_type, const std::span< const std::uint8_t > &data, CompressionCache &cache) |
| SPARROW_IPC_API std::variant< sparrow::buffer< std::uint8_t >, std::span< const std::uint8_t > > | decompress (const CompressionType compression_type, std::span< const std::uint8_t > data) |
| sparrow::buffer< uint8_t > | make_zeroed_buffer (std::size_t size) |
| template<class T> | |
| sparrow::buffer< uint8_t > | make_typed_zeroed_buffer (std::size_t count) |
| template<class T> | |
| sparrow::buffer< uint8_t > | make_zero_offset_buffer () |
| template<typename CHILD> | |
| CHILD ** | make_owned_children (std::vector< CHILD > &&children) |
| 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_IPC_API record_batch_stream | deserialize_file (std::span< const uint8_t > data) |
| Deserializes Arrow IPC file format into a record_batch_stream. | |
| template<class Func> | |
| void | for_each_pending_dictionary (const sparrow::record_batch &record_batch, dictionary_tracker &tracker, Func visitor) |
| SPARROW_IPC_API int64_t | compute_fallback_dictionary_id (std::string_view field_name, size_t field_index) |
| SPARROW_IPC_API dictionary_metadata | parse_dictionary_metadata (const ArrowSchema &schema) |
| template<std::ranges::input_range R> | |
| bool | is_continuation (const R &buf) |
| template<std::ranges::input_range R> | |
| bool | is_end_of_stream (const R &buf) |
| template<std::ranges::input_range R> | |
| bool | is_arrow_file_magic (const R &buf) |
| template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch> | |
| void | serialize_record_batches_to_ipc_stream (const R &record_batches, any_output_stream &stream, std::optional< CompressionType > compression, std::optional< std::reference_wrapper< CompressionCache > > cache) |
| Serializes a collection of record batches into a binary format. | |
| SPARROW_IPC_API serialized_record_batch_info | serialize_record_batch (const sparrow::record_batch &record_batch, any_output_stream &stream, std::optional< CompressionType > compression, std::optional< std::reference_wrapper< CompressionCache > > cache) |
| Serializes a record batch into a binary format following the Arrow IPC specification. | |
| SPARROW_IPC_API serialized_record_batch_info | serialize_dictionary_batch (int64_t dictionary_id, const sparrow::record_batch &record_batch, bool is_delta, any_output_stream &stream, std::optional< CompressionType > compression, std::optional< std::reference_wrapper< CompressionCache > > cache) |
| Serializes a dictionary batch into a binary format following the Arrow IPC specification. | |
| SPARROW_IPC_API void | serialize_schema_message (const sparrow::record_batch &record_batch, any_output_stream &stream) |
| Serializes a schema message for a record batch into a byte buffer. | |
| SPARROW_IPC_API std::size_t | calculate_schema_message_size (const sparrow::record_batch &record_batch) |
| Calculates the total serialized size of a schema message. | |
| SPARROW_IPC_API std::size_t | calculate_record_batch_message_size (const sparrow::record_batch &record_batch, std::optional< CompressionType > compression=std::nullopt, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| Calculates the total serialized size of a record batch message. | |
| SPARROW_IPC_API std::size_t | calculate_dictionary_batch_message_size (int64_t dictionary_id, const sparrow::record_batch &record_batch, bool is_delta, std::optional< CompressionType > compression=std::nullopt, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| Calculates the total serialized size of a dictionary batch message. | |
| template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch> | |
| std::size_t | calculate_total_serialized_size (const R &record_batches, std::optional< CompressionType > compression=std::nullopt, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| Calculates the total serialized size for a collection of record batches. | |
| SPARROW_IPC_API void | fill_body (const sparrow::arrow_proxy &arrow_proxy, any_output_stream &stream, std::optional< CompressionType > compression=std::nullopt, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| Fills the body vector with serialized data from an arrow proxy and its children. | |
| SPARROW_IPC_API void | generate_body (const sparrow::record_batch &record_batch, any_output_stream &stream, std::optional< CompressionType > compression=std::nullopt, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| Generates a serialized body from a record batch. | |
| SPARROW_IPC_API std::vector< sparrow::data_type > | get_column_dtypes (const sparrow::record_batch &rb) |
| serializer & | end_stream (serializer &serializer) |
| template<std::ranges::input_range R> requires std::same_as<std::ranges::range_value_t<R>, sparrow::record_batch> | |
| std::size_t | calculate_serializer_reserve_size (const R &record_batches, std::size_t current_stream_size, bool schema_received, std::optional< CompressionType > compression, const dictionary_tracker &dict_tracker, std::optional< std::reference_wrapper< CompressionCache > > cache=std::nullopt) |
| SPARROW_IPC_API size_t | write_footer (const sparrow::record_batch &record_batch, const std::vector< record_batch_block > &dictionary_blocks, const std::vector< record_batch_block > &record_batch_blocks, any_output_stream &stream) |
| Writes the Arrow IPC file footer. | |
| stream_file_serializer & | end_file (stream_file_serializer &serializer) |
Variables | |
| constexpr int | SPARROW_IPC_VERSION_MAJOR = 2 |
| constexpr int | SPARROW_IPC_VERSION_MINOR = 0 |
| constexpr int | SPARROW_IPC_VERSION_PATCH = 0 |
| constexpr int | SPARROW_IPC_BINARY_CURRENT = 5 |
| constexpr int | SPARROW_IPC_BINARY_REVISION = 0 |
| constexpr int | SPARROW_IPC_BINARY_AGE = 0 |
| constexpr std::array< std::uint8_t, 4 > | continuation = {0xFF, 0xFF, 0xFF, 0xFF} |
| Continuation value defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#encapsulated-message-format. | |
| constexpr std::array< std::uint8_t, 8 > | end_of_stream = {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00} |
| End-of-stream marker defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format. | |
| constexpr std::array< std::uint8_t, 6 > | arrow_file_magic = {'A', 'R', 'R', 'O', 'W', '1'} |
| Magic bytes for Arrow file format defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format The magic string is "ARROW1" (6 bytes) followed by 2 padding bytes to reach 8-byte alignment. | |
| constexpr std::size_t | arrow_file_magic_size = arrow_file_magic.size() |
| constexpr std::array< std::uint8_t, 8 > | arrow_file_header_magic = {'A', 'R', 'R', 'O', 'W', '1', 0x00, 0x00} |
| Magic bytes with padding for file header (8 bytes total for alignment) | |
|
strong |
| Enumerator | |
|---|---|
| LZ4_FRAME | |
| ZSTD | |
Definition at line 16 of file compression.hpp.
| void sparrow_ipc::arrow_array_release | ( | ArrowArray * | array | ) |
Definition at line 16 of file arrow_array.hpp.
|
nodiscard |
Calculates the total serialized size of a dictionary batch message.
This function computes the complete size that would be produced by serialize_dictionary_batch(), including:
| dictionary_id | The unique identifier for the dictionary. |
| record_batch | A single-column record batch containing dictionary values. |
| is_delta | Whether this dictionary batch is a delta update. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache to store and retrieve compressed buffer sizes, avoiding recompression. If compression is given, cache should be set as well. |
|
nodiscard |
Calculates the total serialized size of a record batch message.
This function computes the complete size that would be produced by serialize_record_batch(), including:
| record_batch | The record batch to be measured. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache to store and retrieve compressed buffer sizes, avoiding recompression. If compression is given, cache should be set as well. |
|
nodiscard |
Calculates the total serialized size of a schema message.
This function computes the complete size that would be produced by serialize_schema_message(), including:
| record_batch | The record batch containing the schema to be measured |
|
nodiscard |
Definition at line 17 of file serializer_reserve.hpp.
|
nodiscard |
Calculates the total serialized size for a collection of record batches.
This function computes the complete size that would be produced by serializing a schema message followed by all record batch messages in the collection.
| R | Range type containing sparrow::record_batch objects. |
| record_batches | Collection of record batches to be measured. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache to store and retrieve compressed buffer sizes, avoiding recompression. If compression is given, cache should be set as well. |
| std::invalid_argument | if record batches have inconsistent schemas. |
Definition at line 110 of file serialize_utils.hpp.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
Deserializes Arrow IPC file format into a record_batch_stream.
Reads an Arrow IPC file format which consists of:
| data | A span of bytes containing the serialized Arrow IPC file data |
| std::runtime_error | If:
|
|
nodiscard |
Deserializes an Arrow IPC stream from binary data into a vector of record batches.
... This function processes an Arrow IPC stream format, extracting schema information and record batch data. It handles encapsulated messages sequentially, first expecting a Schema message followed by one or more RecordBatch messages.
| data | A span of bytes containing the serialized Arrow IPC stream data |
| std::runtime_error | If:
|
|
nodiscard |
Deserializes an Arrow IPC stream into a record_batch_stream.
This function returns both the schema (as an optional record batch) and the record batches found in the stream.
| data | A span of bytes containing the serialized Arrow IPC stream data |
|
inline |
Definition at line 360 of file stream_file_serializer.hpp.
|
inline |
Definition at line 265 of file serializer.hpp.
| void sparrow_ipc::fill_arrow_array | ( | ArrowArray & | array, |
| int64_t | length, | ||
| int64_t | null_count, | ||
| int64_t | offset, | ||
| size_t | children_count, | ||
| ArrowArray ** | children, | ||
| ArrowArray * | dictionary, | ||
| Arg && | private_data_arg ) |
Definition at line 32 of file arrow_array.hpp.
| SPARROW_IPC_API void sparrow_ipc::fill_body | ( | const sparrow::arrow_proxy & | arrow_proxy, |
| any_output_stream & | stream, | ||
| std::optional< CompressionType > | compression = std::nullopt, | ||
| std::optional< std::reference_wrapper< CompressionCache > > | cache = std::nullopt ) |
Fills the body vector with serialized data from an arrow proxy and its children.
This function recursively processes an arrow proxy by:
The function ensures proper memory alignment by padding each buffer's data to the next 8-byte boundary, which is typically required for efficient memory access and Arrow format compliance.
| arrow_proxy | The arrow proxy containing buffers and potential child proxies to serialize. |
| stream | The output stream where the serialized body data will be written. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache for compressed buffers to avoid recompression if compression is enabled. If compression is given, cache should be set as well. |
| std::invalid_argument | if compression is given but not cache. |
| void sparrow_ipc::fill_non_owning_arrow_schema | ( | ArrowSchema & | schema, |
| std::string_view | format, | ||
| std::string_view | name, | ||
| std::optional< M > | metadata, | ||
| std::optional< std::unordered_set< sparrow::ArrowFlag > > | flags, | ||
| size_t | children_count, | ||
| ArrowSchema ** | children, | ||
| ArrowSchema * | dictionary ) |
Definition at line 18 of file arrow_schema.hpp.
| void sparrow_ipc::for_each_pending_dictionary | ( | const sparrow::record_batch & | record_batch, |
| dictionary_tracker & | tracker, | ||
| Func | visitor ) |
Definition at line 11 of file dictionary_iteration.hpp.
| SPARROW_IPC_API void sparrow_ipc::generate_body | ( | const sparrow::record_batch & | record_batch, |
| any_output_stream & | stream, | ||
| std::optional< CompressionType > | compression = std::nullopt, | ||
| std::optional< std::reference_wrapper< CompressionCache > > | cache = std::nullopt ) |
Generates a serialized body from a record batch.
This function iterates through all columns in the provided record batch, extracts their Arrow proxy representations, and serializes them into a single byte vector that forms the body of the serialized data.
| record_batch | The record batch containing columns to be serialized. |
| stream | The output stream where the serialized body will be written. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache for compressed buffers to avoid recompression if compression is enabled. If compression is given, cache should be set as well. |
| SPARROW_IPC_API std::vector< sparrow::data_type > sparrow_ipc::get_column_dtypes | ( | const sparrow::record_batch & | rb | ) |
|
nodiscard |
|
nodiscard |
Definition at line 49 of file magic_values.hpp.
|
nodiscard |
Definition at line 37 of file magic_values.hpp.
|
nodiscard |
Definition at line 43 of file magic_values.hpp.
|
nodiscard |
|
nodiscard |
|
nodiscard |
Definition at line 32 of file deserialize.hpp.
|
nodiscard |
Definition at line 20 of file deserialize.hpp.
|
nodiscard |
|
inlinenodiscard |
|
nodiscard |
| SPARROW_IPC_API void sparrow_ipc::release_arrow_array_children_and_dictionary | ( | ArrowArray * | array | ) |
| void sparrow_ipc::release_common_non_owning_arrow | ( | T & | t | ) |
Release the children and dictionnary of an ArrowArray or ArrowSchema.
| T | ArrowArray or ArrowSchema |
| t | The ArrowArray or ArrowSchema to release. |
Definition at line 20 of file arrow_array_schema_common_release.hpp.
| SPARROW_IPC_API void sparrow_ipc::release_non_owning_arrow_schema | ( | ArrowSchema * | schema | ) |
| SPARROW_IPC_API serialized_record_batch_info sparrow_ipc::serialize_dictionary_batch | ( | int64_t | dictionary_id, |
| const sparrow::record_batch & | record_batch, | ||
| bool | is_delta, | ||
| any_output_stream & | stream, | ||
| std::optional< CompressionType > | compression, | ||
| std::optional< std::reference_wrapper< CompressionCache > > | cache ) |
Serializes a dictionary batch into a binary format following the Arrow IPC specification.
This function serializes a dictionary batch containing the actual values referenced by dictionary-encoded fields. The dictionary data is provided as a single-column record batch. The serialized output follows the Arrow IPC encapsulated message format.
| dictionary_id | The unique identifier for this dictionary, used to match with dictionary-encoded fields in record batches |
| record_batch | A single-column record batch containing the dictionary values |
| is_delta | If true, this dictionary should be appended to an existing dictionary with the same ID. If false, it replaces any existing dictionary. |
| stream | The output stream where the serialized dictionary batch will be written |
| compression | Optional: The compression type to use when serializing |
| cache | Optional: A cache to store and retrieve compressed buffers, avoiding recompression. If compression is given, cache should be set as well. |
| std::invalid_argument | if record_batch doesn't have exactly one column |
| SPARROW_IPC_API serialized_record_batch_info sparrow_ipc::serialize_record_batch | ( | const sparrow::record_batch & | record_batch, |
| any_output_stream & | stream, | ||
| std::optional< CompressionType > | compression, | ||
| std::optional< std::reference_wrapper< CompressionCache > > | cache ) |
Serializes a record batch into a binary format following the Arrow IPC specification.
This function converts a sparrow record batch into a serialized byte vector that includes:
| record_batch | The sparrow record batch to serialize |
| stream | The output stream where the serialized record batch will be written |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache to store and retrieve compressed buffers, avoiding recompression. |
| void sparrow_ipc::serialize_record_batches_to_ipc_stream | ( | const R & | record_batches, |
| any_output_stream & | stream, | ||
| std::optional< CompressionType > | compression, | ||
| std::optional< std::reference_wrapper< CompressionCache > > | cache ) |
Serializes a collection of record batches into a binary format.
This function takes a collection of record batches and serializes them into a single binary representation following the Arrow IPC format. The serialization includes:
| R | Container type that holds record batches (must support empty(), operator[], begin(), end()) |
| record_batches | Collection of record batches to serialize. All batches must have identical schemas. |
| stream | The output stream where the serialized data will be written. |
| compression | Optional: The compression type to use when serializing. |
| cache | Optional: A cache to store and retrieve compressed buffers, avoiding recompression. If compression is given, cache should be set as well. |
| std::invalid_argument | If record batches have inconsistent schemas or if the collection contains batches that cannot be serialized together. |
Definition at line 50 of file serialize.hpp.
| SPARROW_IPC_API void sparrow_ipc::serialize_schema_message | ( | const sparrow::record_batch & | record_batch, |
| any_output_stream & | stream ) |
Serializes a schema message for a record batch into a byte buffer.
Serializes a record batch schema into a binary message format.
This function creates a serialized schema message following the Arrow IPC format. The resulting buffer contains:
| record_batch | The record batch containing the schema to serialize |
| stream | The output stream where the serialized schema message will be written |
This function creates a serialized schema message by combining continuation bytes, a length prefix, the flatbuffer schema data, and padding to ensure 8-byte alignment. The resulting format follows the Arrow IPC specification for schema messages.
| record_batch | The record batch containing the schema to be serialized |
| stream | The output stream where the serialized schema message will be written |
| SPARROW_IPC_API size_t sparrow_ipc::write_footer | ( | const sparrow::record_batch & | record_batch, |
| const std::vector< record_batch_block > & | dictionary_blocks, | ||
| const std::vector< record_batch_block > & | record_batch_blocks, | ||
| any_output_stream & | stream ) |
Writes the Arrow IPC file footer.
| record_batch | A record batch containing the schema for the footer |
| record_batch_blocks | Vector of block information for each record batch |
| stream | The output stream to write the footer to |
|
inlineconstexpr |
Magic bytes with padding for file header (8 bytes total for alignment)
Definition at line 34 of file magic_values.hpp.
|
inlineconstexpr |
Magic bytes for Arrow file format defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format The magic string is "ARROW1" (6 bytes) followed by 2 padding bytes to reach 8-byte alignment.
Definition at line 28 of file magic_values.hpp.
|
inlineconstexpr |
Definition at line 29 of file magic_values.hpp.
|
inlineconstexpr |
Continuation value defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#encapsulated-message-format.
Definition at line 15 of file magic_values.hpp.
|
inlineconstexpr |
End-of-stream marker defined in the Arrow IPC specification: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format.
Definition at line 21 of file magic_values.hpp.
|
constexpr |
Definition at line 14 of file sparrow_ipc_version.hpp.
|
constexpr |
Definition at line 12 of file sparrow_ipc_version.hpp.
|
constexpr |
Definition at line 13 of file sparrow_ipc_version.hpp.
|
constexpr |
Definition at line 5 of file sparrow_ipc_version.hpp.
|
constexpr |
Definition at line 6 of file sparrow_ipc_version.hpp.
|
constexpr |
Definition at line 7 of file sparrow_ipc_version.hpp.