Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Data.BloomFilter.Blocked.BitArray
Description
Blocked bit array implementation. This uses blocks of 64 bytes, aligned to 64byte boundaries to match typical cache line sizes. This means that multiple accesses to the same block only require a single cache line load or store.
Synopsis
- newtype NumBlocks = NumBlocks Int
- bitsToBlocks :: Int -> NumBlocks
- blocksToBits :: NumBlocks -> Int
- newtype BlockIx = BlockIx Word
- newtype BitIx = BitIx Int
- newtype BitArray = BitArray (PrimArray Word64)
- unsafeIndex :: BitArray -> BlockIx -> BitIx -> Bool
- prefetchIndex :: BitArray -> BlockIx -> ST s ()
- newtype MBitArray s = MBitArray (MutablePrimArray s Word64)
- new :: NumBlocks -> ST s (MBitArray s)
- unsafeSet :: MBitArray s -> BlockIx -> BitIx -> ST s ()
- prefetchSet :: MBitArray s -> BlockIx -> ST s ()
- freeze :: MBitArray s -> ST s BitArray
- unsafeFreeze :: MBitArray s -> ST s BitArray
- thaw :: BitArray -> ST s (MBitArray s)
- serialise :: BitArray -> (ByteArray, Int, Int)
- deserialise :: PrimMonad m => MBitArray (PrimState m) -> (MutableByteArray (PrimState m) -> Int -> Int -> m ()) -> m ()
Documentation
Blocks are 512 bits, 64 bytes.
bitsToBlocks :: Int -> NumBlocks Source #
The number of 512-bit blocks for the given number of bits. This rounds up to the nearest multiple of 512.
blocksToBits :: NumBlocks -> Int Source #
An array of blocks of bits.
Each block is 512 bits (64 bytes large), corresponding to a cache line on most current architectures.
It is represented by an array of Word64
. This array is aligned to 64 bytes
so that multiple accesses within a single block will use only one cache line.
new :: NumBlocks -> ST s (MBitArray s) Source #
We create an explicitly pinned byte array, aligned to 64 bytes.
deserialise :: PrimMonad m => MBitArray (PrimState m) -> (MutableByteArray (PrimState m) -> Int -> Int -> m ()) -> m () Source #
Do an inplace overwrite of the byte array representing the bit block.