Skip to content

Commit 8505506

Browse files
Add union documentation
1 parent b1dfb69 commit 8505506

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

β€Žarrow-row/src/lib.rsβ€Ž

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,41 @@ mod variable;
415415
///
416416
///```
417417
///
418+
/// ## Union Encoding
419+
///
420+
/// A union value is encoded as the type id byte followed by the row encoding of the underlying type.
421+
/// Null values are handled by the underlying type's encoding.
422+
///
423+
/// For example, given a union of Int32 (type_id = 0) and Utf8 (type_id = 1):
424+
///
425+
/// ```text
426+
/// β”Œβ”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
427+
/// 3 β”‚00β”‚01β”‚80β”‚00β”‚00β”‚03β”‚
428+
/// β””β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
429+
/// β”‚ └─ signed integer encoding (non-null)
430+
/// └──── type_id
431+
///
432+
/// "abc" β”Œβ”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
433+
/// β”‚01β”‚02β”‚'a'β”‚'b'β”‚'c'β”‚00β”‚00β”‚00β”‚00β”‚00β”‚03β”‚
434+
/// β””β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
435+
/// β”‚ └──── string encoding (non-null)
436+
/// └──── type_id
437+
///
438+
/// null Int32 β”Œβ”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
439+
/// β”‚00β”‚00β”‚00β”‚00β”‚00β”‚00β”‚
440+
/// β””β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
441+
/// β”‚ └─ signed integer encoding (null)
442+
/// └──── type_id
443+
///
444+
/// null Utf8 β”Œβ”€β”€β”¬β”€β”€β”
445+
/// β”‚01β”‚00β”‚
446+
/// β””β”€β”€β”΄β”€β”€β”˜
447+
/// β”‚ └─ string encoding (null)
448+
/// └──── type_id
449+
/// ```
450+
///
451+
/// See [`UnionArray`] for more details on union types.
452+
///
418453
/// # Ordering
419454
///
420455
/// ## Float Ordering
@@ -435,6 +470,11 @@ mod variable;
435470
///
436471
/// The order of a given column can be reversed by negating the encoded bytes of non-null values
437472
///
473+
/// ## Union Ordering
474+
///
475+
/// Values of the same type are ordered according to the ordering of that type.
476+
/// Values of different types are ordered by their type id.
477+
///
438478
/// [COBS]: https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing
439479
/// [byte stuffing]: https://en.wikipedia.org/wiki/High-Level_Data_Link_Control#Asynchronous_framing
440480
#[derive(Debug)]

0 commit comments

Comments
Β (0)