[Mulgara-svn] r1915 - trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa

pag at mulgara.org pag at mulgara.org
Mon Feb 15 19:23:24 UTC 2010


Author: pag
Date: 2010-02-15 11:23:23 -0800 (Mon, 15 Feb 2010)
New Revision: 1915

Modified:
   trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
   trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java
Log:
Applied patch by Benjamin Armintor. Added a mechanism for recycling blocks rather than just reading them

Modified: trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
===================================================================
--- trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2010-02-15 19:21:44 UTC (rev 1914)
+++ trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2010-02-15 19:23:23 UTC (rev 1915)
@@ -274,7 +274,7 @@
           throw new IllegalStateException("compareBlockWithPrefix returned non-comparison");
       }
 
-      Block result = findBlock(prefix, found, initialBlockId, first, lastBlockId, last);
+      Block result = findBlock(prefix, found, initialBlockId, first, lastBlockId, last, null);
       if (result == null) {
         throw new TuplesException("Failed to find block within valid range, is BlockCacheLine sorted?");
       }
@@ -292,8 +292,9 @@
    * INV: 1 <= prefix.length <= width.
    *      if !found then lowBlock < prefix < highBlock
    *      if found then lowBlock < prefix == highBlock
+   * @maintenanceAuthor barmintor
    */
-  private Block findBlock(long[] prefix, boolean found, long lowBound, Block lowBlock, long highBound, Block highBlock) throws TuplesException {
+  private Block findBlock(long[] prefix, boolean found, long lowBound, Block lowBlock, long highBound, Block highBlock, Block recycleBlock) throws TuplesException {
     if (logger.isDebugEnabled()) {
       logger.debug("finding Block with prefix: " + AbstractTuples.toString(prefix) + " found: " + found +
           " lowBound: " + lowBound + " highBound: " + highBound);
@@ -302,18 +303,18 @@
       if (highBound - lowBound <= 1) return highBlock;
 
       long midBound = (int)((lowBound + highBound) / 2);
-      Block midBlock = file.readBlock(midBound);
+      Block midBlock = file.recycleBlock(midBound, recycleBlock);
 
       switch (compareBlockWithPrefix(midBlock, prefix)) {
         case -1:
-          return findBlock(prefix, found, midBound, midBlock, highBound, highBlock);
+          return findBlock(prefix, found, midBound, midBlock, highBound, highBlock, lowBlock);
 
         case 0:
-          return findBlock(prefix, true, lowBound, lowBlock, midBound, midBlock);
+          return findBlock(prefix, true, lowBound, lowBlock, midBound, midBlock, highBlock);
 
         case +1:
           assert !found;
-          return findBlock(prefix, false, lowBound, lowBlock, midBound, midBlock);
+          return findBlock(prefix, false, lowBound, lowBlock, midBound, midBlock, highBlock);
 
         default:
           throw new IllegalStateException("compareBlockWithPrefix returned non-comparison");

Modified: trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java
===================================================================
--- trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java	2010-02-15 19:21:44 UTC (rev 1914)
+++ trunk/src/jar/tuples-hybrid/java/org/mulgara/store/xa/HybridTuples.java	2010-02-15 19:23:23 UTC (rev 1915)
@@ -322,6 +322,7 @@
     
     for (int i = 0; i < heapCache.length; i++) {
       heapCache[i].close(System.identityHashCode(this));
+      heapCache[i] = null;
     }
     heapCache = null;
     currTuple = null;




More information about the Mulgara-svn mailing list