ozgrakkurt commented on code in PR #4441:
URL: https://github.com/apache/arrow-rs/pull/4441#discussion_r1244953147


##########
parquet/src/bloom_filter/mod.rs:
##########
@@ -27,111 +27,19 @@ use crate::format::{
     SplitBlockAlgorithm, Uncompressed, XxHash,
 };
 use bytes::{Buf, Bytes};
-use std::hash::Hasher;
+use sbbf_rs_safe::Filter;
 use std::io::Write;
 use std::sync::Arc;
 use thrift::protocol::{
     TCompactInputProtocol, TCompactOutputProtocol, TOutputProtocol, 
TSerializable,
 };
-use twox_hash::XxHash64;
-
-/// Salt as defined in the 
[spec](https://github.com/apache/parquet-format/blob/master/BloomFilter.md#technical-approach).
-const SALT: [u32; 8] = [
-    0x47b6137b_u32,
-    0x44974d91_u32,
-    0x8824ad5b_u32,
-    0xa2b7289d_u32,
-    0x705495c7_u32,
-    0x2df1424b_u32,
-    0x9efc4947_u32,
-    0x5c6bfb31_u32,
-];
-
-/// Each block is 256 bits, broken up into eight contiguous "words", each 
consisting of 32 bits.
-/// Each word is thought of as an array of bits; each bit is either "set" or 
"not set".
-#[derive(Debug, Copy, Clone)]
-struct Block([u32; 8]);
-impl Block {
-    const ZERO: Block = Block([0; 8]);
-
-    /// takes as its argument a single unsigned 32-bit integer and returns a 
block in which each
-    /// word has exactly one bit set.
-    fn mask(x: u32) -> Self {
-        let mut result = [0_u32; 8];
-        for i in 0..8 {
-            // wrapping instead of checking for overflow
-            let y = x.wrapping_mul(SALT[i]);
-            let y = y >> 27;
-            result[i] = 1 << y;
-        }
-        Self(result)
-    }
-
-    #[inline]
-    #[cfg(target_endian = "little")]
-    fn to_le_bytes(self) -> [u8; 32] {
-        self.to_ne_bytes()
-    }
-
-    #[inline]
-    #[cfg(not(target_endian = "little"))]
-    fn to_le_bytes(self) -> [u8; 32] {
-        self.swap_bytes().to_ne_bytes()
-    }
-
-    #[inline]
-    fn to_ne_bytes(self) -> [u8; 32] {
-        unsafe { std::mem::transmute(self) }
-    }
-
-    #[inline]
-    #[cfg(not(target_endian = "little"))]
-    fn swap_bytes(mut self) -> Self {
-        self.0.iter_mut().for_each(|x| *x = x.swap_bytes());
-        self
-    }
-
-    /// setting every bit in the block that was also set in the result from 
mask
-    fn insert(&mut self, hash: u32) {
-        let mask = Self::mask(hash);
-        for i in 0..8 {
-            self[i] |= mask[i];
-        }
-    }
-
-    /// returns true when every bit that is set in the result of mask is also 
set in the block.
-    fn check(&self, hash: u32) -> bool {
-        let mask = Self::mask(hash);
-        for i in 0..8 {
-            if self[i] & mask[i] == 0 {
-                return false;
-            }
-        }
-        true
-    }
-}
-
-impl std::ops::Index<usize> for Block {
-    type Output = u32;
-
-    #[inline]
-    fn index(&self, index: usize) -> &Self::Output {
-        self.0.index(index)
-    }
-}
-
-impl std::ops::IndexMut<usize> for Block {
-    #[inline]
-    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
-        self.0.index_mut(index)
-    }
-}
+use xxhash_rust::xxh64::xxh64;

Review Comment:
   also in my `insert` bench I also call `contains` on `parquet` impl. But 
there is big diff in integration tests of writing parquet with bloom filters



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