directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1538511 - in /directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree: managed/BTree.java managed/BTreeFactory.java memory/BTree.java memory/BTreeFactory.java
Date Mon, 04 Nov 2013 06:17:17 GMT
Author: elecharny
Date: Mon Nov  4 06:17:17 2013
New Revision: 1538511

URL: http://svn.apache.org/r1538511
Log:
Removed the useless comparator field : it's deduced from the keySerializer

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/BTreeFactory.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.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=1538511&r1=1538510&r2=1538511&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
Mon Nov  4 06:17:17 2013
@@ -73,9 +73,6 @@ public class BTree<K, V> implements Clos
     /** The default journal file suffix */
     public static final String JOURNAL_SUFFIX = ".log";
 
-    /** Comparator used to index entries. */
-    private Comparator<K> comparator;
-
     /** The current rootPage */
     protected volatile Page<K, V> rootPage;
 
@@ -232,13 +229,12 @@ public class BTree<K, V> implements Clos
         valueSerializer = configuration.getValueSerializer();
         btreeHeader.setValueSerializerFQCN( valueSerializer.getClass().getName() );
 
-        comparator = keySerializer.getComparator();
         readTimeOut = configuration.getReadTimeOut();
         writeBufferSize = configuration.getWriteBufferSize();
         btreeHeader.setAllowDuplicates( configuration.isAllowDuplicates() );
         cacheSize = configuration.getCacheSize();
 
-        if ( comparator == null )
+        if ( keySerializer.getComparator() == null )
         {
             throw new IllegalArgumentException( "Comparator should not be null" );
         }
@@ -346,8 +342,6 @@ public class BTree<K, V> implements Clos
 
         btreeHeader.setValueSerializerFQCN( valueSerializer.getClass().getName() );
 
-        comparator = keySerializer.getComparator();
-
         btreeHeader.setAllowDuplicates( allowDuplicates );
 
         // Create the first root page, with revision 0L. It will be empty
@@ -1075,16 +1069,7 @@ public class BTree<K, V> implements Clos
      */
     public Comparator<K> getComparator()
     {
-        return comparator;
-    }
-
-
-    /**
-     * @param comparator the comparator to set
-     */
-    public void setComparator( Comparator<K> comparator )
-    {
-        this.comparator = comparator;
+        return keySerializer.getComparator();
     }
 
 
@@ -1094,7 +1079,6 @@ public class BTree<K, V> implements Clos
     public void setKeySerializer( ElementSerializer<K> keySerializer )
     {
         this.keySerializer = keySerializer;
-        this.comparator = keySerializer.getComparator();
         btreeHeader.setKeySerializerFQCN( keySerializer.getClass().getName() );
     }
 
@@ -1362,13 +1346,13 @@ public class BTree<K, V> implements Clos
 
         sb.append( ", comparator:" );
 
-        if ( comparator == null )
+        if ( keySerializer.getComparator() == null )
         {
             sb.append( "null" );
         }
         else
         {
-            sb.append( comparator.getClass().getSimpleName() );
+            sb.append( keySerializer.getComparator().getClass().getSimpleName() );
         }
 
         sb.append( ", DuplicatesAllowed: " ).append( btreeHeader.isAllowDuplicates() );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java?rev=1538511&r1=1538510&r2=1538511&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java
Mon Nov  4 06:17:17 2013
@@ -166,8 +166,6 @@ public class BTreeFactory
         @SuppressWarnings("unchecked")
         ElementSerializer<K> instance = ( ElementSerializer<K> ) keySerializer.newInstance();
         btree.setKeySerializer( instance );
-
-        btree.setComparator( instance.getComparator() );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java?rev=1538511&r1=1538510&r2=1538511&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
Mon Nov  4 06:17:17 2013
@@ -83,9 +83,6 @@ public class BTree<K, V> implements Clos
     /** The default journal file suffix */
     public static final String JOURNAL_SUFFIX = ".log";
 
-    /** Comparator used to index entries. */
-    private Comparator<K> comparator;
-
     /** The current rootPage */
     protected volatile Page<K, V> rootPage;
 
@@ -256,14 +253,13 @@ public class BTree<K, V> implements Clos
         valueSerializer = configuration.getValueSerializer();
         btreeHeader.setValueSerializerFQCN( valueSerializer.getClass().getName() );
 
-        comparator = keySerializer.getComparator();
         readTimeOut = configuration.getReadTimeOut();
         writeBufferSize = configuration.getWriteBufferSize();
         btreeHeader.setAllowDuplicates( configuration.isAllowDuplicates() );
         type = configuration.getType();
         cacheSize = configuration.getCacheSize();
 
-        if ( comparator == null )
+        if ( keySerializer.getComparator() == null )
         {
             throw new IllegalArgumentException( "Comparator should not be null" );
         }
@@ -376,8 +372,6 @@ public class BTree<K, V> implements Clos
 
         btreeHeader.setValueSerializerFQCN( valueSerializer.getClass().getName() );
 
-        comparator = keySerializer.getComparator();
-
         btreeHeader.setAllowDuplicates( allowDuplicates );
 
         // Create the first root page, with revision 0L. It will be empty
@@ -418,7 +412,7 @@ public class BTree<K, V> implements Clos
         readTransactions = new ConcurrentLinkedQueue<Transaction<K, V>>();
 
         // We will extract the Type to use for keys, using the comparator for that
-        Class<?> comparatorClass = comparator.getClass();
+        Class<?> comparatorClass = keySerializer.getComparator().getClass();
         Type[] types = comparatorClass.getGenericInterfaces();
 
         if ( types[0] instanceof Class )
@@ -1121,16 +1115,7 @@ public class BTree<K, V> implements Clos
      */
     public Comparator<K> getComparator()
     {
-        return comparator;
-    }
-
-
-    /**
-     * @param comparator the comparator to set
-     */
-    public void setComparator( Comparator<K> comparator )
-    {
-        this.comparator = comparator;
+        return keySerializer.getComparator();
     }
 
 
@@ -1140,7 +1125,6 @@ public class BTree<K, V> implements Clos
     public void setKeySerializer( ElementSerializer<K> keySerializer )
     {
         this.keySerializer = keySerializer;
-        this.comparator = keySerializer.getComparator();
         btreeHeader.setKeySerializerFQCN( keySerializer.getClass().getName() );
     }
 
@@ -1702,13 +1686,13 @@ public class BTree<K, V> implements Clos
 
         sb.append( ", comparator:" );
 
-        if ( comparator == null )
+        if ( keySerializer.getComparator() == null )
         {
             sb.append( "null" );
         }
         else
         {
-            sb.append( comparator.getClass().getSimpleName() );
+            sb.append( keySerializer.getComparator().getClass().getSimpleName() );
         }
 
         sb.append( ", DuplicatesAllowed: " ).append( btreeHeader.isAllowDuplicates() );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java?rev=1538511&r1=1538510&r2=1538511&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
Mon Nov  4 06:17:17 2013
@@ -166,8 +166,6 @@ public class BTreeFactory
         @SuppressWarnings("unchecked")
         ElementSerializer<K> instance = ( ElementSerializer<K> ) keySerializer.newInstance();
         btree.setKeySerializer( instance );
-
-        btree.setComparator( instance.getComparator() );
     }
 
 



Mime
View raw message