diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-06-16 18:38:12 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-06-16 18:50:13 -0400 |
commit | 2a4a641a3c940a652f62371f417433b47f7f3e79 (patch) | |
tree | e610e549f25dd4cd6719fcce9dcde14a69c46bd2 /Utility/Bloom.hs | |
parent | e3da28295e11972bcb14749ef294d1f39fb03efa (diff) |
use bloom filter in second pass of sync --all --content
This is needed because when preferred content matches on files,
the second pass would otherwise want to drop all keys. Using a bloom filter
avoids this, and in the case of a false positive, a key will be left
undropped that preferred content would allow dropping. Chances of that
happening are a mere 1 in 1 million.
Diffstat (limited to 'Utility/Bloom.hs')
-rw-r--r-- | Utility/Bloom.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Utility/Bloom.hs b/Utility/Bloom.hs index 9076abddb..668901f76 100644 --- a/Utility/Bloom.hs +++ b/Utility/Bloom.hs @@ -12,6 +12,7 @@ module Utility.Bloom ( safeSuggestSizing, Hashable(..), cheapHashes, + elemB, notElemB, newMB, @@ -34,6 +35,9 @@ import Control.Monad.ST (ST) notElemB :: a -> Bloom a -> Bool notElemB = Bloom.notElem +elemB :: a -> Bloom a -> Bool +elemB = Bloom.elem + newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (MBloom.MBloom s a) newMB = MBloom.new @@ -48,6 +52,9 @@ unsafeFreezeMB = Bloom.unsafeFreeze notElemB :: a -> Bloom a -> Bool notElemB = Bloom.notElemB +elemB :: a -> Bloom a -> Bool +elemB = Bloom.elem + newMB :: (a -> [Bloom.Hash]) -> Int -> ST s (Bloom.MBloom s a) newMB = Bloom.newMB |