tustvold commented on code in PR #3325:
URL: https://github.com/apache/arrow-rs/pull/3325#discussion_r1045851803


##########
parquet/src/bloom_filter/mod.rs:
##########
@@ -195,17 +196,69 @@ impl Sbbf {
     fn write_bitset<W: Write>(&self, mut writer: W) -> Result<(), 
ParquetError> {
         for block in &self.0 {
             for word in block {
-                writer.write_all(&word.to_le_bytes()).map_err(|e| {
-                    ParquetError::General(format!(
-                        "Could not write bloom filter bit set: {}",
-                        e
-                    ))
-                })?;
+                let pointer: *const u8 = (word as *const u32) as *const _;
+                let bytes: &[u8] =

Review Comment:
   NGL it is kind of disappointing that LLVM isn't able to automatically make 
this optimization, I will have a play and see if I can get it to do the correct 
thing



##########
parquet/src/bloom_filter/mod.rs:
##########
@@ -195,17 +196,69 @@ impl Sbbf {
     fn write_bitset<W: Write>(&self, mut writer: W) -> Result<(), 
ParquetError> {
         for block in &self.0 {
             for word in block {
-                writer.write_all(&word.to_le_bytes()).map_err(|e| {
-                    ParquetError::General(format!(
-                        "Could not write bloom filter bit set: {}",
-                        e
-                    ))
-                })?;
+                let pointer: *const u8 = (word as *const u32) as *const _;
+                let bytes: &[u8] =
+                    unsafe { slice::from_raw_parts(pointer, 
mem::size_of::<u32>()) };
+                if cfg!(target_endian = "big") {
+                    Self::write_all_for_big_endian(&mut writer, bytes)?;

Review Comment:
   Could we just use `word.to_le_bytes()` here, I imagine it will be faster 
than the code below and is certainly less code



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to