lsm-tree-0.1.0.0: Log-structured merge-trees
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.LSMTree.Internal.BloomFilter

Synopsis

Types

data Bloom a Source #

An immutable Bloom filter.

Instances

Instances details
Show (Bloom a) 
Instance details

Defined in Data.BloomFilter.Blocked.Internal

Methods

showsPrec :: Int -> Bloom a -> ShowS #

show :: Bloom a -> String #

showList :: [Bloom a] -> ShowS #

NFData (Bloom a) 
Instance details

Defined in Data.BloomFilter.Blocked.Internal

Methods

rnf :: Bloom a -> () #

Eq (Bloom a) 
Instance details

Defined in Data.BloomFilter.Blocked.Internal

Methods

(==) :: Bloom a -> Bloom a -> Bool #

(/=) :: Bloom a -> Bloom a -> Bool #

data MBloom s a Source #

A mutable Bloom filter, for use within the ST monad.

Instances

Instances details
Show (MBloom s a) 
Instance details

Defined in Data.BloomFilter.Blocked.Internal

Methods

showsPrec :: Int -> MBloom s a -> ShowS #

show :: MBloom s a -> String #

showList :: [MBloom s a] -> ShowS #

NFData (MBloom s a) 
Instance details

Defined in Data.BloomFilter.Blocked.Internal

Methods

rnf :: MBloom s a -> () #

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 

type RunIx = Int Source #

type KeyIx = Int Source #

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.

bloomFilterFromFile Source #

Arguments

:: (PrimMonad m, MonadCatch m) 
=> HasFS m h 
-> Handle h

The open file, in read mode

-> m (Bloom a) 

Read a Bloom from a file.