Struct datafusion::row::layout::RowLayout
source · pub struct RowLayout { /* private fields */ }
Expand description
Row layout stores one or multiple 8-byte word(s) per field for CPU-friendly and efficient processing.
It is mainly used to represent the rows with frequently updated content, for example, grouping state for hash aggregation.
Each tuple consists of two parts: “null bit set
” and “values
”.
For null-free tuples, the null bit set can be omitted.
The null bit set, when present, is aligned to 8 bytes. It stores one bit per field.
In the region of the values, we store the fields in the order they are defined in the schema. Each field is stored in one or multiple 8-byte words.
┌─────────────────┬─────────────────────┐
│Validity Bitmask │ Fields │
│ (8-byte aligned)│ (8-byte words) │
└─────────────────┴─────────────────────┘
For example, given the schema (Int8, Float32, Int64) with a null-free tuple
Encoding the tuple (1, 3.14, 42)
Requires 24 bytes (3 fields * 8 bytes each):
┌──────────────────────┬──────────────────────┬──────────────────────┐
│ 0x01 │ 0x4048F5C3 │ 0x0000002A │
└──────────────────────┴──────────────────────┴──────────────────────┘
0 8 16 24
If the schema allows null values and the tuple is (1, NULL, 42)
Encoding the tuple requires 32 bytes (1 * 8 bytes for the null bit set + 3 fields * 8 bytes each):
┌──────────────────────────┬──────────────────────┬──────────────────────┬──────────────────────┐
│ 0b00000101 │ 0x01 │ 0x00000000 │ 0x0000002A │
│ (7 bytes padding after) │ │ │ │
└──────────────────────────┴──────────────────────┴──────────────────────┴──────────────────────┘
0 8 16 24 32