directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1529110 - in /directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed: BTree.java CacheHolder.java Node.java PageHolder.java RecordManager.java
Date Fri, 04 Oct 2013 09:26:31 GMT
Author: elecharny
Date: Fri Oct  4 09:26:30 2013
New Revision: 1529110

URL: http://svn.apache.org/r1529110
Log:
o Renamed the CacheHolder to PageHolder, to reflect the data it stores
o Simplified the generics in use for this class

Added:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java
      - copied, changed from r1527458, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/CacheHolder.java
Removed:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/CacheHolder.java
Modified:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java?rev=1529110&r1=1529109&r2=1529110&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
Fri Oct  4 09:26:30 2013
@@ -727,12 +727,12 @@ public class BTree<K, V> implements Clos
                     revision );
 
                 // Store the offset on disk in the page in memory
-                ( ( AbstractPage<K, V> ) modifiedPage ).setOffset( ( ( CacheHolder<Page<K,
V>, K, V> ) holder )
+                ( ( AbstractPage<K, V> ) modifiedPage ).setOffset( ( ( PageHolder<K,
V> ) holder )
                     .getOffset() );
 
                 // Store the last offset on disk in the page in memory
                 ( ( AbstractPage<K, V> ) modifiedPage )
-                    .setLastOffset( ( ( CacheHolder<Page<K, V>, K, V> ) holder
)
+                    .setLastOffset( ( ( PageHolder<K, V> ) holder )
                         .getLastOffset() );
 
                 // This is a new root
@@ -1278,7 +1278,7 @@ public class BTree<K, V> implements Clos
      */
     /* no qualifier */ElementHolder<Page<K, V>, K, V> createPageHolder( Page<K,
V> value )
     {
-        return new CacheHolder<Page<K, V>, K, V>( this, value,
+        return new PageHolder<K, V>( this, value,
             value.getOffset(), value.getLastOffset() );
     }
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java?rev=1529110&r1=1529109&r2=1529110&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
Fri Oct  4 09:26:30 2013
@@ -81,7 +81,7 @@ import org.apache.directory.mavibot.btre
         super( btree, revision, 1 );
 
         // Create the children array, and store the left and right children
-        children = ( CacheHolder<Page<K, V>, K, V>[] ) Array.newInstance( CacheHolder.class,
+        children = ( PageHolder<K, V>[] ) Array.newInstance( PageHolder.class,
             btree.getPageSize() + 1 );
 
         children[0] = btree.createPageHolder( leftPage );
@@ -115,7 +115,7 @@ import org.apache.directory.mavibot.btre
         super( btree, revision, 1 );
 
         // Create the children array, and store the left and right children
-        children = ( CacheHolder<Page<K, V>, K, V>[] ) Array.newInstance( CacheHolder.class,
+        children = ( PageHolder<K, V>[] ) Array.newInstance( PageHolder.class,
             btree.getPageSize() + 1 );
 
         children[0] = leftPage;

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java
(from r1527458, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/CacheHolder.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/CacheHolder.java&r1=1527458&r2=1529110&rev=1529110&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/CacheHolder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java
Fri Oct  4 09:26:30 2013
@@ -38,7 +38,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CacheHolder<E, K, V> implements ElementHolder<E, K, V>
+public class PageHolder<K, V> implements ElementHolder<Page<K, V>, K, V>
 {
     /** The BTree */
     private BTree<K, V> btree;
@@ -56,7 +56,7 @@ public class CacheHolder<E, K, V> implem
      * @param offset The offset in disk for this value
      * @param element The element to store into a SoftReference
      */
-    public CacheHolder( BTree<K, V> btree, Page<K, V> element, long offset, long
lastOffset )
+    public PageHolder( BTree<K, V> btree, Page<K, V> element, long offset, long
lastOffset )
     {
         this.btree = btree;
         this.offset = offset;
@@ -78,7 +78,7 @@ public class CacheHolder<E, K, V> implem
      * @throws EndOfFileExceededException 
      */
     @Override
-    public E getValue( BTree<K, V> btree ) throws EndOfFileExceededException, IOException
+    public Page<K, V> getValue( BTree<K, V> btree ) throws EndOfFileExceededException,
IOException
     {
         Element element = btree.getCache().get( offset );
 
@@ -90,15 +90,15 @@ public class CacheHolder<E, K, V> implem
 
             btree.getCache().put( new Element( offset, page ) );
 
-            return ( E ) page;
+            return page;
         }
 
-        V value = ( V ) element.getObjectValue();
+        Page<K, V> page = ( Page<K, V> ) element.getObjectValue();
 
-        if ( value == null )
+        if ( page == null )
         {
             // We have to fetch the element from disk, using the offset now
-            Page<K, V> page = fetchElement( btree );
+            page = fetchElement( btree );
 
             if ( page instanceof Page<?, ?> )
             {
@@ -107,15 +107,9 @@ public class CacheHolder<E, K, V> implem
             }
 
             btree.getCache().put( new Element( offset, page ) );
-
-            element = btree.getCache().get( offset );
-
-            return ( E ) page;
-        }
-        else
-        {
-            return ( E ) value;
         }
+
+        return page;
     }
 
 
@@ -160,12 +154,12 @@ public class CacheHolder<E, K, V> implem
 
         try
         {
-            E element = getValue( btree );
+            Page<K, V> page = getValue( btree );
 
-            if ( element != null )
+            if ( page != null )
             {
                 sb.append( btree.getName() ).append( "[" ).append( offset ).append( ", "
).append( lastOffset )
-                    .append( "]:" ).append( element );
+                    .append( "]:" ).append( page );
             }
             else
             {

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java?rev=1529110&r1=1529109&r2=1529110&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java
Fri Oct  4 09:26:30 2013
@@ -652,7 +652,7 @@ public class RecordManager
                 long offset = OFFSET_SERIALIZER.deserialize( byteBuffer );
                 long lastOffset = OFFSET_SERIALIZER.deserialize( byteBuffer );
 
-                ElementHolder valueHolder = new CacheHolder( btree, null, offset, lastOffset
);
+                ElementHolder valueHolder = new PageHolder( btree, null, offset, lastOffset
);
                 ( ( Node<K, V> ) page ).setValue( i, valueHolder );
 
                 K key = btree.getKeySerializer().deserialize( byteBuffer );
@@ -663,7 +663,7 @@ public class RecordManager
             long offset = OFFSET_SERIALIZER.deserialize( byteBuffer );
             long lastOffset = OFFSET_SERIALIZER.deserialize( byteBuffer );
 
-            ElementHolder valueHolder = new CacheHolder( btree, null, offset, lastOffset
);
+            ElementHolder valueHolder = new PageHolder( btree, null, offset, lastOffset );
             ( ( Node<K, V> ) page ).setValue( nodeNbElems, valueHolder );
         }
 
@@ -1766,7 +1766,7 @@ public class RecordManager
         // Build the resulting reference
         long offset = pageIos[0].getOffset();
         long lastOffset = pageIos[pageIos.length - 1].getOffset();
-        ElementHolder<Page<K, V>, K, V> valueHolder = new CacheHolder<Page<K,
V>, K, V>( btree, newPage, offset,
+        ElementHolder<Page<K, V>, K, V> valueHolder = new PageHolder<K, V>(
btree, newPage, offset,
             lastOffset );
 
         if ( LOG_CHECK.isDebugEnabled() )



Mime
View raw message