Documentation
¶
Overview ¶
Package tupleordering is Java's TupleOrdering: tuples packed so that their byte order is a chosen direction and NULL placement, the encoding order functions store in index keys. The planner's ordered-bytes Values and the record layer's key evaluation share it.
Index ¶
- Variables
- func ElementEndPos(data []byte, pos int) (int, error)
- func Invert(input []byte) []byte
- func Pack(t tuple.Tuple, dir Direction) []byte
- func PackNullsLast(t tuple.Tuple) []byte
- func Uninvert(inverted []byte) ([]byte, error)
- func Unpack(packed []byte, dir Direction) (tuple.Tuple, error)
- func UnpackNullsLast(data []byte) (tuple.Tuple, error)
- type Direction
Constants ¶
This section is empty.
Variables ¶
var ( AscNullsFirst = Direction{Inverted: false, CounterflowNulls: false} AscNullsLast = Direction{Inverted: false, CounterflowNulls: true} DescNullsFirst = Direction{Inverted: true, CounterflowNulls: true} DescNullsLast = Direction{Inverted: true, CounterflowNulls: false} )
The four directions of Java's TupleOrdering.Direction.
Functions ¶
func ElementEndPos ¶
ElementEndPos finds the end position (exclusive) of a single tuple element starting at data[pos]. Used by UnpackNullsLast to parse element boundaries.
func Invert ¶
Invert applies byte-level inversion for DESC ordering. Each input byte is bit-flipped (XOR 0xFF), then the flipped bits are packed 7 bits per output byte (high bit always 0). A terminator byte with high bit set encodes the padding length.
This ensures that when comparing inverted byte sequences lexicographically:
- Opposite ordering of original values (due to bit flip)
- Shorter strings sort AFTER longer ones with the same prefix (due to 7-bit packing where terminators with high bit 1 sort after data bytes with high bit 0)
Matches Java's TupleOrdering.invert() exactly.
func Pack ¶
Pack encodes t in direction dir (TupleOrdering.pack). A tuple holding an incomplete versionstamp cannot be packed; the caller refuses it first.
func PackNullsLast ¶
PackNullsLast encodes a tuple element-by-element, replacing nil elements with a single 0xFE byte (which sorts after all standard tuple type codes). Matches Java's TupleOrdering.PackNullsLast().
func Uninvert ¶
Uninvert reverses Invert, recovering the original byte sequence. Matches Java's TupleOrdering.uninvert() exactly.