Expand description
HyperBinary COPY format support.
This module provides support for Hyper’s binary COPY format (HyperBinary),
which differs from standard PostgreSQL binary COPY in several ways
optimized for throughput.
§Format Overview
The HyperBinary format consists of:
- Header:
"HPRCPY"+ 13 null bytes (19 bytes total) - Data: Values with null indicators (1 byte each for nullable columns)
- All values are little-endian encoded
- No tuple start markers (unlike
PostgreSQL)
For nullable columns: [1 byte null indicator (0=not null, 1=null)] + [value]
For non-nullable columns: just [value] (no indicator)
§Differences from PostgreSQL Binary COPY
| Aspect | PostgreSQL | HyperBinary |
|---|---|---|
| Header signature | "PGCOPY\n\xff\r\n\0" (11 bytes) + flags + ext | "HPRCPY" + 13 null bytes (19 bytes) |
| Byte order | Big-endian (network order) | Little-endian (x86 native) |
| Row framing | 2-byte field count per row | No per-row framing |
| Null encoding | -1 length prefix (4 bytes) | 1-byte indicator on nullable columns only |
| Non-null values | 4-byte length prefix + data | Raw data (fixed-size) or length-prefixed (variable) |
| Trailer | 2-byte -1 sentinel | None |
The little-endian encoding and absence of per-row framing reduce both encoding overhead and byte-swapping on x86/ARM-LE architectures, which is where Hyper is typically deployed.
Structs§
- Copy
Data Builder - A builder for
HyperBinaryCOPY data.
Enums§
- Copy
Read Error - Errors that can occur when reading
HyperBinaryCOPY data.
Constants§
- HYPER_
BINARY_ FORMAT - The
HyperBinarydata format identifier for Hyper’s protocol. - HYPER_
BINARY_ HEADER - The full
HyperBinaryCOPY header (19 bytes). - HYPER_
BINARY_ HEADER_ SIZE - Size of the
HyperBinaryheader (19 bytes). - HYPER_
BINARY_ SIGNATURE - The
HyperBinaryCOPY signature (“HPRCPY” + 13 null bytes).
Functions§
- read_
data128 - Reads a 128-bit value from
HyperBinaryformat. - read_i8
- Reads an i8 value from
HyperBinaryformat (LittleEndian). - read_
i16 - Reads an i16 value from
HyperBinaryformat (LittleEndian). - read_
i32 - Reads an i32 value from
HyperBinaryformat (LittleEndian). - read_
i64 - Reads an i64 value from
HyperBinaryformat (LittleEndian). - read_
varbinary - Reads a variable-length binary value from
HyperBinaryformat. - write_
data128 - Writes a 128-bit value (NUMERIC, INTERVAL) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 16 bytes LittleEndian]
- write_
data128_ not_ null - Writes a 128-bit value for a non-nullable column.
Format: [value: 16 bytes
LittleEndian] - write_
f32 - Writes an f32 value (REAL/FLOAT4) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 4 bytes LittleEndian]
- write_
f64 - Writes an f64 value (DOUBLE PRECISION/FLOAT8) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 8 bytes LittleEndian]
- write_
f32_ not_ null - Writes an f32 value for a non-nullable column.
Format: [value: 4 bytes
LittleEndian] - write_
f64_ not_ null - Writes an f64 value for a non-nullable column.
Format: [value: 8 bytes
LittleEndian] - write_
header - Writes the
HyperBinaryCOPY header to a buffer. - write_
i8 - Writes an i8 value (bool) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 1 byte]
- write_
i8_ not_ null - Writes an i8 value for a non-nullable column. Format: [value: 1 byte] (no null indicator)
- write_
i16 - Writes an i16 value (SMALLINT) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 2 bytes LittleEndian]
- write_
i32 - Writes an i32 value (INT) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 4 bytes LittleEndian]
- write_
i64 - Writes an i64 value (BIGINT) for a nullable column. Format: [not-null indicator: 1 byte (0)][value: 8 bytes LittleEndian]
- write_
i16_ not_ null - Writes an i16 value for a non-nullable column.
Format: [value: 2 bytes
LittleEndian] - write_
i32_ not_ null - Writes an i32 value for a non-nullable column.
Format: [value: 4 bytes
LittleEndian] - write_
i64_ not_ null - Writes an i64 value for a non-nullable column.
Format: [value: 8 bytes
LittleEndian] - write_
null - Writes a NULL value (1 byte with value 1).
- write_
trailer - Writes the COPY trailer (no-op for
HyperBinary). - write_
tuple_ start - Writes a tuple start marker (no-op for
HyperBinary). - write_
varbinary - Writes a variable-length binary value (TEXT, BYTEA) for a nullable column. Format: [not-null indicator: 1 byte (0)][length: 4 bytes LittleEndian][data: N bytes]
- write_
varbinary_ not_ null - Writes a variable-length binary value for a non-nullable column.
Format: [length: 4 bytes
LittleEndian][data: N bytes]