You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/10/31 13:51:18 UTC

svn commit: r1029326 - in /directory: apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ shared/trunk/ldap/src/main/java/org/a...

Author: elecharny
Date: Sun Oct 31 12:51:17 2010
New Revision: 1029326

URL: http://svn.apache.org/viewvc?rev=1029326&view=rev
Log:
o Added an Abstract class for IndexEntry
o Fixed some typoes

Added:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java
Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ReverseIndexEntry.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/cursor/Tuple.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java Sun Oct 31 12:51:17 2010
@@ -60,6 +60,7 @@ public class IndexCursorAdaptor<K, O, ID
     public IndexCursorAdaptor( Cursor<Tuple> wrappedCursor, boolean forwardIndex )
     {
         this.wrappedCursor = wrappedCursor;
+        
         if ( forwardIndex )
         {
             forwardEntry = new ForwardIndexEntry<K, O, ID>();

Added: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java?rev=1029326&view=auto
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java (added)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java Sun Oct 31 12:51:17 2010
@@ -0,0 +1,113 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.xdbm;
+
+import org.apache.directory.shared.ldap.cursor.Tuple;
+
+
+/**
+ * Abstract class managing the object for index entries.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @param <V> The value stored in the Tuple, associated key for the object
+ * @param <ID> The ID of the object
+ * @param <O> The associated object
+ */
+public abstract class AbstractIndexEntry<V, O, ID> implements IndexEntry<V, O, ID>
+{
+    /** The referenced object if loaded from the store */
+    private O object;
+
+    /**
+     * Creates an instance of AbstractIndexEntry
+     * 
+     * @param object The interned object
+     */
+    protected AbstractIndexEntry( O object )
+    {
+        this.object = object;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public abstract V getValue();
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public abstract void setValue( V value );
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public abstract ID getId();
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public abstract void setId( ID id );
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public O getObject()
+    {
+        return object;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public abstract Tuple<?, ?> getTuple();
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setObject( O object )
+    {
+        this.object = object;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void clear()
+    {
+        object = null;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void copy( IndexEntry<V, O, ID> entry )
+    {
+        object = entry.getObject();
+    }
+}

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java Sun Oct 31 12:51:17 2010
@@ -24,93 +24,114 @@ import org.apache.directory.shared.ldap.
 
 /**
  * An index id value pair based on a Tuple which can optionally reference the
- * indexed obj if one has already been loaded.
+ * indexed object if one has already been loaded.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @param <V> The value stored in the Tuple, associated key for the object
+ * @param <ID> The ID of the object
+ * @param <O> The associated object
  */
-public class ForwardIndexEntry<V, O, ID> implements IndexEntry<V, O, ID>
+public class ForwardIndexEntry<V, O, ID> extends AbstractIndexEntry<V, O, ID>
 {
     /** The underlying Tuple */
     private final Tuple<V, ID> tuple = new Tuple<V, ID>();
 
-    /** The referenced obj if loaded from the store */
-    private O obj;
-
-
+    
+    /**
+     * Creates a ForwardIndexEntry instance
+     */
+    public ForwardIndexEntry()
+    {
+        super( null );
+    }
+    
+    
     /**
      * Sets the key value tuple represented by this ForwardIndexEntry optionally
      * setting the obj associated with the id if one was loaded from the
      * master table.
      *
      * @param tuple the tuple for the ForwardIndexEntry
-     * @param entry the resusitated obj if any
+     * @param object the resuscitated object if any
      */
-    public void setTuple( Tuple<V, ID> tuple, O entry )
+    public void setTuple( Tuple<V, ID> tuple, O object )
     {
+        setObject( object );
         this.tuple.setKey( tuple.getKey() );
         this.tuple.setValue( tuple.getValue() );
-        this.obj = entry;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public ID getId()
     {
         return tuple.getValue();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public V getValue()
     {
         return tuple.getKey();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setId( ID id )
     {
         tuple.setValue( id );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setValue( V value )
     {
         tuple.setKey( value );
     }
 
 
-    public O getObject()
-    {
-        return obj;
-    }
-
-
-    public void setObject( O obj )
-    {
-        this.obj = obj;
-    }
-
-
+    /**
+     * {@inheritDoc}
+     */
     public Tuple<V, ID> getTuple()
     {
         return tuple;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void clear()
     {
-        obj = null;
+        super.clear();
         tuple.setKey( null );
         tuple.setValue( null );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void copy( IndexEntry<V, O, ID> entry )
     {
-        this.obj = entry.getObject();
+        super.copy( entry );
         tuple.setKey( entry.getValue() );
         tuple.setValue( entry.getId() );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString()
     {
         StringBuilder buf = new StringBuilder();
@@ -119,6 +140,7 @@ public class ForwardIndexEntry<V, O, ID>
         buf.append( ", " );
         buf.append( tuple.getValue() );
         buf.append( " ]" );
+        
         return buf.toString();
     }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java Sun Oct 31 12:51:17 2010
@@ -144,7 +144,7 @@ public interface Index<K, O, ID>
 
 
     /**
-     * Gets the scan count for the occurence of a specific attribute value 
+     * Gets the scan count for the occurrence of a specific attribute value 
      * within the index.
      *
      * @param attrVal the value of the attribute to get a scan count for

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java Sun Oct 31 12:51:17 2010
@@ -23,9 +23,14 @@ import org.apache.directory.shared.ldap.
 
 
 /**
- * Interface for index entries.
+ * Interface for index entries. An index entry associate an Entry object with 
+ * a value (the key) and the Object ID in the table where it's stored. The Object
+ * may be present in this instance once we read it from the tabe.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @param <V> The value stored in the Tuple, associated key for the object
+ * @param <ID> The ID of the object
+ * @param <O> The associated object
  */
 public interface IndexEntry<V, O, ID>
 {
@@ -46,23 +51,23 @@ public interface IndexEntry<V, O, ID>
 
 
     /**
-     * Gets the id of the object indexed.
+     * Gets the id of the indexed object.
      *
-     * @return the id of the object indexed
+     * @return the id of the indexed object
      */
     ID getId();
 
 
     /**
-     * Sets the id of the object indexed.
+     * Sets the id of the indexed.object
      *
-     * @param id the id of the object indexed
+     * @param id the id of the indexed object
      */
     void setId( ID id );
 
 
     /**
-     * Gets the object indexed if resusitated.
+     * Gets the object indexed if resuscitated.
      *
      * @return the object indexed
      */
@@ -78,9 +83,9 @@ public interface IndexEntry<V, O, ID>
 
 
     /**
-     * Sets the object indexed.
+     * Sets the indexed object.
      *
-     * @param obj the object indexed
+     * @param obj the indexed object
      */
     void setObject( O obj );
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ReverseIndexEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ReverseIndexEntry.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ReverseIndexEntry.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ReverseIndexEntry.java Sun Oct 31 12:51:17 2010
@@ -27,15 +27,25 @@ import org.apache.directory.shared.ldap.
  * if one has already been loaded.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @param <V> The value stored in the Tuple, associated key for the object
+ * @param <ID> The ID of the object
+ * @param <O> The associated object
  */
-public class ReverseIndexEntry<V, O, ID> implements IndexEntry<V, O, ID>
+public class ReverseIndexEntry<V, O, ID> extends AbstractIndexEntry<V, O, ID>
 {
     /** The underlying Tuple */
     private final Tuple<ID, V> tuple = new Tuple<ID, V>();
 
-    /** The indexed object if loaded from the store */
-    private O obj;
 
+    /**
+     * Creates a ForwardIndexEntry instance
+     */
+    public ReverseIndexEntry()
+    {
+        super( null );
+    }
+    
+    
 
     /**
      * Sets the Tuple value represented by this ReverseIndexEntry optionally
@@ -45,72 +55,84 @@ public class ReverseIndexEntry<V, O, ID>
      * @param tuple the tuple for the ReverseIndexEntry
      * @param obj the resusitated object that is indexed if any
      */
-    public void setTuple( Tuple<ID, V> tuple, O obj )
+    public void setTuple( Tuple<ID, V> tuple, O object )
     {
+        setObject( object );
         this.tuple.setKey( tuple.getKey() );
         this.tuple.setValue( tuple.getValue() );
-        this.obj = obj;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public ID getId()
     {
         return tuple.getKey();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public V getValue()
     {
         return tuple.getValue();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setId( ID id )
     {
         tuple.setKey( id );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setValue( V key )
     {
         tuple.setValue( key );
     }
 
 
-    public O getObject()
-    {
-        return obj;
-    }
-
-
-    public void setObject( O obj )
-    {
-        this.obj = obj;
-    }
-
-
+    /**
+     * {@inheritDoc}
+     */
     public Tuple<ID, V> getTuple()
     {
         return tuple;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void clear()
     {
-        obj = null;
+        super.clear();
         tuple.setKey( null );
         tuple.setValue( null );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void copy( IndexEntry<V, O, ID> entry )
     {
-        this.obj = entry.getObject();
+        setObject( entry.getObject() );
         tuple.setKey( entry.getId() );
         tuple.setValue( entry.getValue() );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString()
     {
         StringBuilder buf = new StringBuilder();
@@ -119,6 +141,7 @@ public class ReverseIndexEntry<V, O, ID>
         buf.append( ", " );
         buf.append( tuple.getKey() );
         buf.append( " ]" );
+
         return buf.toString();
     }
 }
\ No newline at end of file

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/cursor/Tuple.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/cursor/Tuple.java?rev=1029326&r1=1029325&r2=1029326&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/cursor/Tuple.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/cursor/Tuple.java Sun Oct 31 12:51:17 2010
@@ -195,7 +195,7 @@ public class Tuple<K, V>
             return false;
         }
 
-        Tuple<?, ?> other = ( org.apache.directory.shared.ldap.cursor.Tuple<?, ?> ) obj;
+        Tuple<?, ?> other = ( Tuple<?, ?> ) obj;
 
         if ( key == null )
         {