directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1660631 - /directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
Date Wed, 18 Feb 2015 13:34:02 GMT
Author: elecharny
Date: Wed Feb 18 13:34:02 2015
New Revision: 1660631

URL: http://svn.apache.org/r1660631
Log:
Fixed the way we count elements in the bulk loader : when two tuples have the same key, they
count for one single element.

Modified:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java?rev=1660631&r1=1660630&r2=1660631&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
Wed Feb 18 13:34:02 2015
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -149,18 +150,25 @@ public class BulkLoader<K, V>
         int nbIteration = 0;
         int nbElems = 0;
         boolean inMemory = true;
+        Set<K> keys = new HashSet<K>();
 
         while ( true )
         {
             nbIteration++;
             tuples.clear();
+            keys.clear();
 
             // Read up to chukSize elements
             while ( iterator.hasNext() && ( nbRead < chunkSize ) )
             {
                 Tuple<K, V> tuple = iterator.next();
                 tuples.add( tuple );
-                nbRead++;
+
+                if ( !keys.contains( tuple.getKey() ) )
+                {
+                    keys.add( tuple.getKey() );
+                    nbRead++;
+                }
             }
 
             if ( nbRead < chunkSize )



Mime
View raw message