Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 50779 invoked from network); 29 Apr 2010 21:22:10 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Apr 2010 21:22:10 -0000 Received: (qmail 71929 invoked by uid 500); 29 Apr 2010 21:22:09 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 71883 invoked by uid 500); 29 Apr 2010 21:22:09 -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 71876 invoked by uid 99); 29 Apr 2010 21:22:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Apr 2010 21:22:09 +0000 X-ASF-Spam-Status: No, hits=-1275.8 required=10.0 tests=ALL_TRUSTED,AWL 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; Thu, 29 Apr 2010 21:22:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0FE8223889C5; Thu, 29 Apr 2010 21:21:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r939483 - in /directory/apacheds/trunk: avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ jdbm-store/src/main/java/org/apache/directory/se... Date: Thu, 29 Apr 2010 21:21:16 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100429212117.0FE8223889C5@eris.apache.org> Author: seelmann Date: Thu Apr 29 21:21:14 2010 New Revision: 939483 URL: http://svn.apache.org/viewvc?rev=939483&view=rev Log: o added ParentIdAndRdn class and use it for the RDN index o removed parentId from RDN class o removed unused getParentId(String) method from Store interface o removed unused getParentId(Sting|ID) method from BTreePartition Added: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdnComparator.java Removed: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/InternalRdnComparator.java Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java (original) +++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java Thu Apr 29 21:21:14 2010 @@ -333,16 +333,6 @@ public class AvlStore extends Abstrac /** * {@inheritDoc} */ - public Long getParentId( String dn ) throws Exception - { - Long childId = ndnIdx.forwardLookup( dn ); - return oneLevelIdx.reverseLookup( childId ); - } - - - /** - * {@inheritDoc} - */ public Long getParentId( Long childId ) throws Exception { return oneLevelIdx.reverseLookup( childId ); Modified: directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java (original) +++ directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java Thu Apr 29 21:21:14 2010 @@ -393,7 +393,7 @@ public class AvlStoreTest assertEquals( dn.getName(), store.getEntryUpdn( 1L ) ); // note that the suffix entry returns 0 for it's parent which does not exist - assertEquals( 0L, ( long ) store.getParentId( dn.getNormName() ) ); + assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) ); assertNull( store.getParentId( 0L ) ); // should NOW be allowed Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java Thu Apr 29 21:21:14 2010 @@ -32,10 +32,11 @@ import jdbm.recman.CacheRecordManager; import org.apache.directory.server.core.partition.impl.btree.LongComparator; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.xdbm.ParentIdAndRdn; +import org.apache.directory.server.xdbm.ParentIdAndRdnComparator; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.MatchingRule; import org.apache.directory.shared.ldap.schema.SchemaManager; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.util.SynchronizedLRUMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,11 +48,11 @@ import org.slf4j.LoggerFactory; * @author Apache Directory Project * @version $Rev$, $Date$ */ -public class JdbmRdnIndex extends JdbmIndex +public class JdbmRdnIndex extends JdbmIndex, Long> { /** A logger for this class */ - private static final Logger LOG = LoggerFactory.getLogger( JdbmRdnIndex.class.getSimpleName() ); + private static final Logger LOG = LoggerFactory.getLogger( JdbmRdnIndex.class ); public JdbmRdnIndex() @@ -120,18 +121,18 @@ public class JdbmRdnIndex extends throw new IOException( I18n.err( I18n.ERR_574, attribute.getName() ) ); } - SerializableComparator comp = new InternalRdnComparator( mr.getOid() ); + ParentIdAndRdnComparator comp = new ParentIdAndRdnComparator( mr.getOid() ); LongComparator.INSTANCE.setSchemaManager( schemaManager ); - forward = new JdbmTable( schemaManager, attribute.getName() + FORWARD_BTREE, recMan, comp, null, - LongSerializer.INSTANCE ); - reverse = new JdbmTable( schemaManager, attribute.getName() + REVERSE_BTREE, recMan, - LongComparator.INSTANCE, LongSerializer.INSTANCE, null ); + forward = new JdbmTable, Long>( schemaManager, attribute.getName() + FORWARD_BTREE, + recMan, comp, null, LongSerializer.INSTANCE ); + reverse = new JdbmTable>( schemaManager, attribute.getName() + REVERSE_BTREE, + recMan, LongComparator.INSTANCE, LongSerializer.INSTANCE, null ); } - public void add( K rdn, Long entryId ) throws Exception + public void add( ParentIdAndRdn rdn, Long entryId ) throws Exception { forward.put( rdn, entryId ); reverse.put( entryId, rdn ); @@ -140,13 +141,13 @@ public class JdbmRdnIndex extends public void drop( Long entryId ) throws Exception { - K rdn = reverse.get( entryId ); + ParentIdAndRdn rdn = reverse.get( entryId ); forward.remove( rdn ); reverse.remove( entryId ); } - public void drop( K rdn, Long id ) throws Exception + public void drop( ParentIdAndRdn rdn, Long id ) throws Exception { long val = forward.get( rdn ); if ( val == id ) @@ -157,7 +158,7 @@ public class JdbmRdnIndex extends } - public K getNormalized( K rdn ) throws Exception + public ParentIdAndRdn getNormalized( ParentIdAndRdn rdn ) throws Exception { return rdn; } Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Thu Apr 29 21:21:14 2010 @@ -36,6 +36,7 @@ import org.apache.directory.server.xdbm. import org.apache.directory.server.xdbm.Index; import org.apache.directory.server.xdbm.IndexCursor; import org.apache.directory.server.xdbm.IndexEntry; +import org.apache.directory.server.xdbm.ParentIdAndRdn; import org.apache.directory.shared.ldap.MultiException; import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.cursor.Cursor; @@ -72,7 +73,7 @@ public class JdbmStore extends Abstra private JdbmMasterTable master; /** the relative distinguished name index */ - private JdbmRdnIndex rdnIdx; + private JdbmRdnIndex rdnIdx; /** Static declarations to avoid lookup all over the code */ private static AttributeType OBJECT_CLASS_AT; @@ -158,7 +159,7 @@ public class JdbmStore extends Abstra { if ( rdnIdx == null ) { - rdnIdx = new JdbmRdnIndex(); + rdnIdx = new JdbmRdnIndex(); rdnIdx.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_RDN_AT_OID, ( JdbmIndex ) rdnIdx ); } @@ -321,15 +322,13 @@ public class JdbmStore extends Abstra int dnSize = dn.size(); int i = suffixDn.size(); - RDN key = new RDN( suffixDn.getNormName() ); - key._setParentId( 0 ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, suffixDn.getRdn() ); Long curEntryId = rdnIdx.forwardLookup( key ); for ( ; i < dnSize; i++ ) { - key = dn.getRdn( i ); - key._setParentId( curEntryId ); + key = new ParentIdAndRdn( curEntryId, dn.getRdn( i ) ); curEntryId = rdnIdx.forwardLookup( key ); if ( curEntryId == null ) { @@ -366,14 +365,14 @@ public class JdbmStore extends Abstra do { - RDN curRdn = rdnIdx.reverseLookup( parentId ); - parentId = curRdn._getParentId(); - + ParentIdAndRdn cur = rdnIdx.reverseLookup( parentId ); + RDN curRdn = cur.getRdn(); + parentId = cur.getParentId(); if ( parentId == 0 ) { // we reached the suffix, add the context entry DN // we do this because the suffix can consist - // of multiple RDNs, e.g. ec=example,dc=com + // of multiple RDNs, e.g. dc=example,dc=com if ( contextEntryDn == null ) { contextEntryDn = new DN( curRdn.getName() ); @@ -409,21 +408,20 @@ public class JdbmStore extends Abstra */ private DN buildEntryDn( String dn ) throws Exception { + // TODO: what is this for??? DN normDN = new DN( dn ); normDN.normalize( schemaManager.getNormalizerMapping() ); int dnSize = normDN.size(); int i = suffixDn.size(); - RDN key = new RDN( suffixDn.getNormName() ); - key._setParentId( 0 ); + ParentIdAndRdn key = new ParentIdAndRdn(0L, suffixDn.getRdn()); Long curEntryId = rdnIdx.forwardLookup( key ); for ( ; i < dnSize; i++ ) { - key = normDN.getRdn( i ); - key._setParentId( curEntryId ); + key = new ParentIdAndRdn(curEntryId, normDN.getRdn( i )); curEntryId = rdnIdx.forwardLookup( key ); } @@ -431,41 +429,15 @@ public class JdbmStore extends Abstra } - /** - * Gets the Long id of an entry's parent using the child entry's - * normalized DN. Note that the suffix entry returns 0, which does not - * map to any entry. - * - * @param dn the normalized distinguished name of the child - * @return the id of the parent entry or zero if the suffix entry the - * normalized suffix DN string is used - * @throws Exception on failures to access the underlying store - */ - public Long getParentId( String dn ) throws Exception - { - DN normDN = new DN( dn ); - normDN.normalize( schemaManager.getNormalizerMapping() ); - - if ( suffixDn.equals( normDN ) ) - { - return 0L; - } - - normDN = buildEntryDn( dn ); - return normDN.getRdn()._getParentId(); - } - - public Long getParentId( Long childId ) throws Exception { - //return oneLevelIdx.reverseLookup( childId ); - RDN rdn = rdnIdx.reverseLookup( childId ); - if ( rdn == null ) + ParentIdAndRdn key = rdnIdx.reverseLookup( childId ); + if ( key == null ) { return null; } - return rdn._getParentId(); + return key.getParentId(); } @@ -599,7 +571,9 @@ public class JdbmStore extends Abstra } // L O O K U P T A R G E T I D - targetId = rdnIdx.forwardLookup( normalizedAliasTargetDn.getRdn() ); + ParentIdAndRdn key = new ParentIdAndRdn( getParentId( getEntryId( normalizedAliasTargetDn ) ), + normalizedAliasTargetDn.getRdn() ); + targetId = rdnIdx.forwardLookup( key ); /* * Check For Target Existence @@ -725,8 +699,8 @@ public class JdbmStore extends Abstra throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) ); } - rdn._setParentId( parentId ); - rdnIdx.add( rdn, id ); + ParentIdAndRdn key = new ParentIdAndRdn( parentId, rdn ); + rdnIdx.add( key, id ); EntryAttribute objectClass = entry.get( OBJECT_CLASS_AT ); @@ -1385,10 +1359,6 @@ public class JdbmStore extends Abstra // gotta normalize cuz this thang is cloned and not normalized by default newUpdn.normalize( schemaManager.getNormalizerMapping() ); - // restore the parentId from the old RDN - newRdn = newUpdn.getRdn(); - newRdn._setParentId( updn.getRdn()._getParentId() ); - modifyDn( id, newUpdn, false ); // propagate dn changes // Update the current entry @@ -1432,7 +1402,9 @@ public class JdbmStore extends Abstra updn.getRdn().normalize( schemaManager.getNormalizerMapping() ); } - rdnIdx.add( updn.getRdn(), id ); + Long parentId = getEntryId( updn.getParent() ); + ParentIdAndRdn key = new ParentIdAndRdn( parentId, updn.getRdn() ); + rdnIdx.add( key, id ); /* * Read Alias Index Tuples @@ -1538,7 +1510,6 @@ public class JdbmStore extends Abstra DN childUpdn = buildEntryDn( childId ); RDN childRdn = childUpdn.getRdn( childUpdn.size() - 1 ); - childRdn._setParentId( newParentId ); DN newUpdn = buildEntryDn( newParentId ); newUpdn.add( childRdn ); Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (original) +++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Thu Apr 29 21:21:14 2010 @@ -33,6 +33,7 @@ import org.apache.commons.io.FileUtils; import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.xdbm.Index; import org.apache.directory.server.xdbm.IndexEntry; +import org.apache.directory.server.xdbm.ParentIdAndRdn; import org.apache.directory.shared.ldap.cursor.Cursor; import org.apache.directory.shared.ldap.name.DN; import org.apache.directory.shared.ldap.name.RDN; @@ -57,7 +58,7 @@ import org.junit.Test; public class JdbmRdnIndexTest { private static File dbFileDir; - Index idx; + Index, Long, Long> idx; private static SchemaManager schemaManager; @@ -134,15 +135,15 @@ public class JdbmRdnIndexTest void initIndex() throws Exception { - initIndex( new JdbmRdnIndex() ); + initIndex( new JdbmRdnIndex() ); } - void initIndex( JdbmRdnIndex jdbmIdx ) throws Exception + void initIndex( JdbmRdnIndex jdbmIdx ) throws Exception { if ( jdbmIdx == null ) { - jdbmIdx = new JdbmRdnIndex(); + jdbmIdx = new JdbmRdnIndex(); } jdbmIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT_OID ), dbFileDir ); @@ -184,9 +185,9 @@ public class JdbmRdnIndexTest public void testWkDirPath() throws Exception { // uninitialized index - JdbmRdnIndex JdbmRdnIndex = new JdbmRdnIndex(); - JdbmRdnIndex.setWkDirPath( new File( dbFileDir, "foo" ) ); - assertEquals( "foo", JdbmRdnIndex.getWkDirPath().getName() ); + JdbmRdnIndex jdbmRdnIndex = new JdbmRdnIndex(); + jdbmRdnIndex.setWkDirPath( new File( dbFileDir, "foo" ) ); + assertEquals( "foo", jdbmRdnIndex.getWkDirPath().getName() ); // initialized index initIndex(); @@ -201,11 +202,11 @@ public class JdbmRdnIndexTest assertEquals( dbFileDir, idx.getWkDirPath() ); destroyIndex(); - JdbmRdnIndex = new JdbmRdnIndex(); + jdbmRdnIndex = new JdbmRdnIndex(); File wkdir = new File( dbFileDir, "foo" ); wkdir.mkdirs(); - JdbmRdnIndex.setWkDirPath( wkdir ); - initIndex( JdbmRdnIndex ); + jdbmRdnIndex.setWkDirPath( wkdir ); + initIndex( jdbmRdnIndex ); assertEquals( wkdir, idx.getWkDirPath() ); } @@ -239,15 +240,13 @@ public class JdbmRdnIndexTest initIndex(); assertEquals( 0, idx.count() ); - RDN key = new RDN( "cn=key" ); - key._setParentId( 0 ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, new RDN( "cn=key" ) ); idx.add( key, 0l ); assertEquals( 1, idx.count() ); // setting a different parentId should make this key a different key - key = new RDN( "cn=key" ); - key._setParentId( 1 ); + key = new ParentIdAndRdn( 1L, new RDN( "cn=key" ) ); idx.add( key, 1l ); assertEquals( 2, idx.count() ); @@ -256,8 +255,7 @@ public class JdbmRdnIndexTest idx.add( key, 2l ); assertEquals( 2, idx.count() ); - key = new RDN( "cn=key" ); - key._setParentId( 2 ); + key = new ParentIdAndRdn( 2L, new RDN( "cn=key" ) ); idx.add( key, 3l ); assertEquals( 3, idx.count() ); } @@ -268,7 +266,7 @@ public class JdbmRdnIndexTest { initIndex(); - RDN key = new RDN( "cn=key" ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, new RDN( "cn=key" ) ); assertEquals( 0, idx.count( key ) ); @@ -286,7 +284,7 @@ public class JdbmRdnIndexTest { initIndex(); - RDN key = new RDN( "cn=key" ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, new RDN( "cn=key" ) ); assertNull( idx.forwardLookup( key ) ); @@ -301,7 +299,7 @@ public class JdbmRdnIndexTest { initIndex(); - RDN key = new RDN( "cn=key" ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, new RDN( "cn=key" ) ); assertNull( idx.forwardLookup( key ) ); @@ -324,17 +322,16 @@ public class JdbmRdnIndexTest { initIndex(); - RDN key = new RDN( "cn=key" ); + ParentIdAndRdn key = new ParentIdAndRdn( 0L, new RDN( "cn=key" ) ); assertEquals( 0, idx.count() ); idx.add( key, 0l ); assertEquals( 1, idx.count() ); - for( int i=1; i< 5; i++ ) + for( long i=1; i< 5; i++ ) { - key = new RDN( "cn=key" + i ); - key._setParentId( i ); + key = new ParentIdAndRdn( i, new RDN( "cn=key" + i ) ); idx.add( key, ( long ) i ); } @@ -342,44 +339,44 @@ public class JdbmRdnIndexTest assertEquals( 5, idx.count() ); // use forward index's cursor - Cursor> cursor = idx.forwardCursor(); + Cursor, Long, Long>> cursor = idx.forwardCursor(); cursor.beforeFirst(); cursor.next(); - IndexEntry e1 = cursor.get(); + IndexEntry, Long, Long> e1 = cursor.get(); assertEquals( 0, ( long ) e1.getId() ); - assertEquals( "cn=key", e1.getValue().getName() ); - assertEquals( -1, e1.getValue()._getParentId() ); + assertEquals( "cn=key", e1.getValue().getRdn().getName() ); + assertEquals( 0, e1.getValue().getParentId().longValue() ); cursor.next(); - IndexEntry e2 = cursor.get(); + IndexEntry, Long, Long> e2 = cursor.get(); assertEquals( 1, ( long ) e2.getId() ); - assertEquals( "cn=key1", e2.getValue().getName() ); - assertEquals( 1, e2.getValue()._getParentId() ); + assertEquals( "cn=key1", e2.getValue().getRdn().getName() ); + assertEquals( 1, e2.getValue().getParentId().longValue() ); cursor.next(); - IndexEntry e3 = cursor.get(); + IndexEntry, Long, Long> e3 = cursor.get(); assertEquals( 2, ( long ) e3.getId() ); - assertEquals( "cn=key2", e3.getValue().getName() ); - assertEquals( 2, e3.getValue()._getParentId() ); + assertEquals( "cn=key2", e3.getValue().getRdn().getName() ); + assertEquals( 2, e3.getValue().getParentId().longValue() ); } - @Test - public void testStoreRdnWithTwoATAVs() throws Exception - { - initIndex(); - - DN dn = new DN( "dc=example,dc=com" ); - dn.normalize( schemaManager.getNormalizerMapping() ); - - RDN rdn = new RDN( dn.getName() ); - rdn._setParentId( 1 ); - idx.add( rdn, 0l ); - - RDN rdn2 = idx.reverseLookup( 0l ); - System.out.println( rdn2 ); - InternalRdnComparator rdnCom = new InternalRdnComparator( "" ); - assertEquals( 0, rdnCom.compare( rdn, rdn2 ) ); - } +// @Test +// public void testStoreRdnWithTwoATAVs() throws Exception +// { +// initIndex(); +// +// DN dn = new DN( "dc=example,dc=com" ); +// dn.normalize( schemaManager.getNormalizerMapping() ); +// +// RDN rdn = new RDN( dn.getName() ); +// rdn._setParentId( 1 ); +// idx.add( rdn, 0l ); +// +// RDN rdn2 = idx.reverseLookup( 0l ); +// System.out.println( rdn2 ); +// InternalRdnComparator rdnCom = new InternalRdnComparator( "" ); +// assertEquals( 0, rdnCom.compare( rdn, rdn2 ) ); +// } } Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original) +++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Thu Apr 29 21:21:14 2010 @@ -461,7 +461,7 @@ public class JdbmStoreTest assertEquals( dn.getName(), store.getEntryUpdn( 1L ) ); // note that the suffix entry returns 0 for it's parent which does not exist - assertEquals( 0L, ( long ) store.getParentId( dn.getNormName() ) ); + assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) ); assertNull( store.getParentId( 0L ) ); // should NOW be allowed Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original) +++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Thu Apr 29 21:21:14 2010 @@ -841,20 +841,6 @@ public class LdifPartition extends BTree @Override - public Long getParentId( Long childId ) throws Exception - { - return wrappedPartition.getParentId( childId ); - } - - - @Override - public Long getParentId( String dn ) throws Exception - { - return wrappedPartition.getParentId( dn ); - } - - - @Override public Index getPresenceIndex() { return wrappedPartition.getPresenceIndex(); Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original) +++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Thu Apr 29 21:21:14 2010 @@ -431,12 +431,6 @@ public abstract class BTreePartition public abstract String getEntryDn( ID id ) throws Exception; - public abstract ID getParentId( String dn ) throws Exception; - - - public abstract ID getParentId( ID childId ) throws Exception; - - /** * Gets the user provided distinguished name. * Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java (original) +++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java Thu Apr 29 21:21:14 2010 @@ -205,18 +205,6 @@ public abstract class AbstractXdbmPartit } - public final ID getParentId( String dn ) throws Exception - { - return store.getParentId( dn ); - } - - - public final ID getParentId( ID childId ) throws Exception - { - return store.getParentId( childId ); - } - - public final String getEntryUpdn( ID id ) throws Exception { return store.getEntryUpdn( id ); Added: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=939483&view=auto ============================================================================== --- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java (added) +++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java Thu Apr 29 21:21:14 2010 @@ -0,0 +1,158 @@ +/* + * 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 java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +import org.apache.directory.shared.ldap.name.RDN; + + +/** + * A wrapper for the tuple of parentId and RDN, used for the RDN index. + * + * @author Apache Directory Project + * @version $Rev: 917312 $ + */ +public class ParentIdAndRdn> implements Externalizable, Comparable> +{ + + protected ID parentId; + protected RDN rdn; + + + /** + * Serializable constructor. + */ + public ParentIdAndRdn() + { + } + + + /** + * Creates a new instance of ParentIdAndRdn. + * + * @param parentId the parent ID + * @param rdn the RDN + */ + public ParentIdAndRdn( ID parentId, RDN rdn ) + { + this.parentId = parentId; + this.rdn = rdn; + } + + + /** + * Gets the parent ID. + * + * @return the parent ID + */ + public ID getParentId() + { + return parentId; + } + + + /** + * Sets the parent ID. + * + * @param parentId the new parent ID + */ + public void setParentId( ID parentId ) + { + this.parentId = parentId; + } + + + /** + * Gets the RDN. + * + * @return the RDN + */ + public RDN getRdn() + { + return rdn; + } + + + /** + * Sets the RDN. + * + * @param rdn the new RDN + */ + public void setRdn( RDN rdn ) + { + this.rdn = rdn; + } + + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( parentId == null ) ? 0 : parentId.hashCode() ); + result = prime * result + ( ( rdn == null ) ? 0 : rdn.hashCode() ); + return result; + } + + + @Override + @SuppressWarnings("unchecked") + public boolean equals( Object obj ) + { + if ( !( obj instanceof ParentIdAndRdn ) ) + { + return false; + } + + return compareTo( ( ParentIdAndRdn ) obj ) == 0; + } + + + public int compareTo( ParentIdAndRdn o ) + { + int val = this.getRdn().compareTo( o.getRdn() ); + if ( val == 0 ) + { + val = this.getParentId().compareTo( o.getParentId() ); + } + + return val; + } + + + public void writeExternal( ObjectOutput out ) throws IOException + { + out.writeObject( parentId ); + out.writeObject( rdn ); + } + + + @SuppressWarnings("unchecked") + public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException + { + parentId = ( ID ) in.readObject(); + rdn = ( RDN ) in.readObject(); + } +} Added: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdnComparator.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdnComparator.java?rev=939483&view=auto ============================================================================== --- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdnComparator.java (added) +++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdnComparator.java Thu Apr 29 21:21:14 2010 @@ -0,0 +1,60 @@ +/* + * 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.server.xdbm.ParentIdAndRdn; +import org.apache.directory.shared.ldap.schema.SchemaManager; +import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; + + +/** + * A comparator used to compare {@link ParentIdAndRdn} stored in the RDN index. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class ParentIdAndRdnComparator> extends SerializableComparator> +{ + + private static final long serialVersionUID = 5414960421568991202L; + + + public ParentIdAndRdnComparator( String matchingRuleOid ) + { + super( matchingRuleOid ); + } + + + @Override + public int compare( ParentIdAndRdn rdn1, ParentIdAndRdn rdn2 ) + { + return rdn1.compareTo( rdn2 ); + } + + + @Override + public void setSchemaManager( SchemaManager schemaManager ) + { + // no need to deal with the schema manager + } + +} \ No newline at end of file Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=939483&r1=939482&r2=939483&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java (original) +++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java Thu Apr 29 21:21:14 2010 @@ -386,18 +386,13 @@ public interface Store /** - * Gets the Long id of an entry's parent using the child entry's - * normalized dn. Note that the suffix entry returns 0, which does not - * map to any entry. - * - * @param dn the normalized distinguished name of the child - * @return the id of the parent entry or zero if the suffix entry the - * normalized suffix dn string is used + * Gets the ID of an entry's parent using the child entry's ID. + * Note that the suffix entry returns 0, which does not map to any entry. + * + * @param childId the ID of the entry + * @return the id of the parent entry or zero if the suffix entry ID is used * @throws Exception on failures to access the underlying store */ - ID getParentId( String dn ) throws Exception; - - ID getParentId( ID childId ) throws Exception;