Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.BloomFilter
Contents
Synopsis
- data Bloom a
- data MBloom s a
- bloomQueries :: Vector (Bloom SerialisedKey) -> Vector SerialisedKey -> Vector RunIxKeyIx
- data RunIxKeyIx where
- pattern RunIxKeyIx :: RunIx -> KeyIx -> RunIxKeyIx
- type RunIx = Int
- type KeyIx = Int
- bloomFilterVersion :: Word32
- bloomFilterToLBS :: Bloom a -> ByteString
- bloomFilterFromFile :: (PrimMonad m, MonadCatch m) => HasFS m h -> Handle h -> m (Bloom a)
Types
An immutable Bloom filter.
A mutable Bloom filter, for use within the ST
monad.
Bulk query
bloomQueries :: Vector (Bloom SerialisedKey) -> Vector SerialisedKey -> Vector RunIxKeyIx Source #
Perform a batch of bloom queries. The result is a tuple of indexes into the vector of runs and vector of keys respectively. The order of keys and runs/filters in the input is maintained in the output. This implementation produces results in key-major order.
The result vector can be of variable length. The initial estimate is 2x the number of keys but this is grown if needed (using a doubling strategy).
data RunIxKeyIx where Source #
A RunIxKeyIx
is a (compact) pair of a RunIx
and a KeyIx
.
We represent it as a 32bit word, using:
- 16 bits for the run/filter index (MSB)
- 16 bits for the key index (LSB)
Bundled Patterns
pattern RunIxKeyIx :: RunIx -> KeyIx -> RunIxKeyIx |
Instances
Serialisation
bloomFilterVersion :: Word32 Source #
By writing out the version in host endianness, we also indicate endianness. During deserialisation, we would discover an endianness mismatch.
We base our version number on the formatVersion
from the bloomfilter
library, plus our own version here. This accounts both for changes in the
format code here, and changes in the library.
bloomFilterToLBS :: Bloom a -> ByteString Source #