On Wed, Aug 27, 2008 at 6:10 AM, Matthew Toseland <toad at amphibian.dyndns.org> wrote: > On Wednesday 27 August 2008 09:41, Daniel Cheng wrote: >> On Wed, Aug 27, 2008 at 5:12 AM, <toad at freenetproject.org> wrote: >> > Author: toad >> > Date: 2008-08-26 21:12:19 +0000 (Tue, 26 Aug 2008) >> > New Revision: 22181 >> > >> > Modified: >> > branches/db4o/freenet/src/freenet/support/CountingBloomFilter.java >> > Log: >> > FIX MAJOR BUG IN COUNTING BLOOM FILTER: >> > / 4 not / 8 * 2. >> > setBit(1000) was effectively also doing setBit(1008). >> > PORT TO SALTED HASH STORE BRANCH ASAP! >> >> Your bloom filters are outdated. >> >> The Bloom filters was designed to work only at size of multiples of 8 . >> Salted hash store took the alternative approach by enforcing this in r22021. > > I don't understand how that would produce this bug. I was already using > multiples of 8. > > If you are trying to set bit number 1000, the location will be (with the old > code) 1000 / 8 * 2 = 250. The specific block within the byte will be 1000 % 4 > = 0. Now, if you try to set bit number 1004, the location with the old code > will be 1004 / 8 * 2 = 250, and the block within the byte will again be 0. > > Have you tried running the BloomFilterTest I committed against your code, with > a counting filter vs a non-counting one?
Why aren't you using a BitSet for this? Ian. -- Ian Clarke CEO, Uprizer Labs Email: ian at uprizer.com Cell: +1 512 422 3588
