directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r642502 - in /directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl: ApproximateEvaluator.java EvaluatorBuilder.java ExpressionEvaluatorBuilder.java LeafEvaluator.java
Date Sat, 29 Mar 2008 03:48:08 GMT
Author: akarasulu
Date: Fri Mar 28 20:48:07 2008
New Revision: 642502

URL: http://svn.apache.org/viewvc?rev=642502&view=rev
Log:
More Evaluator work ...

 o removed the LeafEvaluator - we're creating evaluators for each node instead
   of using the flyweight pattern
 o fixed some generics issues with EvaluatorBuilder
 o feed bad about adding but added ApproximateEvaluator as a copy of 
   EqualityEvaluator because of some issues with generics


Added:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
      - copied, changed from r642498, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
Removed:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LeafEvaluator.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEvaluatorBuilder.java

Copied: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
(from r642498, directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?p2=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java&p1=directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java&r1=642498&r2=642502&rev=642502&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
Fri Mar 28 20:48:07 2008
@@ -20,7 +20,7 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.apache.directory.shared.ldap.filter.EqualityNode;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -38,15 +38,15 @@
 
 
 /**
- * An Evaluator which determines if candidates are matched by GreaterEqNode
- * assertions.
+ * An Evaluator which determines if candidates are matched by ApproximateNode
+ * assertions.  Same as equality for now.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class EqualityEvaluator implements Evaluator<EqualityNode, Attributes>
+public class ApproximateEvaluator implements Evaluator<ApproximateNode, Attributes>
 {
-    private final EqualityNode node;
+    private final ApproximateNode node;
     private final Store<Attributes> db;
     private final Registries registries;
     private final AttributeType type;
@@ -55,7 +55,7 @@
     private final Index<Number,Attributes> idx;
 
 
-    public EqualityEvaluator( EqualityNode node, Store<Attributes> db, Registries registries
)
+    public ApproximateEvaluator( ApproximateNode node, Store<Attributes> db, Registries
registries )
         throws Exception
     {
         this.db = db;
@@ -89,7 +89,7 @@
     }
 
 
-    public EqualityNode getExpression()
+    public ApproximateNode getExpression()
     {
         return node;
     }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=642502&r1=642501&r2=642502&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
Fri Mar 28 20:48:07 2008
@@ -30,7 +30,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public interface EvaluatorBuilder<N extends ExprNode, E>
+public interface EvaluatorBuilder<E>
 {
     /**
      * Builds an Evaluator based on the filter expression provided.
@@ -39,5 +39,5 @@
      * @return the evaluator for the AST
      * @throws Exception on database faults during construction
      */
-    Evaluator<N,E> build( ExprNode expression ) throws Exception;
+    Evaluator<? extends ExprNode,E> build( ExprNode expression ) throws Exception;
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEvaluatorBuilder.java?rev=642502&r1=642501&r2=642502&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEvaluatorBuilder.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ExpressionEvaluatorBuilder.java
Fri Mar 28 20:48:07 2008
@@ -20,21 +20,21 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.filter.*;
+import org.apache.directory.shared.ldap.NotImplementedException;
 
 
 /**
- * Top level filter expression evaluator implemenation.
+ * Top level filter expression evaluator builder implemenation.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExpressionEvaluatorBuilder implements EvaluatorBuilder<ExprNode,Attributes>
+public class ExpressionEvaluatorBuilder implements EvaluatorBuilder<Attributes>
 {
     private final Store<Attributes> db;
     private final Registries registries;
@@ -50,6 +50,8 @@
      * evaluator which will be created.
      *
      * @param db the database this evaluator operates upon
+     * @param registries the schema registries
+     * @throws Exception failure to access db or lookup schema in registries
      */
     public ExpressionEvaluatorBuilder( Store<Attributes> db, Registries registries
) throws Exception
     {
@@ -66,51 +68,83 @@
     /**
      * @see EvaluatorBuilder#build(ExprNode)
      */
-    public Evaluator<ExprNode, Attributes> build( ExprNode node ) throws NamingException
+    public Evaluator<? extends ExprNode, Attributes> build( ExprNode node ) throws
Exception
     {
-        if ( node.isLeaf() )
+        switch ( node.getAssertionType() )
         {
-            switch ( )
-        }
-
-        BranchNode bnode = ( BranchNode ) node;
-
-        if ( bnode instanceof OrNode )
-        {
-            for ( ExprNode child:bnode.getChildren() )
-            {
-                if ( evaluate( child, entry ) )
-                {
-                    return true;
-                }
-            }
+            case APPROXIMATE:
+                return new ApproximateEvaluator( ( ApproximateNode ) node, db, registries
);
+            case EQUALITY:
+                return new EqualityEvaluator( ( EqualityNode ) node, db, registries );
+            case GREATEREQ:
+                return new GreaterEqEvaluator( ( GreaterEqNode ) node, db, registries );
+            case LESSEQ:
+                return new LessEqEvaluator( ( LessEqNode ) node, db, registries );
+            case PRESENCE:
+                return new PresenceEvaluator( ( PresenceNode ) node, db, registries );
+            case SCOPE:
+//                return new ScopeEvaluator( ( ScopeNode ) node, db, registries );
+                throw new NotImplementedException( "SOON!!!!!" );
+            case SUBSTRING:
+                return new SubstringEvaluator( ( SubstringNode ) node, db, registries );
+
+                /* ---------- LOGICAL OPERATORS ---------- */
+
+            case AND:
+                throw new NotImplementedException();
+            case NOT:
+                throw new NotImplementedException();
+            case OR:
+                throw new NotImplementedException();
+
+                /* ----------  NOT IMPLEMENTED  ---------- */
+
+            case ASSERTION:
+            case EXTENSIBLE:
+                throw new NotImplementedException();
 
-            return false;
+            default:
+                throw new IllegalStateException( "Unknown assertion type: " + node.getAssertionType()
);
         }
-        else if ( bnode instanceof AndNode )
-        {
-            for ( ExprNode child:bnode.getChildren() )
-            {
-                if ( !evaluate( child, entry ) )
-                {
-                    return false;
-                }
-            }
 
-            return true;
-        }
-        else if ( bnode instanceof NotNode )
-        {
-            if ( null != bnode.getFirstChild() )
-            {
-                return !evaluate( bnode.getFirstChild(), entry );
-            }
-
-            throw new NamingException( "Negation has no child: " + node );
-        }
-        else
-        {
-                throw new NamingException( "Unrecognized branch node operator: " + bnode
);
-        }
+//        BranchNode bnode = ( BranchNode ) node;
+//
+//        if ( bnode instanceof OrNode )
+//        {
+//            for ( ExprNode child:bnode.getChildren() )
+//            {
+//                if ( evaluate( child, entry ) )
+//                {
+//                    return true;
+//                }
+//            }
+//
+//            return false;
+//        }
+//        else if ( bnode instanceof AndNode )
+//        {
+//            for ( ExprNode child:bnode.getChildren() )
+//            {
+//                if ( !evaluate( child, entry ) )
+//                {
+//                    return false;
+//                }
+//            }
+//
+//            return true;
+//        }
+//        else if ( bnode instanceof NotNode )
+//        {
+//            if ( null != bnode.getFirstChild() )
+//            {
+//                return !evaluate( bnode.getFirstChild(), entry );
+//            }
+//
+//            throw new NamingException( "Negation has no child: " + node );
+//        }
+//        else
+//        {
+//                throw new NamingException( "Unrecognized branch node operator: " + bnode
);
+//        }
     }
 }



Mime
View raw message