Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Data.BloomFilter.Classic.Calc
Description
Various formulas for working with bloomfilters.
Synopsis
- type NumEntries = Int
- data BloomSize = BloomSize {
- sizeBits :: !Int
- sizeHashes :: !Int
- type FPR = Double
- sizeForFPR :: FPR -> NumEntries -> BloomSize
- type BitsPerEntry = Double
- sizeForBits :: BitsPerEntry -> NumEntries -> BloomSize
- sizeForPolicy :: BloomPolicy -> NumEntries -> BloomSize
- data BloomPolicy = BloomPolicy {
- policyBits :: !Double
- policyHashes :: !Int
- policyFPR :: BloomPolicy -> FPR
- policyForFPR :: FPR -> BloomPolicy
- policyForBits :: BitsPerEntry -> BloomPolicy
Documentation
type NumEntries = Int Source #
Parameters for constructing a Bloom filter.
Constructors
BloomSize | |
Fields
|
sizeForFPR :: FPR -> NumEntries -> BloomSize Source #
type BitsPerEntry = Double Source #
sizeForBits :: BitsPerEntry -> NumEntries -> BloomSize Source #
sizeForPolicy :: BloomPolicy -> NumEntries -> BloomSize Source #
data BloomPolicy Source #
A policy on intended bloom filter size -- independent of the number of elements.
We can decide a policy based on:
- a target false positive rate (FPR) using
policyForFPR
- a number of bits per entry using
policyForBits
A policy can be turned into a BloomSize
given a target NumEntries
using
sizeForPolicy
.
Either way we define the policy, we can inspect the result to see:
- The bits per entry
policyBits
. This will determine the size of the bloom filter in bits. In general the bits per entry can be fractional. The final bloom filter size in will be rounded to a whole number of bits. - The number of hashes
policyHashes
. - The expected FPR for the policy using
policyFPR
.
Constructors
BloomPolicy | |
Fields
|
Instances
Show BloomPolicy Source # | |
Defined in Data.BloomFilter.Classic.Calc Methods showsPrec :: Int -> BloomPolicy -> ShowS # show :: BloomPolicy -> String # showList :: [BloomPolicy] -> ShowS # |
policyFPR :: BloomPolicy -> FPR Source #
policyForFPR :: FPR -> BloomPolicy Source #