55
66module Database.LSMTree.Internal.BloomFilter (
77 -- * Types
8- BF . Bloom ,
9- BF . MBloom ,
8+ Bloom . Bloom ,
9+ Bloom . MBloom ,
1010
1111 -- * Bulk query
1212 bloomQueries ,
@@ -36,7 +36,6 @@ import Control.Monad.ST (ST, runST)
3636import System.FS.API
3737
3838import Data.BloomFilter.Blocked (Bloom )
39- import qualified Data.BloomFilter.Blocked as BF
4039import qualified Data.BloomFilter.Blocked as Bloom
4140import Database.LSMTree.Internal.ByteString (byteArrayToByteString )
4241import Database.LSMTree.Internal.CRC32C (FileCorruptedError (.. ),
@@ -167,19 +166,19 @@ bloomQueries !filters !keys =
167166-- | By writing out the version in host endianness, we also indicate endianness.
168167-- During deserialisation, we would discover an endianness mismatch.
169168--
170- -- We base our version number on the 'BF .formatVersion' from the @bloomfilter@
169+ -- We base our version number on the 'Bloom .formatVersion' from the @bloomfilter@
171170-- library, plus our own version here. This accounts both for changes in the
172171-- format code here, and changes in the library.
173172--
174173bloomFilterVersion :: Word32
175- bloomFilterVersion = 1 + fromIntegral BF . formatVersion
174+ bloomFilterVersion = 1 + fromIntegral Bloom . formatVersion
176175
177- bloomFilterToLBS :: BF. Bloom a -> LBS. ByteString
176+ bloomFilterToLBS :: Bloom a -> LBS. ByteString
178177bloomFilterToLBS bf =
179- let (size, ba, off, len) = BF . serialise bf
178+ let (size, ba, off, len) = Bloom . serialise bf
180179 in header size <> byteArrayToLBS ba off len
181180 where
182- header BF . BloomSize { sizeBits, sizeHashes } =
181+ header Bloom . BloomSize { sizeBits, sizeHashes } =
183182 -- creates a single 16 byte chunk
184183 B. toLazyByteStringWith (B. safeStrategy 16 B. smallChunkSize) mempty $
185184 B. word32Host bloomFilterVersion
@@ -196,14 +195,14 @@ bloomFilterToLBS bf =
196195{-# SPECIALISE bloomFilterFromFile ::
197196 HasFS IO h
198197 -> Handle h
199- -> IO (BF. Bloom a) #-}
200- -- | Read a 'BF. Bloom' from a file.
198+ -> IO (Bloom a) #-}
199+ -- | Read a 'Bloom' from a file.
201200--
202201bloomFilterFromFile ::
203202 (PrimMonad m , MonadCatch m )
204203 => HasFS m h
205204 -> Handle h -- ^ The open file, in read mode
206- -> m (BF. Bloom a )
205+ -> m (Bloom a )
207206bloomFilterFromFile hfs h = do
208207 header <- rethrowEOFError " Doesn't contain a header" $
209208 hGetByteArrayExactly hfs h 16
@@ -225,10 +224,10 @@ bloomFilterFromFile hfs h = do
225224
226225 -- read the filter data from the file directly into the bloom filter
227226 bloom <-
228- BF . deserialise
229- BF . BloomSize {
230- BF . sizeBits = fromIntegral nbits,
231- BF . sizeHashes = fromIntegral nhashes
227+ Bloom . deserialise
228+ Bloom . BloomSize {
229+ Bloom . sizeBits = fromIntegral nbits,
230+ Bloom . sizeHashes = fromIntegral nhashes
232231 }
233232 (\ buf off len ->
234233 rethrowEOFError " bloom filter file too short" $
0 commit comments