directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r423455 - in /directory/branches/apacheds/optimization: core/src/main/java/org/apache/directory/server/core/authz/ core/src/main/java/org/apache/directory/server/core/configuration/ core/src/main/java/org/apache/directory/server/core/enumer...
Date Wed, 19 Jul 2006 13:17:58 GMT
Author: akarasulu
Date: Wed Jul 19 06:17:56 2006
New Revision: 423455

URL: http://svn.apache.org/viewvc?rev=423455&view=rev
Log:
made use of optimizer configurable

Added:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java
Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java
    directory/branches/apacheds/optimization/server-installers/src/main/installers/server.xml
    directory/branches/apacheds/optimization/server-main/server.xml

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
Wed Jul 19 06:17:56 2006
@@ -927,9 +927,7 @@
         Invocation invocation = InvocationStack.getInstance().peek();
         ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapPrincipal user = ctx.getPrincipal();
-        LdapDN principalDn = new LdapDN( user.getName() );
-        principalDn.normalize( attrRegistry.getNormalizerMapping() );
-        
+        LdapDN principalDn = user.getJndiName();
         NamingEnumeration e = next.search( base, env, filter, searchCtls );
 
         boolean isSubschemaSubentryLookup = subschemaSubentryDn.equals( base.toNormName()
);

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java
Wed Jul 19 06:17:56 2006
@@ -25,6 +25,7 @@
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.core.partition.DirectoryPartition;
+import org.apache.directory.server.core.partition.impl.btree.BTreePartitionConfiguration;
 
 
 /**
@@ -33,7 +34,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class MutablePartitionConfiguration extends PartitionConfiguration
+public class MutablePartitionConfiguration extends BTreePartitionConfiguration
 {
     /**
      * Creates a new instance.
@@ -72,6 +73,11 @@
         super.setSuffix( suffix );
     }
     
+    
+    public void setOptimizerEnabled( boolean optimizerEnabled )
+    {
+        super.setOptimizerEnabled( optimizerEnabled );
+    }
     
     /**
      * Get's the entry cache size for this partition.

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java
Wed Jul 19 06:17:56 2006
@@ -87,8 +87,8 @@
      * creating this enumeration
      * @param invocation the invocation representing the seach that created this enumeration
      */
-    public SearchResultFilteringEnumeration(NamingEnumeration decorated, SearchControls searchControls,
-        Invocation invocation, SearchResultFilter filter) throws NamingException
+    public SearchResultFilteringEnumeration( NamingEnumeration decorated, SearchControls
searchControls,
+        Invocation invocation, SearchResultFilter filter ) throws NamingException
     {
         this.searchControls = searchControls;
         this.invocation = invocation;
@@ -116,8 +116,8 @@
      * creating this enumeration
      * @param invocation the invocation representing the seach that created this enumeration
      */
-    public SearchResultFilteringEnumeration(NamingEnumeration decorated, SearchControls searchControls,
-        Invocation invocation, List filters) throws NamingException
+    public SearchResultFilteringEnumeration( NamingEnumeration decorated, SearchControls
searchControls,
+        Invocation invocation, List filters ) throws NamingException
     {
         this.searchControls = searchControls;
         this.invocation = invocation;

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Wed Jul 19 06:17:56 2006
@@ -122,7 +122,20 @@
         OidRegistry oidRegistry = factoryCfg.getGlobalRegistries().getOidRegistry();
         ExpressionEvaluator evaluator = new ExpressionEvaluator( this, oidRegistry, attributeTypeRegistry
);
         ExpressionEnumerator enumerator = new ExpressionEnumerator( this, attributeTypeRegistry,
evaluator );
-        this.searchEngine = new DefaultSearchEngine( this, evaluator, enumerator );
+        BTreePartitionConfiguration btConfig = BTreePartitionConfiguration.convert( cfg );
+        
+        
+        Optimizer optimizer;
+        if ( btConfig.isOptimizerEnabled() )
+        {
+            optimizer = new DefaultOptimizer( this );
+        }
+        else
+        {
+            optimizer = new NoOpOptimizer();
+        }
+        
+        this.searchEngine = new DefaultSearchEngine( this, evaluator, enumerator, optimizer
);
 
         HashSet sysOidSet = new HashSet();
         sysOidSet.add( Oid.EXISTANCE );

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java
Wed Jul 19 06:17:56 2006
@@ -19,6 +19,8 @@
 package org.apache.directory.server.core.partition.impl.btree;
 
 
+import javax.naming.NamingException;
+
 import org.apache.directory.server.core.configuration.PartitionConfiguration;
 
 
@@ -37,6 +39,19 @@
      * opertations are performed
      */
     private boolean synchOnWrite = false;
+    private boolean optimizerEnabled = true;
+
+
+    protected void setOptimizerEnabled( boolean optimizerEnabled )
+    {
+        this.optimizerEnabled = optimizerEnabled;
+    }
+
+
+    public boolean isOptimizerEnabled()
+    {
+        return optimizerEnabled;
+    }
 
     
     protected void setSynchOnWrite( boolean synchOnWrite )
@@ -48,5 +63,23 @@
     public boolean isSynchOnWrite()
     {
         return synchOnWrite;
+    }
+    
+    
+    public static BTreePartitionConfiguration convert( PartitionConfiguration config ) throws
NamingException
+    {
+        if ( config instanceof BTreePartitionConfiguration )
+        {
+            return ( BTreePartitionConfiguration ) config;
+        }
+        
+        BTreePartitionConfiguration newConfig = new BTreePartitionConfiguration();
+        newConfig.setCacheSize( config.getCacheSize() );
+        newConfig.setContextEntry( config.getContextEntry() );
+        newConfig.setContextPartition( config.getContextPartition() );
+        newConfig.setIndexedAttributes( config.getIndexedAttributes() );
+        newConfig.setName( config.getName() );
+        newConfig.setSuffix( config.getSuffix() );
+        return newConfig;
     }
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
Wed Jul 19 06:17:56 2006
@@ -60,13 +60,13 @@
      * Creates a DefaultSearchEngine for searching a Database without setting
      * up the database.
      */
-    public DefaultSearchEngine(BTreePartition db, ExpressionEvaluator evaluator,
-        ExpressionEnumerator enumerator)
+    public DefaultSearchEngine( BTreePartition db, ExpressionEvaluator evaluator,
+        ExpressionEnumerator enumerator, Optimizer optimizer )
     {
         this.db = db;
         this.evaluator = evaluator;
         this.enumerator = enumerator;
-        optimizer = new DefaultOptimizer( db );
+        this.optimizer = optimizer;
     }
 
 

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java
Wed Jul 19 06:17:56 2006
@@ -77,6 +77,12 @@
     }
     
     
+    public void setOptimizerEnabled( boolean optimizerEnabled )
+    {
+        super.setOptimizerEnabled( optimizerEnabled );
+    }
+    
+    
     public static MutableBTreePartitionConfiguration getConfiguration( PartitionConfiguration
config ) 
         throws NamingException
     {

Added: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java?rev=423455&view=auto
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java
(added)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java
Wed Jul 19 06:17:56 2006
@@ -0,0 +1,75 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.impl.btree;
+
+import java.math.BigInteger;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.filter.BranchNode;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+
+/**
+ * A do nothing optimizer which labels all nodes with <code>
+ * BigInteger.valueOf( Integer.MAX_VALUE ) </code>, instead of actually 
+ * taking scan counts.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NoOpOptimizer implements Optimizer
+{
+    /** the maximum size for a count Integer.MAX_VALUE as a BigInteger */
+    private static final BigInteger MAX = BigInteger.valueOf( Integer.MAX_VALUE );
+    
+    public void annotate( ExprNode node ) throws NamingException
+    {
+        if ( node.isLeaf() )
+        {
+            node.set( "count", MAX );
+            return;
+        }
+        
+        BranchNode bnode = ( BranchNode ) node;
+        if ( bnode.getChildren().size() == 0 )
+        {
+            return;
+        }
+        
+        if ( bnode.getChildren().size() == 1 )
+        {
+            ( ( ExprNode ) bnode.getChildren().get( 0 ) ).set( "count", MAX );
+            return;
+        }
+        
+        final int limit = bnode.getChildren().size();
+        for ( int ii = 0; ii < limit; ii++ )
+        {
+            ExprNode child = ( ExprNode ) bnode.getChildren().get( ii );
+            if ( child.isLeaf() )
+            {
+                child.set( "count", MAX );
+            }
+            else
+            {
+                annotate( child );
+            }
+        }
+    }
+}

Modified: directory/branches/apacheds/optimization/server-installers/src/main/installers/server.xml
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/server-installers/src/main/installers/server.xml?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/server-installers/src/main/installers/server.xml
(original)
+++ directory/branches/apacheds/optimization/server-installers/src/main/installers/server.xml
Wed Jul 19 06:17:56 2006
@@ -186,6 +186,10 @@
     <property name="cacheSize"><value>10000</value></property>
     <property name="suffix"><value>ou=system</value></property>
 
+    <!-- the optimizer is enabled by default but may not always be what     -->
+    <!-- you want if your queries are really simple                         -->
+    <property name="optimizerEnabled"><value>true</value></property>
+
     <!--
       Synchronization on writes does not wait for synch operations
       to flush dirty pages.  Writes persist immediately to disk at 
@@ -254,6 +258,10 @@
     <property name="name"><value>example</value></property>
     <property name="cacheSize"><value>10000</value></property>
     <property name="suffix"><value>dc=example,dc=com</value></property>
+
+    <!-- the optimizer is enabled by default but may not always be what     -->
+    <!-- you want if your queries are really simple                         -->
+    <property name="optimizerEnabled"><value>true</value></property>
 
     <!--
       Synchronization on writes does not wait for synch operations

Modified: directory/branches/apacheds/optimization/server-main/server.xml
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/server-main/server.xml?rev=423455&r1=423454&r2=423455&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/server-main/server.xml (original)
+++ directory/branches/apacheds/optimization/server-main/server.xml Wed Jul 19 06:17:56 2006
@@ -186,6 +186,10 @@
     <property name="cacheSize"><value>10000</value></property>
     <property name="suffix"><value>ou=system</value></property>
 
+    <!-- the optimizer is enabled by default but may not always be what     -->
+    <!-- you want if your queries are really simple                         -->
+    <property name="enableOptimizer"><value>true</value></property>
+
     <!--
       Synchronization on writes does not wait for synch operations
       to flush dirty pages.  Writes persist immediately to disk at 
@@ -254,6 +258,10 @@
     <property name="name"><value>example</value></property>
     <property name="cacheSize"><value>10000</value></property>
     <property name="suffix"><value>dc=example,dc=com</value></property>
+
+    <!-- the optimizer is enabled by default but may not always be what     -->
+    <!-- you want if your queries are really simple                         -->
+    <property name="enableOptimizer"><value>true</value></property>
 
     <!--
       Synchronization on writes does not wait for synch operations



Mime
View raw message