pub struct TupleOutput { /* private fields */ }Expand description
A writer for tuple-encoded byte data.
Writes primitive values to a growable byte buffer using the same encoding formats
as TupleOutput. Signed integers use big-endian with the sign bit
flipped for sortable ordering. Floats use IEEE 754 with bit manipulation
for sortable ordering.
Implementations§
Source§impl TupleOutput
impl TupleOutput
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new TupleOutput with the given initial capacity.
Sourcepub fn to_database_entry(&self) -> DatabaseEntry
pub fn to_database_entry(&self) -> DatabaseEntry
Converts the written data to a DatabaseEntry.
Sourcepub fn write_bool(&mut self, val: bool)
pub fn write_bool(&mut self, val: bool)
Writes a boolean (one byte) value. True is stored as 1, false as 0.
Values can be read using TupleInput::read_bool.
Sourcepub fn write_u8(&mut self, val: u8)
pub fn write_u8(&mut self, val: u8)
Writes an unsigned byte value directly.
Values can be read using TupleInput::read_u8.
Sourcepub fn write_i8(&mut self, val: i8)
pub fn write_i8(&mut self, val: i8)
Writes a signed byte value with sign bit flipped for sort order.
Values can be read using TupleInput::read_i8.
Sourcepub fn write_u16(&mut self, val: u16)
pub fn write_u16(&mut self, val: u16)
Writes an unsigned short (two byte, big-endian) value.
Values can be read using TupleInput::read_u16.
Sourcepub fn write_i16(&mut self, val: i16)
pub fn write_i16(&mut self, val: i16)
Writes a signed short (two byte) value with sign bit flipped for sort order.
Values can be read using TupleInput::read_i16.
Sourcepub fn write_u32(&mut self, val: u32)
pub fn write_u32(&mut self, val: u32)
Writes an unsigned int (four byte, big-endian) value.
Values can be read using TupleInput::read_u32.
Sourcepub fn write_i32(&mut self, val: i32)
pub fn write_i32(&mut self, val: i32)
Writes a signed int (four byte) value with sign bit flipped for sort order.
Values can be read using TupleInput::read_i32.
Sourcepub fn write_u64(&mut self, val: u64)
pub fn write_u64(&mut self, val: u64)
Writes an unsigned long (eight byte, big-endian) value.
Values can be read using TupleInput::read_u64.
Sourcepub fn write_i64(&mut self, val: i64)
pub fn write_i64(&mut self, val: i64)
Writes a signed long (eight byte) value with sign bit flipped for sort order.
Values can be read using TupleInput::read_i64.
Sourcepub fn write_float(&mut self, val: f32)
pub fn write_float(&mut self, val: f32)
Writes an unsorted float (four byte) value as raw IEEE 754 big-endian bits.
This does NOT produce sortable byte ordering. Use write_sorted_float
for keys that need to sort correctly.
Values can be read using TupleInput::read_float.
Sourcepub fn write_double(&mut self, val: f64)
pub fn write_double(&mut self, val: f64)
Writes an unsorted double (eight byte) value as raw IEEE 754 big-endian bits.
This does NOT produce sortable byte ordering. Use write_sorted_double
for keys that need to sort correctly.
Values can be read using TupleInput::read_double.
Sourcepub fn write_sorted_float(&mut self, val: f32)
pub fn write_sorted_float(&mut self, val: f32)
Writes a sorted float (four byte) value using sign-bit manipulation.
The encoding ensures that the byte representation sorts in the same order as the float values:
- If negative (sign bit set): XOR all bits
- If positive (sign bit clear): XOR only the sign bit
Values can be read using TupleInput::read_sorted_float.
Sourcepub fn write_sorted_double(&mut self, val: f64)
pub fn write_sorted_double(&mut self, val: f64)
Writes a sorted double (eight byte) value using sign-bit manipulation.
The encoding ensures that the byte representation sorts in the same order as the double values:
- If negative (sign bit set): XOR all bits
- If positive (sign bit clear): XOR only the sign bit
Values can be read using TupleInput::read_sorted_double.
Sourcepub fn write_packed_int(&mut self, value: i32)
pub fn write_packed_int(&mut self, value: i32)
Writes a packed (variable-length) i32 value.
Values in [-119, 119] are stored in a single byte. Larger values use 2-5 bytes with the first byte encoding the sign and byte count.
This is an unsorted encoding - it is compact but the byte representation does NOT sort in the same order as the integer values.
Values can be read using TupleInput::read_packed_int.
Sourcepub fn write_packed_long(&mut self, value: i64)
pub fn write_packed_long(&mut self, value: i64)
Writes a packed (variable-length) i64 value.
Values in [-119, 119] are stored in a single byte. Larger values use 2-9 bytes with the first byte encoding the sign and byte count.
This is an unsorted encoding - it is compact but the byte representation does NOT sort in the same order as the integer values.
Values can be read using TupleInput::read_packed_long.
Sourcepub fn write_string(&mut self, val: &str)
pub fn write_string(&mut self, val: &str)
Writes a null-escaped UTF-8 string using null-byte escape format.
Each 0x00 byte in the string is escaped as the two-byte sequence [0x00, 0x01], and the string is terminated with [0x00, 0x00]. This allows strings containing embedded null bytes to round-trip correctly and preserves lexicographic sort order.
Values can be read using TupleInput::read_string.
Sourcepub fn write_bytes(&mut self, data: &[u8])
pub fn write_bytes(&mut self, data: &[u8])
Writes raw bytes to the buffer without any framing.
The caller must know the length when reading back.
Values can be read using TupleInput::read_bytes.
Sourcepub fn write_sorted_packed_int(&mut self, val: i32)
pub fn write_sorted_packed_int(&mut self, val: i32)
Writes a sorted packed (variable-length, order-preserving) i32 value.
Values in [-119, 120] are stored in a single byte as (value + 127).
Larger positive values use 2-5 bytes with first byte 0xF7 + N.
Smaller negative values use 2-5 bytes with first byte 0x08 - N.
The byte representation sorts in the same order as the integer values,
making this suitable for database keys. This is distinct from
write_packed_int, which is compact but NOT sortable.
/ TupleOutput.writeSortedPackedInt().
Values can be read using TupleInput::read_sorted_packed_int.
Sourcepub fn write_sorted_packed_long(&mut self, val: i64)
pub fn write_sorted_packed_long(&mut self, val: i64)
Writes a sorted packed (variable-length, order-preserving) i64 value.
Values in [-119, 120] are stored in a single byte as (value + 127).
Larger positive values use 2-9 bytes with first byte 0xF7 + N.
Smaller negative values use 2-9 bytes with first byte 0x08 - N.
The byte representation sorts in the same order as the integer values,
making this suitable for database keys. This is distinct from
write_packed_long, which is compact but NOT sortable.
/ TupleOutput.writeSortedPackedLong().
Values can be read using TupleInput::read_sorted_packed_long.
Sourcepub fn write_char(&mut self, val: u16)
pub fn write_char(&mut self, val: u16)
Writes a Java char (16-bit Unicode code point) as two big-endian bytes.
The encoding is identical to an unsigned big-endian u16: the high byte
first, then the low byte. This matches Java’s DataOutputStream.writeChar.
Values can be read using TupleInput::read_char.
Trait Implementations§
Source§impl Clone for TupleOutput
impl Clone for TupleOutput
Source§fn clone(&self) -> TupleOutput
fn clone(&self) -> TupleOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more