Jimexist commented on code in PR #3057: URL: https://github.com/apache/arrow-rs/pull/3057#discussion_r1020310141
########## parquet/src/bloom_filter/mod.rs: ########## @@ -0,0 +1,212 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! Bloom filter implementation specific to Parquet, as described +//! in the [spec](https://github.com/apache/parquet-format/blob/master/BloomFilter.md) + +use crate::errors::ParquetError; +use crate::file::metadata::ColumnChunkMetaData; +use crate::format::{ + BloomFilterAlgorithm, BloomFilterCompression, BloomFilterHash, BloomFilterHeader, +}; +use std::hash::Hasher; +use std::io::{Read, Seek, SeekFrom}; +use thrift::protocol::TCompactInputProtocol; +use twox_hash::XxHash64; + +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". +type Block = [u32; 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) -> Block { + let mut result = [0_u32; 8]; + for i in 0..8 { + // wrapping instead of checking for overflow Review Comment: basically it's very likely to wrap given the salt is numerically large, but the idea of salting is to make the distribution pseudo random so wrapping is a good idea. -- 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]
