scovich commented on code in PR #8274:
URL: https://github.com/apache/arrow-rs/pull/8274#discussion_r2322867316


##########
arrow-avro/src/writer/encoder.rs:
##########
@@ -84,48 +85,211 @@ fn write_bool<W: Write + ?Sized>(writer: &mut W, v: bool) 
-> Result<(), ArrowErr
 /// - Null-first (default): null => 0, value => 1
 /// - Null-second (Impala): value => 0, null => 1
 #[inline]
-fn write_optional_branch<W: Write + ?Sized>(
+fn write_optional_index<W: Write + ?Sized>(
     writer: &mut W,
     is_null: bool,
-    impala_mode: bool,
+    order: Nullability,
 ) -> Result<(), ArrowError> {
-    let branch = if impala_mode == is_null { 1 } else { 0 };
-    write_int(writer, branch)
+    // 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
+            }
+        }

Review Comment:
   Tho if there's only one place the two constants appear (see my other 
comment), then naming them matters less and we just need a decent code comment 
to explain it?



-- 
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]

Reply via email to