jecsand838 commented on code in PR #8274:
URL: https://github.com/apache/arrow-rs/pull/8274#discussion_r2325734395
##########
arrow-avro/src/writer/encoder.rs:
##########
@@ -84,36 +81,186 @@ fn write_bool<W: Write + ?Sized>(writer: &mut W, v: bool)
-> Result<(), ArrowErr
/// Branch index is 0-based per Avro unions:
/// - Null-first (default): null => 0, value => 1
/// - Null-second (Impala): value => 0, null => 1
-#[inline]
fn write_optional_index<W: Write + ?Sized>(
writer: &mut W,
is_null: bool,
- order: Nullability,
+ null_order: Nullability,
) -> Result<(), ArrowError> {
- // For NullFirst: null => 0x00, value => 0x02
- // For NullSecond: value => 0x00, null => 0x02
- let byte = match order {
- Nullability::NullFirst => {
- if is_null {
- 0x00
- } else {
- 0x02
- }
- }
- Nullability::NullSecond => {
- if is_null {
- 0x02
- } else {
- 0x00
- }
- }
- };
+ let byte = union_value_branch_byte(null_order, is_null);
writer
.write_all(&[byte])
.map_err(|e| ArrowError::IoError(format!("write union branch: {e}"),
e))
}
-/// Per‑site encoder plan for a field. This mirrors Avro structure so nested
+#[derive(Debug, Clone)]
+enum NullState {
+ NonNullable,
+ NullableNoNulls {
+ byte: u8,
Review Comment:
100%, much more descriptive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]