|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.util.DecayingBloomFilter
public class DecayingBloomFilter
Series of bloom filters which decay over time, allowing their continual use for time sensitive data. This has a fixed size (per period, using two periods overall), allowing this to pump through hundreds of entries per second with virtually no false positive rate. Down the line, this may be refactored to allow tighter control of the size necessary for the contained bloom filters. See main() for an analysis of false positive rate. See BloomFilterIVValidator for instantiation parameters. See DecayingHashSet for a smaller and simpler version.
BloomFilterIVValidator
,
DecayingHashSet
Field Summary | |
---|---|
protected I2PAppContext |
_context
|
protected long |
_currentDuplicates
|
protected SimpleTimer2.TimedEvent |
_decayEvent
|
protected int |
_durationMs
|
protected int |
_entryBytes
|
protected boolean |
_keepDecaying
|
protected Log |
_log
|
protected String |
_name
just for logging |
protected ReentrantReadWriteLock |
_reorganizeLock
synchronize against this lock when switching double buffers |
Constructor Summary | |
---|---|
|
DecayingBloomFilter(I2PAppContext context,
int durationMs,
int entryBytes)
Create a bloom filter that will decay its entries over time. |
|
DecayingBloomFilter(I2PAppContext context,
int durationMs,
int entryBytes,
String name)
|
|
DecayingBloomFilter(I2PAppContext context,
int durationMs,
int entryBytes,
String name,
int m)
|
protected |
DecayingBloomFilter(int durationMs,
int entryBytes,
String name,
I2PAppContext context)
only for extension by DHS |
Method Summary | |
---|---|
boolean |
add(byte[] entry)
|
boolean |
add(byte[] entry,
int off,
int len)
|
boolean |
add(long entry)
|
void |
clear()
|
protected void |
decay()
|
long |
getCurrentDuplicateCount()
|
double |
getFalsePositiveRate()
unsynchronized, only used for logging elsewhere |
int |
getInsertedCount()
unsynchronized but only used for logging elsewhere |
protected void |
getReadLock()
|
protected boolean |
getWriteLock()
|
boolean |
isKnown(long entry)
|
protected void |
releaseReadLock()
|
protected void |
releaseWriteLock()
|
void |
stopDecaying()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final I2PAppContext _context
protected final Log _log
protected final int _durationMs
protected final int _entryBytes
protected long _currentDuplicates
protected volatile boolean _keepDecaying
protected final SimpleTimer2.TimedEvent _decayEvent
protected final String _name
protected final ReentrantReadWriteLock _reorganizeLock
Constructor Detail |
---|
protected DecayingBloomFilter(int durationMs, int entryBytes, String name, I2PAppContext context)
public DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes)
durationMs
- entries last for at least this long, but no more than twice this longentryBytes
- how large are the entries to be added? if this is less than 32 bytes,
the entries added will be expanded by concatenating their XORing
against with sufficient random values.public DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes, String name)
name
- just for logging / debugging / statspublic DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes, String name, int m)
m
- filter size exponent, max is 29Method Detail |
---|
public long getCurrentDuplicateCount()
public int getInsertedCount()
public double getFalsePositiveRate()
public boolean add(byte[] entry)
public boolean add(byte[] entry, int off, int len)
public boolean add(long entry)
public boolean isKnown(long entry)
public void clear()
public void stopDecaying()
protected void decay()
protected void getReadLock()
protected void releaseReadLock()
protected boolean getWriteLock()
protected void releaseWriteLock()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |