Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DDD6116A8 for ; Tue, 6 May 2014 18:08:08 +0000 (UTC) Received: (qmail 20007 invoked by uid 500); 6 May 2014 17:11:06 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 19981 invoked by uid 500); 6 May 2014 17:11:06 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 19963 invoked by uid 99); 6 May 2014 17:11:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 17:11:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 17:11:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8D77D2388860; Tue, 6 May 2014 17:10:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1592807 - /directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Date: Tue, 06 May 2014 17:10:44 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140506171044.8D77D2388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kayyagari Date: Tue May 6 17:10:44 2014 New Revision: 1592807 URL: http://svn.apache.org/r1592807 Log: fixed building of a new index that was added after adding data to a partition (DIRSERVER-1976) 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=1592807&r1=1592806&r2=1592807&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 Tue May 6 17:10:44 2014 @@ -150,6 +150,34 @@ public class JdbmPartition extends Abstr throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, partitionDir ) ); } + // get all index db files first + File[] allIndexDbFiles = partitionDir.listFiles( DB_FILTER ); + + // get the names of the db files also + List indexDbFileNameList = Arrays.asList( partitionDir.list( DB_FILTER ) ); + + // then add all index objects to a list + List allIndices = new ArrayList(); + + List> indexToBuild = new ArrayList>(); + + for ( Index index : getIndexedAttributes() ) + { + // Index won't be initialized at this time, so lookup AT registry to get the OID + String oid = schemaManager.lookupAttributeTypeRegistry( index.getAttributeId() ).getOid(); + allIndices.add( oid ); + + // take the part after removing .db from the + String name = oid + JDBM_DB_FILE_EXTN; + + // if the name doesn't exist in the list of index DB files + // this is a new index and we need to build it + if ( !indexDbFileNameList.contains( name ) ) + { + indexToBuild.add( index ); + } + } + // Initialize the indexes super.doInit(); @@ -175,42 +203,6 @@ public class JdbmPartition extends Abstr // Create the master table (the table containing all the entries) master = new JdbmMasterTable( recMan, schemaManager ); - // get all index db files first - File[] allIndexDbFiles = partitionDir.listFiles( DB_FILTER ); - - // get the names of the db files also - List indexDbFileNameList = Arrays.asList( partitionDir.list( DB_FILTER ) ); - - // then add all index objects to a list - List allIndices = new ArrayList(); - - for ( Index index : systemIndices.values() ) - { - allIndices.add( index.getAttribute().getOid() ); - } - - List> indexToBuild = new ArrayList>(); - - // 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 index : userIndices.values() ) - { - String indexOid = index.getAttribute().getOid(); - allIndices.add( indexOid ); - - // take the part after removing .db from the - String name = indexOid + JDBM_DB_FILE_EXTN; - - // if the name doesn't exist in the list of index DB files - // this is a new index and we need to build it - if ( !indexDbFileNameList.contains( name ) ) - { - indexToBuild.add( index ); - } - } - if ( indexToBuild.size() > 0 ) { buildUserIndex( indexToBuild ); @@ -363,7 +355,7 @@ public class JdbmPartition extends Abstr { for ( Value value : entryAttr ) { - index.add( value.getValue(), id ); + index.add( value.getNormValue(), id ); } // Adds only those attributes that are indexed