1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.xdbm.search.impl;
21
22
23 import org.apache.directory.api.ldap.model.exception.LdapException;
24 import org.apache.directory.api.ldap.model.filter.BranchNode;
25 import org.apache.directory.api.ldap.model.filter.ExprNode;
26 import org.apache.directory.server.core.api.partition.PartitionTxn;
27 import org.apache.directory.server.xdbm.search.Optimizer;
28
29
30
31
32
33
34
35
36
37 public class NoOpOptimizer implements Optimizer
38 {
39
40 private static final Long MAX = Long.MAX_VALUE;
41
42
43 public Long annotate( PartitionTxn partitionTxn, ExprNode node ) throws LdapException
44 {
45 if ( node.isLeaf() )
46 {
47 node.set( DefaultOptimizer.COUNT_ANNOTATION, MAX );
48 return MAX;
49 }
50
51 BranchNode bnode = ( BranchNode ) node;
52
53 if ( bnode.getChildren().isEmpty() )
54 {
55 bnode.set( DefaultOptimizer.COUNT_ANNOTATION, MAX );
56 return MAX;
57 }
58
59 final int limit = bnode.getChildren().size();
60 for ( int ii = 0; ii < limit; ii++ )
61 {
62 ExprNode child = bnode.getChildren().get( ii );
63 if ( child.isLeaf() )
64 {
65 child.set( DefaultOptimizer.COUNT_ANNOTATION, MAX );
66 }
67 else
68 {
69 annotate( partitionTxn, child );
70 }
71 }
72
73 bnode.set( DefaultOptimizer.COUNT_ANNOTATION, MAX );
74 return MAX;
75 }
76 }