2014-07-07 16:24:12 +00:00
|
|
|
{- bloomfilter compatability wrapper
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-07-07 16:24:12 +00:00
|
|
|
-
|
|
|
|
- License: BSD-2-clause
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
|
|
|
module Utility.Bloom (
|
|
|
|
Bloom,
|
2014-09-12 16:26:12 +00:00
|
|
|
safeSuggestSizing,
|
2015-06-16 22:37:41 +00:00
|
|
|
Hashable(..),
|
2014-07-07 16:24:12 +00:00
|
|
|
cheapHashes,
|
2015-06-16 22:38:12 +00:00
|
|
|
elemB,
|
2014-07-07 16:24:12 +00:00
|
|
|
notElemB,
|
|
|
|
|
|
|
|
newMB,
|
|
|
|
insertMB,
|
|
|
|
unsafeFreezeMB,
|
|
|
|
) where
|
|
|
|
|
|
|
|
#if MIN_VERSION_bloomfilter(2,0,0)
|
|
|
|
import qualified Data.BloomFilter.Mutable as MBloom
|
|
|
|
import qualified Data.BloomFilter as Bloom
|
|
|
|
#else
|
|
|
|
import qualified Data.BloomFilter as Bloom
|
|
|
|
#endif
|
2014-09-12 16:26:12 +00:00
|
|
|
import Data.BloomFilter.Easy (safeSuggestSizing, Bloom)
|
2015-06-16 22:37:41 +00:00
|
|
|
import Data.BloomFilter.Hash (Hashable(..), cheapHashes)
|
2015-05-10 18:42:16 +00:00
|
|
|
import Control.Monad.ST (ST)
|
2014-07-07 16:24:12 +00:00
|
|
|
|
|
|
|
#if MIN_VERSION_bloomfilter(2,0,0)
|
|
|
|
|
|
|
|
notElemB :: a -> Bloom a -> Bool
|
|
|
|
notElemB = Bloom.notElem
|
|
|
|
|
2015-06-16 22:38:12 +00:00
|
|
|
elemB :: a -> Bloom a -> Bool
|
|
|
|
elemB = Bloom.elem
|
|
|
|
|
2014-07-07 16:24:12 +00:00
|
|
|
newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (MBloom.MBloom s a)
|
|
|
|
newMB = MBloom.new
|
|
|
|
|
|
|
|
insertMB :: MBloom.MBloom s a -> a -> ST s ()
|
|
|
|
insertMB = MBloom.insert
|
|
|
|
|
|
|
|
unsafeFreezeMB :: MBloom.MBloom s a -> ST s (Bloom a)
|
|
|
|
unsafeFreezeMB = Bloom.unsafeFreeze
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
notElemB :: a -> Bloom a -> Bool
|
|
|
|
notElemB = Bloom.notElemB
|
|
|
|
|
2015-06-16 22:38:12 +00:00
|
|
|
elemB :: a -> Bloom a -> Bool
|
|
|
|
elemB = Bloom.elem
|
|
|
|
|
2014-07-07 16:24:12 +00:00
|
|
|
newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (Bloom.MBloom s a)
|
|
|
|
newMB = Bloom.newMB
|
|
|
|
|
|
|
|
insertMB :: Bloom.MBloom s a -> a -> ST s ()
|
|
|
|
insertMB = Bloom.insertMB
|
|
|
|
|
|
|
|
unsafeFreezeMB :: Bloom.MBloom s a -> ST s (Bloom a)
|
|
|
|
unsafeFreezeMB = Bloom.unsafeFreezeMB
|
|
|
|
|
|
|
|
#endif
|