You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2014/06/01 09:43:35 UTC
svn commit: r1598954 - in
/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree:
MavibotPartitionBuilder.java SchemaAwareLdifReader.java
Author: kayyagari
Date: Sun Jun 1 07:43:34 2014
New Revision: 1598954
URL: http://svn.apache.org/r1598954
Log:
o a schema-aware LDIF reader implementation
o updated builder to use the new LDIF reader and re-use created time value
o pass the relevant flag to storeRevision() method
Added:
directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/SchemaAwareLdifReader.java
Modified:
directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java
Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java?rev=1598954&r1=1598953&r2=1598954&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java (original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java Sun Jun 1 07:43:34 2014
@@ -239,7 +239,7 @@ public class MavibotPartitionBuilder
rm.addInBtreeOfBtrees( name, btree.getRevision(), newBtreeHeaderOffset );
// Store the new revision
- btree.storeRevision( header );
+ btree.storeRevision( header, rm.isKeepRevisions() );
rm.freePages( ( BTree ) btree, btree.getRevision(), ( List ) Arrays.asList( oldRoot ) );
@@ -493,6 +493,7 @@ public class MavibotPartitionBuilder
private Iterator<DnTuple> itr = idSortedSet.iterator();
+ final String createTime = DateUtils.getGeneralizedTime();
@Override
public boolean hasNext()
@@ -514,17 +515,15 @@ public class MavibotPartitionBuilder
raf.seek( dt.getOffset() );
raf.readFully( data, 0, data.length );
- LdifReader lar = new LdifReader();
+ SchemaAwareLdifReader lar = new SchemaAwareLdifReader( schemaManager );
Entry entry = lar.parseLdif( Strings.utf8ToString( data ) ).get( 0 ).getEntry();
- // make it schema aware
- entry = new DefaultEntry( schemaManager, entry );
entry.add( SchemaConstants.ENTRY_UUID_AT, dt.getId() );
entry.add( SchemaConstants.ENTRY_PARENT_ID_AT, dt.getParentId() );
entry.add( SchemaConstants.ENTRY_CSN_AT, csnFactory.newInstance().toString() );
entry.add( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
- entry.add( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+ entry.add( SchemaConstants.CREATE_TIMESTAMP_AT, createTime );
t.setValue( entry );
}
@@ -797,6 +796,7 @@ public class MavibotPartitionBuilder
}
catch( Exception e )
{
+ e.printStackTrace();
LOG.warn( "Failed to build the index " + id.getAttribute().getName() );
LOG.warn( "", e );
return;
@@ -1064,7 +1064,7 @@ public class MavibotPartitionBuilder
TupleCursor cursor = tree.browse();
while ( cursor.hasNext() )
{
- System.out.println( cursor.next() );
+ //System.out.println( cursor.next() );
}
cursor.close();
@@ -1184,9 +1184,8 @@ public class MavibotPartitionBuilder
//builder.testBTree( fwdRdnTree );
//String revRdnTree = ApacheSchemaConstants.APACHE_RDN_AT_OID + MavibotRdnIndex.REVERSE_BTREE;
- //builder.testBTree( revRdnTree );
+ //builder.testBTree( "2.5.4.0_forward" );
//builder.testPartition();
-
}
/*
Added: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/SchemaAwareLdifReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/SchemaAwareLdifReader.java?rev=1598954&view=auto
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/SchemaAwareLdifReader.java (added)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/SchemaAwareLdifReader.java Sun Jun 1 07:43:34 2014
@@ -0,0 +1,49 @@
+/*
+ * 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.mavibot.btree;
+
+import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.ldif.LdifEntry;
+import org.apache.directory.api.ldap.model.ldif.LdifReader;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+
+/**
+ * TODO SchemaAwareLdifReader.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaAwareLdifReader extends LdifReader
+{
+ private SchemaManager schemaManager;
+
+ public SchemaAwareLdifReader( SchemaManager schemaManager ) throws Exception
+ {
+ this.schemaManager = schemaManager;
+ }
+
+ @Override
+ protected LdifEntry createLdifEntry()
+ {
+ Entry entry = new DefaultEntry( schemaManager );
+ return new LdifEntry( entry );
+ }
+
+}