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 2012/04/16 15:22:32 UTC
svn commit: r1326604 -
/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Author: elecharny
Date: Mon Apr 16 13:22:32 2012
New Revision: 1326604
URL: http://svn.apache.org/viewvc?rev=1326604&view=rev
Log:
fixed two issues :
- the indexed AT are now listed usig their OIDs (otherwise, the created index are deleted immediately after having been created). Fixes for DIRSERVER-1712
- the index creation is now faster, as we don't iterate over the indexes, browsing the full MasterTable for each index to create. We now do the opposite : we browse the MasterTable only once and update all the index in one shot. Fixes for DIRSERVER-1711
Modified:
directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1326604&r1=1326603&r2=1326604&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Mon Apr 16 13:22:32 2012
@@ -165,13 +165,15 @@ public class JdbmPartition extends Abstr
allIndices.add( index.getAttribute().getOid() );
}
+ List<Index<?, Entry, Long>> indexToBuild = new ArrayList<Index<?, Entry, Long>>();
+
// this loop is used for two purposes
// one for collecting all user indices
// two for finding a new index to be built
// just to avoid another iteration for determining which is the new index
for ( Index<?, Entry, Long> index : userIndices.values() )
{
- allIndices.add( index.getAttributeId() );
+ allIndices.add( index.getAttribute().getOid() );
// take the part after removing .db from the
String name = index.getAttributeId() + JDBM_DB_FILE_EXTN;
@@ -180,10 +182,15 @@ public class JdbmPartition extends Abstr
// this is a new index and we need to build it
if ( !indexDbFileNameList.contains( name ) )
{
- buildUserIndex( index );
+ indexToBuild.add( index );
}
}
+ if ( indexToBuild.size() > 0 )
+ {
+ buildUserIndex( indexToBuild );
+ }
+
deleteUnusedIndexFiles( allIndices, allIndexDbFiles );
// We are done !
@@ -241,40 +248,43 @@ public class JdbmPartition extends Abstr
/**
- * builds a user defined index on a attribute by browsing all the entries present in master db
+ * builds user defined indexes on a attributes by browsing all the entries present in master db
*
- * @param userIdx then user defined index
+ * @param userIndexes then user defined indexes to create
* @throws Exception in case of any problems while building the index
*/
- private void buildUserIndex( Index userIdx ) throws Exception
+ private void buildUserIndex( List<Index<?, Entry, Long>> userIndexes ) throws Exception
{
- AttributeType atType = userIdx.getAttribute();
-
- LOG.info( "building the index for attribute type {}", atType );
-
Cursor<Tuple<Long, Entry>> cursor = master.cursor();
cursor.beforeFirst();
- String attributeOid = userIdx.getAttribute().getOid();
-
while ( cursor.next() )
{
- Tuple<Long, Entry> tuple = cursor.get();
-
- Long id = tuple.getKey();
- Entry entry = tuple.getValue();
-
- Attribute entryAttr = entry.get( atType );
-
- if ( entryAttr != null )
+ for ( Index index : userIndexes )
{
- for ( Value<?> value : entryAttr )
+ AttributeType atType = index.getAttribute();
+
+ String attributeOid = index.getAttribute().getOid();
+
+ LOG.info( "building the index for attribute type {}", atType );
+
+ Tuple<Long, Entry> tuple = cursor.get();
+
+ Long id = tuple.getKey();
+ Entry entry = tuple.getValue();
+
+ Attribute entryAttr = entry.get( atType );
+
+ if ( entryAttr != null )
{
- userIdx.add( value.getValue(), id );
+ for ( Value<?> value : entryAttr )
+ {
+ index.add( value.getValue(), id );
+ }
+
+ // Adds only those attributes that are indexed
+ presenceIdx.add( attributeOid, id );
}
-
- // Adds only those attributes that are indexed
- presenceIdx.add( attributeOid, id );
}
}