alamb commented on code in PR #5622:
URL: https://github.com/apache/arrow-rs/pull/5622#discussion_r1562485694


##########
arrow-json/src/writer/encoder.rs:
##########
@@ -443,3 +448,33 @@ impl<'a> Encoder for MapEncoder<'a> {
         out.push(b'}');
     }
 }
+
+struct FixedSizeBinaryEncoder<'a> {
+    array: &'a FixedSizeBinaryArray,
+    explicit_nulls: bool,
+}
+
+impl<'a> FixedSizeBinaryEncoder<'a> {
+    fn new(array: &'a FixedSizeBinaryArray, options: &EncoderOptions) -> Self {
+        Self {
+            array,
+            explicit_nulls: options.explicit_nulls,
+        }
+    }
+}
+
+impl<'a> Encoder for FixedSizeBinaryEncoder<'a> {
+    fn encode(&mut self, idx: usize, out: &mut Vec<u8>) {
+        if self.array.is_valid(idx) {

Review Comment:
   I double checked by making the following change locally and the tests all 
still pass. Thus I agree the valid is not needed
   
   ```diff
   diff --git a/arrow-json/src/writer/encoder.rs 
b/arrow-json/src/writer/encoder.rs
   index 27fa5747288..470d2fadd06 100644
   --- a/arrow-json/src/writer/encoder.rs
   +++ b/arrow-json/src/writer/encoder.rs
   @@ -101,7 +101,7 @@ fn make_encoder_impl<'a>(
   
            DataType::FixedSizeBinary(_) => {
                let array = 
array.as_any().downcast_ref::<FixedSizeBinaryArray>().unwrap();
   -            (Box::new(FixedSizeBinaryEncoder::new(array, options)) as _, 
array.nulls().cloned())
   +            (Box::new(FixedSizeBinaryEncoder::new(array)) as _, 
array.nulls().cloned())
            }
   
            DataType::Struct(fields) => {
   @@ -451,14 +451,12 @@ impl<'a> Encoder for MapEncoder<'a> {
   
    struct FixedSizeBinaryEncoder<'a> {
        array: &'a FixedSizeBinaryArray,
   -    explicit_nulls: bool,
    }
   
    impl<'a> FixedSizeBinaryEncoder<'a> {
   -    fn new(array: &'a FixedSizeBinaryArray, options: &EncoderOptions) -> 
Self {
   +    fn new(array: &'a FixedSizeBinaryArray) -> Self {
            Self {
                array,
   -            explicit_nulls: options.explicit_nulls,
            }
        }
    }
   @@ -473,8 +471,6 @@ impl<'a> Encoder for FixedSizeBinaryEncoder<'a> {
                    write!(out, "{byte:02x}").unwrap();
                }
                out.push(b'"');
   -        } else if self.explicit_nulls {
   -            out.extend_from_slice(b"null");
            }
        }
    }
   ```



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