![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Thrift Compact Protocol writer. More...
#include <compact.hpp>
Public Member Functions | |
| CompactEncoder () | |
| Default constructor. Initializes field-ID stack with a single zero entry. | |
| void | write_field (int16_t field_id, uint8_t thrift_type) |
| Write a field header. | |
| void | write_stop () |
| Write struct stop marker (0x00). | |
| void | begin_struct () |
| Push a new field-ID context for a nested struct. | |
| void | end_struct () |
| Pop the field-ID context after finishing a nested struct. | |
| void | write_bool (bool val) |
| Write a standalone bool (not embedded in a field header). | |
| void | write_i8 (int8_t val) |
| Write an 8-bit signed integer as a single raw byte (I8 wire type). | |
| void | write_field_bool (int16_t field_id, bool val) |
| Write a bool field where the value is embedded in the field header's type nibble (1 = true, 2 = false). | |
| void | write_i32 (int32_t val) |
| Write a 32-bit integer as zigzag + varint. | |
| void | write_i64 (int64_t val) |
| Write a 64-bit integer as zigzag + varint. | |
| void | write_double (double val) |
| Write a double as 8 bytes little-endian (IEEE 754). | |
| void | write_float (float val) |
| Write a float as 4 bytes little-endian (IEEE 754). | |
| void | write_string (const std::string &val) |
| Write a string as varint-length-prefixed UTF-8 bytes. | |
| void | write_binary (const uint8_t *data, size_t len) |
| Write raw binary data as varint-length-prefixed bytes. | |
| void | write_list_header (uint8_t elem_type, int32_t size) |
| Write a list header. | |
| const std::vector< uint8_t > & | data () const |
| Returns a const reference to the underlying byte buffer. | |
| size_t | size () const |
| Returns the current size of the encoded buffer in bytes. | |
| void | clear () |
| Resets the encoder to its initial state (empty buffer, field ID stack reset to a single zero entry). | |
Static Public Attributes | |
| static constexpr size_t | MAX_STRING_BYTES = 64u * 1024u * 1024u |
| Maximum string/binary field size (matches CompactDecoder::MAX_STRING_BYTES). | |
Thrift Compact Protocol writer.
Writes Thrift Compact Protocol data into an internal byte buffer. Supports nested structs, delta field encoding, zigzag+varint integers, and all standard compact types. Used to serialize Parquet FileMetaData and related structures.
Definition at line 72 of file compact.hpp.
|
inline |
Default constructor. Initializes field-ID stack with a single zero entry.
Definition at line 78 of file compact.hpp.
|
inline |
Push a new field-ID context for a nested struct.
Definition at line 100 of file compact.hpp.
|
inline |
Resets the encoder to its initial state (empty buffer, field ID stack reset to a single zero entry).
Definition at line 207 of file compact.hpp.
|
inline |
Returns a const reference to the underlying byte buffer.
Definition at line 200 of file compact.hpp.
|
inline |
Pop the field-ID context after finishing a nested struct.
Definition at line 103 of file compact.hpp.
|
inline |
Returns the current size of the encoded buffer in bytes.
Definition at line 203 of file compact.hpp.
|
inline |
Write raw binary data as varint-length-prefixed bytes.
| std::overflow_error | if len > MAX_STRING_BYTES. |
Definition at line 174 of file compact.hpp.
|
inline |
Write a standalone bool (not embedded in a field header).
Definition at line 108 of file compact.hpp.
|
inline |
Write a double as 8 bytes little-endian (IEEE 754).
Definition at line 144 of file compact.hpp.
|
inline |
Write a field header.
Uses delta encoding when field_id - last_field_id is in [1, 15], otherwise writes the type byte followed by a zigzag varint of the field ID.
Definition at line 85 of file compact.hpp.
|
inline |
Write a bool field where the value is embedded in the field header's type nibble (1 = true, 2 = false).
This is the standard compact protocol encoding for bool fields.
Definition at line 120 of file compact.hpp.
|
inline |
Write a float as 4 bytes little-endian (IEEE 754).
Note: Not part of standard Thrift compact protocol, but useful for Parquet FLOAT columns and other binary formats.
Definition at line 154 of file compact.hpp.
|
inline |
Write a 32-bit integer as zigzag + varint.
Definition at line 134 of file compact.hpp.
|
inline |
Write a 64-bit integer as zigzag + varint.
Definition at line 139 of file compact.hpp.
|
inline |
Write an 8-bit signed integer as a single raw byte (I8 wire type).
Definition at line 113 of file compact.hpp.
|
inline |
Write a list header.
If size <= 14, uses the compact single-byte form. Otherwise writes (0xF0 | elem_type) followed by a varint size.
Definition at line 185 of file compact.hpp.
|
inline |
Write struct stop marker (0x00).
Definition at line 97 of file compact.hpp.
|
inline |
Write a string as varint-length-prefixed UTF-8 bytes.
| std::overflow_error | if val.size() > MAX_STRING_BYTES. |
Definition at line 163 of file compact.hpp.
|
staticconstexpr |
Maximum string/binary field size (matches CompactDecoder::MAX_STRING_BYTES).
64 MB
Definition at line 75 of file compact.hpp.