On Monday 01 September 2008 02:39, Daniel Cheng wrote:
> On Sat, Aug 30, 2008 at 5:22 AM,  <toad at freenetproject.org> wrote:
> > Author: toad
> > Date: 2008-08-29 21:22:10 +0000 (Fri, 29 Aug 2008)
> > New Revision: 22216
> >
> > Modified:
> >   branches/db4o/freenet/src/freenet/support/CountingBloomFilter.java
> > Log:
> > Flag to log an error when we try to decrement a 0. This will indicate that 
we are removing the same key twice, or removing a key which was never added.
> 
> 
> use  Logger.shouldLog(Logger.DEBUG, ... ) ?

It's only enabled if the caller asks for it. The way that I use the filters, 
it's an error indicating a bug. Your code doesn't have to enable it.
> 
> > Modified: 
branches/db4o/freenet/src/freenet/support/CountingBloomFilter.java
> > ===================================================================
> > --- branches/db4o/freenet/src/freenet/support/CountingBloomFilter.java  
2008-08-29 14:10:52 UTC (rev 22215)
> > +++ branches/db4o/freenet/src/freenet/support/CountingBloomFilter.java  
2008-08-29 21:22:10 UTC (rev 22216)
> > @@ -13,6 +13,13 @@
> >  * @author sdiz
> >  */
> >  public class CountingBloomFilter extends BloomFilter {
> > +
> > +       private boolean warnOnRemoveFromEmpty;
> > +
> > +       public void setWarnOnRemoveFromEmpty() {
> > +               warnOnRemoveFromEmpty = true;
> > +       }
> > +
> >        /**
> >         * Constructor
> >         *
> > @@ -77,6 +84,9 @@
> >                byte b = filter.get(offset / 4);
> >                byte v = (byte) ((b >>> offset % 4 * 2) & 3);
> >
> > +               if (v == 0 && warnOnRemoveFromEmpty)
> > +                       Logger.error(this, "Unsetting bit but already 
unset - probable double remove, can cause false negatives, is very bad!", new 
Exception("error"));
> > +
> >                if (v == 0 || v == 3)
> >                        return; // overflow / underflow
> >
> >
> > _______________________________________________
> > cvs mailing list
> > cvs at freenetproject.org
> > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> >
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080901/108c0888/attachment.pgp>

Reply via email to