packages feed

unagi-bloomfilter 0.1.1.0 → 0.1.1.1

raw patch · 3 files changed

+17/−5 lines, 3 files

Files

src/Control/Concurrent/BloomFilter/Internal.hs view
@@ -208,11 +208,13 @@ log2lFromArraySize sz =    either throwBloom return $ do     let dataSzBytes = sz - sIZEOF_METADATA-        log2lFloat = logBase 2 ((fromIntegral dataSzBytes / fromIntegral sIZEOF_INT) :: Float)-        log2l = floor log2lFloat+        (dataSzWds, z) = dataSzBytes `quotRem` sIZEOF_INT+        isPowerOfTwo n = n .&. (n - 1) == 0 -- when n > 0+     unless (dataSzBytes >= sIZEOF_INT) $ Left "Array is not large enough to be a serialized bloom filter"-    unless (fromIntegral log2l == log2lFloat) $ Left "Array is an unexpected size for a serialized bloom filter"-    return log2l+    unless (isPowerOfTwo dataSzWds && z == 0) $ Left "Array is an unexpected size for a serialized bloom filter"+    return $!+      countTrailingZeros dataSzWds -- logBase 2, when isPowerOfTwo     
tests/Main.hs view
@@ -417,6 +417,16 @@    serializeRoundtripsTest   serializeGoldenTests+  issue2Test++-- Issue #2: this triggered a bug from a careless bit of floating point arithmetic:+issue2Test :: IO ()+issue2Test = do+  sipKey <- pure $ (Bloom.SipKey 1 1)+  bloom <- Bloom.new sipKey 3 26 :: IO (Bloom.BloomFilter String)+  bloomBS <- Bloom.serialize bloom+  void $ (Bloom.deserialize sipKey bloomBS :: IO (Bloom.BloomFilter String))+  -- For validating that we can serialize and deserialize across machines, and -- try to handle forwards compatibility (later).
unagi-bloomfilter.cabal view
@@ -1,5 +1,5 @@ name:                unagi-bloomfilter-version:             0.1.1.0+version:             0.1.1.1 synopsis:            A fast, cache-efficient, concurrent bloom filter description:   This library implements a fast concurrent bloom filter, based on bloom-1 from