directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r763087 - in /directory/apacheds/branches/ldif-partition: avl-partition/ avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/
Date Wed, 08 Apr 2009 02:58:52 GMT
Author: akarasulu
Date: Wed Apr  8 02:58:51 2009
New Revision: 763087

URL: http://svn.apache.org/viewvc?rev=763087&view=rev
Log:
adding new avl partition and changing index constructors

Added:
    directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
Modified:
    directory/apacheds/branches/ldif-partition/avl-partition/pom.xml
    directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
    directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java

Modified: directory/apacheds/branches/ldif-partition/avl-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/avl-partition/pom.xml?rev=763087&r1=763086&r2=763087&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/avl-partition/pom.xml (original)
+++ directory/apacheds/branches/ldif-partition/avl-partition/pom.xml Wed Apr  8 02:58:51 2009
@@ -88,6 +88,12 @@
       <artifactId>apacheds-xdbm-base</artifactId>
       <version>${pom.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-xdbm-search</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
   </dependencies>
 
   <build>

Modified: directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java?rev=763087&r1=763086&r2=763087&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
(original)
+++ directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
Wed Apr  8 02:58:51 2009
@@ -46,9 +46,8 @@
     private String attributeId;
     
     
-    public AvlIndex( String attributeId ) throws Exception
+    public AvlIndex() throws Exception
     {
-        this.attributeId = attributeId;
     }
     
     

Added: directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java?rev=763087&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
(added)
+++ directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
Wed Apr  8 02:58:51 2009
@@ -0,0 +1,162 @@
+/*
+ *   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.core.partition.avl;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.server.constants.ApacheSchemaConstants;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.XdbmPartition;
+import org.apache.directory.server.xdbm.search.impl.CursorBuilder;
+import org.apache.directory.server.xdbm.search.impl.DefaultOptimizer;
+import org.apache.directory.server.xdbm.search.impl.DefaultSearchEngine;
+import org.apache.directory.server.xdbm.search.impl.EvaluatorBuilder;
+import org.apache.directory.server.xdbm.search.impl.NoOpOptimizer;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+
+
+/**
+ * An XDBM Partition backed by in memory AVL Trees.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AvlPartition extends XdbmPartition
+{
+    private boolean optimizerEnabled = true;
+    private Set<AvlIndex<?,ServerEntry>> indexedAttributes;
+    private String suffix;
+    
+    
+    // ------------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * Creates a store based on AVL Trees.
+     */
+    public AvlPartition()
+    {
+        super();
+        super.setStore( new AvlStore<ServerEntry>() );
+        indexedAttributes = new HashSet<AvlIndex<?,ServerEntry>>();
+    }
+
+
+    /**
+     * @{inhertDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public void init( DirectoryService core ) throws Exception
+    {
+        setRegistries( core.getRegistries() );
+        
+        EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( getStore(), getRegistries()
);
+        CursorBuilder cursorBuilder = new CursorBuilder( getStore(), evaluatorBuilder );
+
+        // setup optimizer and registries for parent
+        if ( ! optimizerEnabled )
+        {
+            optimizer = new NoOpOptimizer();
+        }
+        else
+        {
+            optimizer = new DefaultOptimizer<ServerEntry>( getStore() );
+        }
+
+        searchEngine = new DefaultSearchEngine( getStore(), cursorBuilder, evaluatorBuilder,
optimizer );
+        
+        // initialize the store
+        getStore().setName( getId() );
+        getStore().setSuffixDn( suffix );
+
+        Set<AvlIndex<?,ServerEntry>> userIndices = new HashSet<AvlIndex<?,ServerEntry>>();
+        
+        for ( AvlIndex<?,ServerEntry> obj : indexedAttributes )
+        {
+            AvlIndex<?,ServerEntry> index;
+
+            if ( obj instanceof AvlIndex )
+            {
+                index = ( AvlIndex<?,ServerEntry> ) obj;
+            }
+            else
+            {
+                index = new AvlIndex<Object,ServerEntry>();
+                index.setAttributeId( obj.getAttributeId() );
+            }
+
+            String oid = getRegistries().getOidRegistry().getOid( index.getAttributeId()
);
+            
+            if ( SYS_INDEX_OIDS.contains( getRegistries().getOidRegistry().getOid( index.getAttributeId()
) ) )
+            {
+                if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_OID ) )
+                {
+                    getStore().setAliasIndex( ( Index<String,ServerEntry> ) index );
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_EXISTANCE_OID ) )
+                {
+                    getStore().setPresenceIndex( ( Index<String,ServerEntry> ) index
);
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID ) )
+                {
+                    getStore().setOneLevelIndex( ( Index<Long,ServerEntry> ) index
);
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_N_DN_OID ) )
+                {
+                    getStore().setNdnIndex( ( Index<String,ServerEntry> ) index );
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID ) )
+                {
+                    getStore().setOneAliasIndex( ( Index<Long,ServerEntry> ) index
);
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID ) )
+                {
+                    getStore().setSubAliasIndex( ( Index<Long,ServerEntry> ) index
);
+                }
+                else if ( oid.equals( ApacheSchemaConstants.APACHE_UP_DN_OID ) )
+                {
+                    getStore().setUpdnIndex( ( Index<String,ServerEntry> ) index );
+                }
+                else if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
+                {
+                    getStore().addIndex( ( Index<String,ServerEntry> ) index );
+                }
+                else
+                {
+                    throw new IllegalStateException( "Unrecognized system index " + oid );
+                }
+            }
+            else
+            {
+                userIndices.add( index );
+            }
+            
+            getStore().setUserIndices( userIndices );
+        }
+
+        getStore().init( getRegistries() );
+    }
+}

Modified: directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=763087&r1=763086&r2=763087&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
(original)
+++ directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
Wed Apr  8 02:58:51 2009
@@ -577,7 +577,8 @@
         if ( ndnIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_N_DN_OID
);
-            ndnIdx = new AvlIndex<String,E>( ApacheSchemaConstants.APACHE_N_DN_OID
);
+            ndnIdx = new AvlIndex<String,E>();
+            ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_OID );
             ndnIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_OID, ndnIdx );
         }
@@ -585,7 +586,8 @@
         if ( updnIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_UP_DN_OID
);
-            updnIdx = new AvlIndex<String,E>( ApacheSchemaConstants.APACHE_UP_DN_OID
);
+            updnIdx = new AvlIndex<String,E>();
+            updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_OID );
             updnIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_OID, updnIdx );
         }
@@ -593,7 +595,8 @@
         if ( existenceIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_EXISTANCE_OID
);
-            existenceIdx = new AvlIndex<String,E>( ApacheSchemaConstants.APACHE_EXISTANCE_OID
);
+            existenceIdx = new AvlIndex<String,E>();
+            existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTANCE_OID );
             existenceIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_EXISTANCE_OID, existenceIdx );
         }
@@ -601,7 +604,8 @@
         if ( oneLevelIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID
);
-            oneLevelIdx = new AvlIndex<Long,E>( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID
);
+            oneLevelIdx = new AvlIndex<Long,E>();
+            oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID );
             oneLevelIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID, oneLevelIdx );
         }
@@ -609,7 +613,8 @@
         if ( oneAliasIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID
);
-            oneAliasIdx = new AvlIndex<Long,E>( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID
);
+            oneAliasIdx = new AvlIndex<Long,E>();
+            oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID );
             oneAliasIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID, oneAliasIdx );
         }
@@ -617,7 +622,8 @@
         if ( subAliasIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID
);
-            subAliasIdx = new AvlIndex<Long,E>( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID
);
+            subAliasIdx = new AvlIndex<Long,E>();
+            subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID );
             subAliasIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID, subAliasIdx );
         }
@@ -625,7 +631,8 @@
         if ( aliasIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ALIAS_OID
);
-            aliasIdx = new AvlIndex<String,E>( ApacheSchemaConstants.APACHE_ALIAS_OID
);
+            aliasIdx = new AvlIndex<String,E>();
+            aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_OID );
             aliasIdx.initialize( attributeType );
             systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_OID, aliasIdx );
         }
@@ -633,7 +640,8 @@
         if ( subLevelIdx == null )
         {
             AttributeType attributeType = attributeTypeRegistry.lookup( SUBLEVEL );
-            subLevelIdx = new AvlIndex<Long, E>( SUBLEVEL ); 
+            subLevelIdx = new AvlIndex<Long, E>();
+            subLevelIdx.setAttributeId( SUBLEVEL ); 
             subLevelIdx.initialize( attributeType );
             systemIndices.put( SUBLEVEL, subLevelIdx );
         }
@@ -1488,7 +1496,9 @@
     
     private <K> Index<K,E> convert( Index<K,E> index ) throws Exception
     {
-        return new AvlIndex<K, E>( index.getAttributeId() );
+        AvlIndex<K, E> avlIndex = new AvlIndex<K, E>(); 
+        avlIndex.setAttributeId( index.getAttributeId() );
+        return avlIndex;
     }
     
     

Modified: directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java?rev=763087&r1=763086&r2=763087&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
(original)
+++ directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
Wed Apr  8 02:58:51 2009
@@ -64,6 +64,7 @@
      */
     public JdbmPartition()
     {
+        super();
         super.setStore( new JdbmStore<ServerEntry>() );
         indexedAttributes = new HashSet<JdbmIndex<?,ServerEntry>>();
     }



Mime
View raw message