5
5
6
6
module Database.LSMTree.Internal.BloomFilter (
7
7
-- * Types
8
- BF . Bloom ,
9
- BF . MBloom ,
8
+ Bloom . Bloom ,
9
+ Bloom . MBloom ,
10
10
11
11
-- * Bulk query
12
12
bloomQueries ,
@@ -36,7 +36,6 @@ import Control.Monad.ST (ST, runST)
36
36
import System.FS.API
37
37
38
38
import Data.BloomFilter.Blocked (Bloom )
39
- import qualified Data.BloomFilter.Blocked as BF
40
39
import qualified Data.BloomFilter.Blocked as Bloom
41
40
import Database.LSMTree.Internal.ByteString (byteArrayToByteString )
42
41
import Database.LSMTree.Internal.CRC32C (FileCorruptedError (.. ),
@@ -167,19 +166,19 @@ bloomQueries !filters !keys =
167
166
-- | By writing out the version in host endianness, we also indicate endianness.
168
167
-- During deserialisation, we would discover an endianness mismatch.
169
168
--
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@
171
170
-- library, plus our own version here. This accounts both for changes in the
172
171
-- format code here, and changes in the library.
173
172
--
174
173
bloomFilterVersion :: Word32
175
- bloomFilterVersion = 1 + fromIntegral BF . formatVersion
174
+ bloomFilterVersion = 1 + fromIntegral Bloom . formatVersion
176
175
177
- bloomFilterToLBS :: BF. Bloom a -> LBS. ByteString
176
+ bloomFilterToLBS :: Bloom a -> LBS. ByteString
178
177
bloomFilterToLBS bf =
179
- let (size, ba, off, len) = BF . serialise bf
178
+ let (size, ba, off, len) = Bloom . serialise bf
180
179
in header size <> byteArrayToLBS ba off len
181
180
where
182
- header BF . BloomSize { sizeBits, sizeHashes } =
181
+ header Bloom . BloomSize { sizeBits, sizeHashes } =
183
182
-- creates a single 16 byte chunk
184
183
B. toLazyByteStringWith (B. safeStrategy 16 B. smallChunkSize) mempty $
185
184
B. word32Host bloomFilterVersion
@@ -196,14 +195,14 @@ bloomFilterToLBS bf =
196
195
{-# SPECIALISE bloomFilterFromFile ::
197
196
HasFS IO h
198
197
-> 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.
201
200
--
202
201
bloomFilterFromFile ::
203
202
(PrimMonad m , MonadCatch m )
204
203
=> HasFS m h
205
204
-> Handle h -- ^ The open file, in read mode
206
- -> m (BF. Bloom a )
205
+ -> m (Bloom a )
207
206
bloomFilterFromFile hfs h = do
208
207
header <- rethrowEOFError " Doesn't contain a header" $
209
208
hGetByteArrayExactly hfs h 16
@@ -225,10 +224,10 @@ bloomFilterFromFile hfs h = do
225
224
226
225
-- read the filter data from the file directly into the bloom filter
227
226
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
232
231
}
233
232
(\ buf off len ->
234
233
rethrowEOFError " bloom filter file too short" $
0 commit comments