On Wednesday 20 August 2008 09:20, j16sdiz at freenetproject.org wrote:
> Author: j16sdiz
> Date: 2008-08-20 08:20:43 +0000 (Wed, 20 Aug 2008)
> New Revision: 22047
>
> Modified:
> trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
> trunk/freenet/src/freenet/store/FreenetStore.java
> trunk/freenet/src/freenet/store/RAMFreenetStore.java
> Log:
> bug 2516: probablyInStore() for BerkeleyDBFreenetStore/RAMFreenetStore
I dunno whether we should even check the database in BDBFS ... Maybe we should
just always return true. The big gain is if we have a bloom filter or an
index in RAM. Even if it's a memory mapped bloom filter, chances are it'll be
in RAM; I dunno whether this is true of BDBFS.
I'm uncertain anyway: maybe you're right? I do think probablyNotInStore()
should try to avoid disk I/O so it can be used quickly on any thread.
>
> Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
> ===================================================================
> --- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
> 2008-08-20
00:24:11 UTC (rev 22046)
> +++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
> 2008-08-20
08:20:43 UTC (rev 22047)
> @@ -37,7 +37,6 @@
>
> import freenet.crypt.RandomSource;
> import freenet.keys.KeyVerifyException;
> -import freenet.node.NodeInitException;
> import freenet.node.SemiOrderedShutdownHook;
> import freenet.support.Fields;
> import freenet.support.HexUtil;
> @@ -2303,4 +2302,27 @@
> envConfig.setConfigParam("je.env.backgroundSleepInterval", "10000" /*
microseconds */); // 10ms
> return envConfig;
> }
> +
> + public boolean probablyInStore(byte[] routingKey) {
> + DatabaseEntry routingkeyDBE = new DatabaseEntry(routingKey);
> + DatabaseEntry blockDBE = new DatabaseEntry();
> + synchronized (this) {
> + if (closed)
> + return false;
> + }
> +
> + Cursor c = null;
> + try {
> + return keysDB.get(null, routingkeyDBE, blockDBE,
LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS;
> + } catch (DatabaseException e) {
> + return false;
> + } finally {
> + try {
> + if (c != null)
> + c.close();
> + } catch (DatabaseException e) {
> + // ignore
> + }
> + }
> + }
> }
>
> Modified: trunk/freenet/src/freenet/store/FreenetStore.java
> ===================================================================
> --- trunk/freenet/src/freenet/store/FreenetStore.java 2008-08-20 00:24:11
UTC (rev 22046)
> +++ trunk/freenet/src/freenet/store/FreenetStore.java 2008-08-20 08:20:43
UTC (rev 22047)
> @@ -53,4 +53,12 @@
> public long writes();
>
> public long keyCount();
> +
> + /**
> + * Check if a routing key probably
> + *
> + * @param routingkey
> + * @return <code>false</code> <b>only</b> if the key does not exist in
store.
> + */
> + public boolean probablyInStore(byte[] routingKey);
> }
>
> Modified: trunk/freenet/src/freenet/store/RAMFreenetStore.java
> ===================================================================
> --- trunk/freenet/src/freenet/store/RAMFreenetStore.java 2008-08-20
> 00:24:11
UTC (rev 22046)
> +++ trunk/freenet/src/freenet/store/RAMFreenetStore.java 2008-08-20
> 08:20:43
UTC (rev 22047)
> @@ -122,4 +122,8 @@
> return writes;
> }
>
> + public boolean probablyInStore(byte[] routingKey) {
> + ByteArrayWrapper key = new ByteArrayWrapper(routingKey);
> + return blocksByRoutingKey.get(key) != null;
> + }
> }
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080823/27587c30/attachment.pgp>