-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Pure and impure Bloom Filter implementations. -- -- Pure and impure Bloom Filter implementations. @package bloomfilter @version 2.0.1.2 -- | Fast hashing of Haskell values. The hash functions used are Bob -- Jenkins's public domain functions, which combine high performance with -- excellent mixing properties. For more details, see -- http://burtleburtle.net/bob/hash/. -- -- In addition to the usual "one input, one output" hash functions, this -- module provides multi-output hash functions, suitable for use in -- applications that need multiple hashes, such as Bloom filtering. module Data.BloomFilter.Hash class Hashable a -- | Compute a 32-bit hash of a value. The salt value perturbs the result. hashIO32 :: Hashable a => a -> Word32 -> IO Word32 -- | Compute a 64-bit hash of a value. The first salt value perturbs the -- first element of the result, and the second salt perturbs the second. hashIO64 :: Hashable a => a -> Word64 -> IO Word64 -- | Compute a 32-bit hash. hash32 :: Hashable a => a -> Word32 hash64 :: Hashable a => a -> Word64 -- | Compute a salted 32-bit hash. hashSalt32 :: Hashable a => Word32 -> a -> Word32 -- | Compute a salted 64-bit hash. hashSalt64 :: Hashable a => Word64 -> a -> Word64 -- | Compute a list of 32-bit hashes. The value to hash may be inspected as -- many times as there are hashes requested. hashes :: Hashable a => Int -> a -> [Word32] -- | Compute a list of 32-bit hashes relatively cheaply. The value to hash -- is inspected at most twice, regardless of the number of hashes -- requested. -- -- We use a variant of Kirsch and Mitzenmacher's technique from "Less -- Hashing, Same Performance: Building a Better Bloom Filter", -- http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf. -- -- Where Kirsch and Mitzenmacher multiply the second hash by a -- coefficient, we shift right by the coefficient. This offers better -- performance (as a shift is much cheaper than a multiply), and the low -- order bits of the final hash stay well mixed. cheapHashes :: Hashable a => Int -> a -> [Word32] -- | Compute a 32-bit hash of a Storable instance. hashOne32 :: Storable a => a -> Word32 -> IO Word32 -- | Compute a 64-bit hash of a Storable instance. hashOne64 :: Storable a => a -> Word64 -> IO Word64 -- | Compute a 32-bit hash of a list of Storable instances. hashList32 :: Storable a => [a] -> Word32 -> IO Word32 -- | Compute a 64-bit hash of a list of Storable instances. hashList64 :: Storable a => [a] -> Word64 -> IO Word64 instance Data.BloomFilter.Hash.Hashable () instance Data.BloomFilter.Hash.Hashable GHC.Num.Integer.Integer instance Data.BloomFilter.Hash.Hashable GHC.Types.Bool instance Data.BloomFilter.Hash.Hashable GHC.Types.Ordering instance Data.BloomFilter.Hash.Hashable GHC.Types.Char instance Data.BloomFilter.Hash.Hashable GHC.Types.Int instance Data.BloomFilter.Hash.Hashable GHC.Types.Float instance Data.BloomFilter.Hash.Hashable GHC.Types.Double instance Data.BloomFilter.Hash.Hashable GHC.Int.Int8 instance Data.BloomFilter.Hash.Hashable GHC.Int.Int16 instance Data.BloomFilter.Hash.Hashable GHC.Int.Int32 instance Data.BloomFilter.Hash.Hashable GHC.Int.Int64 instance Data.BloomFilter.Hash.Hashable GHC.Word.Word8 instance Data.BloomFilter.Hash.Hashable GHC.Word.Word16 instance Data.BloomFilter.Hash.Hashable GHC.Word.Word32 instance Data.BloomFilter.Hash.Hashable GHC.Word.Word64 instance Data.BloomFilter.Hash.Hashable Data.ByteString.Internal.ByteString instance Data.BloomFilter.Hash.Hashable Data.ByteString.Lazy.Internal.ByteString instance Data.BloomFilter.Hash.Hashable a => Data.BloomFilter.Hash.Hashable (GHC.Maybe.Maybe a) instance (Data.BloomFilter.Hash.Hashable a, Data.BloomFilter.Hash.Hashable b) => Data.BloomFilter.Hash.Hashable (Data.Either.Either a b) instance (Data.BloomFilter.Hash.Hashable a, Data.BloomFilter.Hash.Hashable b) => Data.BloomFilter.Hash.Hashable (a, b) instance (Data.BloomFilter.Hash.Hashable a, Data.BloomFilter.Hash.Hashable b, Data.BloomFilter.Hash.Hashable c) => Data.BloomFilter.Hash.Hashable (a, b, c) instance (Data.BloomFilter.Hash.Hashable a, Data.BloomFilter.Hash.Hashable b, Data.BloomFilter.Hash.Hashable c, Data.BloomFilter.Hash.Hashable d) => Data.BloomFilter.Hash.Hashable (a, b, c, d) instance (Data.BloomFilter.Hash.Hashable a, Data.BloomFilter.Hash.Hashable b, Data.BloomFilter.Hash.Hashable c, Data.BloomFilter.Hash.Hashable d, Data.BloomFilter.Hash.Hashable e) => Data.BloomFilter.Hash.Hashable (a, b, c, d, e) instance Foreign.Storable.Storable a => Data.BloomFilter.Hash.Hashable [a] -- | A fast, space efficient Bloom filter implementation. A Bloom filter is -- a set-like data structure that provides a probabilistic membership -- test. -- --
-- import Data.BloomFilter.Hash (cheapHashes) -- -- filt = fromList (cheapHashes 3) 1024 ["foo", "bar", "quux"] -- --fromList :: (a -> [Hash]) -> Int -> [a] -> Bloom a -- | Create an empty Bloom filter. -- -- This function is subject to fusion with insert and -- insertList. empty :: (a -> [Hash]) -> Int -> Bloom a -- | Create a Bloom filter with a single element. -- -- This function is subject to fusion with insert and -- insertList. singleton :: (a -> [Hash]) -> Int -> a -> Bloom a -- | Return the size of an immutable Bloom filter, in bits. length :: Bloom a -> Int -- | Query an immutable Bloom filter for membership. If the value is -- present, return True. If the value is not present, there is -- still some possibility that True will be returned. elem :: a -> Bloom a -> Bool -- | Query an immutable Bloom filter for non-membership. If the value -- is present, return False. If the value is not present, -- there is still some possibility that False will be -- returned. notElem :: a -> Bloom a -> Bool -- | Create a new Bloom filter from an existing one, with the given member -- added. -- -- This function may be expensive, as it is likely to cause the -- underlying bit array to be copied. -- -- Repeated applications of this function with itself are subject to -- fusion. insert :: a -> Bloom a -> Bloom a -- | Create a new Bloom filter from an existing one, with the given members -- added. -- -- This function may be expensive, as it is likely to cause the -- underlying bit array to be copied. -- -- Repeated applications of this function with itself are subject to -- fusion. insertList :: [a] -> Bloom a -> Bloom a bitArray :: Bloom a -> UArray Int Hash instance GHC.Show.Show (Data.BloomFilter.Bloom a) instance Control.DeepSeq.NFData (Data.BloomFilter.Bloom a) -- | An easy-to-use Bloom filter interface. module Data.BloomFilter.Easy -- | An immutable Bloom filter, suitable for querying from pure code. data Bloom a -- | Create a Bloom filter with the given false positive rate and members. -- The hash functions used are computed by the cheapHashes -- function from the Hash module. easyList :: Hashable a => Double -> [a] -> Bloom a -- | Query an immutable Bloom filter for membership. If the value is -- present, return True. If the value is not present, there is -- still some possibility that True will be returned. elem :: a -> Bloom a -> Bool -- | Query an immutable Bloom filter for non-membership. If the value -- is present, return False. If the value is not present, -- there is still some possibility that False will be -- returned. notElem :: a -> Bloom a -> Bool -- | Return the size of an immutable Bloom filter, in bits. length :: Bloom a -> Int -- | Suggest a good combination of filter size and number of hash functions -- for a Bloom filter, based on its expected maximum capacity and a -- desired false positive rate. -- -- The false positive rate is the rate at which queries against the -- filter should return True when an element is not actually -- present. It should be a fraction between 0 and 1, so a 1% false -- positive rate is represented by 0.01. safeSuggestSizing :: Int -> Double -> Either String (Int, Int) -- | Behaves as safeSuggestSizing, but calls error if given -- invalid or out-of-range inputs. suggestSizing :: Int -> Double -> (Int, Int)