Author: elecharny
Date: Thu Apr 26 17:43:10 2012
New Revision: 1330989
URL: http://svn.apache.org/viewvc?rev=1330989&view=rev
Log:
o Propagated the ID in the ScopeNode, to avoid recomputing it in two other places
o Fixed the tests accordingly
Modified:
directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ScopeNode.java
Modified: directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
(original)
+++ directory/apacheds/branches/index-work/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchPerfIT.java
Thu Apr 26 17:43:10 2012
@@ -180,7 +180,7 @@ public class SearchPerfIT extends Abstra
assertEquals( 10, i );
- int nbIterations = 15000000;
+ int nbIterations = 1500000;
long t0 = System.currentTimeMillis();
long t00 = 0L;
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
Thu Apr 26 17:43:10 2012
@@ -122,7 +122,7 @@ public class DefaultOptimizer<E, ID exte
if ( node instanceof ScopeNode )
{
- count = getScopeScan( ( ScopeNode ) node );
+ count = getScopeScan( ( ScopeNode<ID> ) node );
}
else if ( node instanceof AssertionNode )
{
@@ -210,6 +210,7 @@ public class DefaultOptimizer<E, ID exte
}
node.set( "count", count );
+
return count;
}
@@ -370,9 +371,9 @@ public class DefaultOptimizer<E, ID exte
* @return the scan count for scope
* @throws Exception if any errors result
*/
- private long getScopeScan( ScopeNode node ) throws Exception
+ private long getScopeScan( ScopeNode<ID> node ) throws Exception
{
- ID id = db.getEntryId( node.getBaseDn() );
+ ID id = node.getBaseId();
switch ( node.getScope() )
{
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
Thu Apr 26 17:43:10 2012
@@ -149,15 +149,15 @@ public class DefaultSearchEngine<ID exte
// --------------------------------------------------------------------
// Specifically Handle Object Level Scope
// --------------------------------------------------------------------
+ ID effectiveBaseId = baseId;
+
+ if ( effectiveBase != base )
+ {
+ effectiveBaseId = db.getEntryId( effectiveBase );
+ }
if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
{
- ID effectiveBaseId = baseId;
- if ( effectiveBase != base )
- {
- effectiveBaseId = db.getEntryId( effectiveBase );
- }
-
IndexEntry<ID, ID> indexEntry = new ForwardIndexEntry<ID, ID>();
indexEntry.setId( effectiveBaseId );
optimizer.annotate( filter );
@@ -175,13 +175,14 @@ public class DefaultSearchEngine<ID exte
// Add the scope node using the effective base to the filter
BranchNode root = new AndNode();
- ExprNode node = new ScopeNode( aliasDerefMode, effectiveBase, SearchScope.getSearchScope(
searchCtls
+ ExprNode node = new ScopeNode<ID>( aliasDerefMode, effectiveBase, effectiveBaseId,
SearchScope.getSearchScope( searchCtls
.getSearchScope() ) );
root.getChildren().add( node );
root.getChildren().add( filter );
// Annotate the node with the optimizer and return search enumeration.
optimizer.annotate( root );
+
return ( IndexCursor<ID, Entry, ID> ) cursorBuilder.build( root );
}
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
Thu Apr 26 17:43:10 2012
@@ -91,13 +91,13 @@ public class EvaluatorBuilder<ID extends
return new PresenceEvaluator<ID>( ( PresenceNode ) node, db, schemaManager
);
case SCOPE:
- if ( ( ( ScopeNode ) node ).getScope() == SearchScope.ONELEVEL )
+ if ( ( ( ScopeNode<ID> ) node ).getScope() == SearchScope.ONELEVEL
)
{
- return new OneLevelScopeEvaluator<Entry, ID>( db, ( ScopeNode )
node );
+ return new OneLevelScopeEvaluator<Entry, ID>( db, ( ScopeNode<ID>
) node );
}
else
{
- return new SubtreeScopeEvaluator<Entry, ID>( db, ( ScopeNode )
node );
+ return new SubtreeScopeEvaluator<Entry, ID>( db, ( ScopeNode<ID>
) node );
}
case SUBSTRING:
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
Thu Apr 26 17:43:10 2012
@@ -56,7 +56,7 @@ public class OneLevelScopeEvaluator<E, I
* @param db the database used to evaluate scope node
* @throws Exception on db access failure
*/
- public OneLevelScopeEvaluator( Store<E, ID> db, ScopeNode node ) throws Exception
+ public OneLevelScopeEvaluator( Store<E, ID> db, ScopeNode<ID> node ) throws
Exception
{
this.node = node;
@@ -66,7 +66,7 @@ public class OneLevelScopeEvaluator<E, I
}
this.db = db;
- baseId = db.getEntryId( node.getBaseDn() );
+ baseId = node.getBaseId();
dereferencing = node.getDerefAliases().isDerefInSearching() || node.getDerefAliases().isDerefAlways();
}
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
Thu Apr 26 17:43:10 2012
@@ -70,7 +70,7 @@ public class SubtreeScopeEvaluator<E, ID
* @param db the database used to evaluate scope node
* @throws Exception on db access failure
*/
- public SubtreeScopeEvaluator( Store<E, ID> db, ScopeNode node ) throws Exception
+ public SubtreeScopeEvaluator( Store<E, ID> db, ScopeNode<ID> node ) throws
Exception
{
this.db = db;
this.node = node;
@@ -80,7 +80,7 @@ public class SubtreeScopeEvaluator<E, ID
throw new IllegalStateException( I18n.err( I18n.ERR_727 ) );
}
- baseId = db.getEntryId( node.getBaseDn() );
+ baseId = node.getBaseId();
baseIsContextEntry = getContextEntryId() == baseId;
dereferencing = node.getDerefAliases().isDerefInSearching() || node.getDerefAliases().isDerefAlways();
}
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
Thu Apr 26 17:43:10 2012
@@ -159,8 +159,12 @@ public class OneLevelScopeTest
@Test
public void testCursorNoDeref() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store,
evaluator );
@@ -349,8 +353,13 @@ public class OneLevelScopeTest
@Test
public void testCursorNoDerefReturnAliases() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=engineering," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=engineering,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store,
evaluator );
@@ -533,8 +542,11 @@ public class OneLevelScopeTest
@Test
public void testCursorWithDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
- + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_IN_SEARCHING,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store,
evaluator );
@@ -666,9 +678,14 @@ public class OneLevelScopeTest
@Test
public void testCursorWithDereferencing2() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
- + "=apache," + SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
- + "=good times co." ), SearchScope.ONELEVEL );
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=apache," + SchemaConstants.OU_AT_OID
+ + "=board of directors,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_IN_SEARCHING,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store,
evaluator );
@@ -793,8 +810,13 @@ public class OneLevelScopeTest
addContext = new AddOperationContext( null, entry );
( ( Partition ) store ).add( addContext );
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
- + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=board of directors,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_IN_SEARCHING,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store,
evaluator );
@@ -1034,8 +1056,12 @@ public class OneLevelScopeTest
@Test
public void testEvaluatorNoDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
@@ -1048,8 +1074,13 @@ public class OneLevelScopeTest
@Test
public void testEvaluatorWithDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_ALWAYS, new Dn( SchemaConstants.OU_AT_OID
- + "=engineering," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=engineering,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_ALWAYS,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
assertEquals( node, evaluator.getExpression() );
@@ -1081,11 +1112,15 @@ public class OneLevelScopeTest
public void testInvalidCursorPositionException() throws Exception
{
OneLevelScopeCursor<Long> cursor = null;
-
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -1102,11 +1137,15 @@ public class OneLevelScopeTest
public void testUnsupportBeforeWithoutIndex() throws Exception
{
OneLevelScopeCursor<Long> cursor = null;
-
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -1127,11 +1166,14 @@ public class OneLevelScopeTest
public void testUnsupportAfterWithoutIndex() throws Exception
{
OneLevelScopeCursor<Long> cursor = null;
-
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.ONELEVEL );
OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry,
Long>( store,
node );
cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -1151,8 +1193,13 @@ public class OneLevelScopeTest
@Test(expected = IllegalStateException.class)
public void testIllegalStateBadScope() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales,"
+ + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.SUBTREE );
new OneLevelScopeEvaluator<Entry, Long>( store, node );
}
}
\ No newline at end of file
Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
Thu Apr 26 17:43:10 2012
@@ -161,9 +161,10 @@ public class SubtreeScopeTest
@Test
public void testCursorNoDeref() throws Exception
{
- ScopeNode node = new ScopeNode(
- AliasDerefMode.NEVER_DEREF_ALIASES,
- new Dn( SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
+ "=good times co." ),
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
+ "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId,
SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store,
evaluator );
@@ -265,8 +266,11 @@ public class SubtreeScopeTest
@Test
public void testCursorWithDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
- + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_IN_SEARCHING,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store,
evaluator );
@@ -458,9 +462,13 @@ public class SubtreeScopeTest
@Test
public void testCursorWithDereferencing2() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
- + "=apache," + SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
- + "=good times co." ), SearchScope.SUBTREE );
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=apache," + SchemaConstants.OU_AT_OID
+ + "=board of directors," + SchemaConstants.O_AT_OID
+ + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_IN_SEARCHING,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store,
evaluator );
@@ -617,9 +625,13 @@ public class SubtreeScopeTest
addContext = new AddOperationContext( null, entry );
( ( Partition ) store ).add( addContext );
- ScopeNode node = new ScopeNode(
+ dn = new Dn( SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
+ "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>(
AliasDerefMode.DEREF_IN_SEARCHING,
- new Dn( SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID
+ "=good times co." ),
+ dn,
+ baseId,
SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store,
evaluator );
@@ -831,8 +843,11 @@ public class SubtreeScopeTest
@Test
public void testEvaluatorNoDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
ForwardIndexEntry<Long, Long> indexEntry = new ForwardIndexEntry<Long, Long>();
@@ -844,8 +859,11 @@ public class SubtreeScopeTest
@Test
public void testEvaluatorWithDereferencing() throws Exception
{
- ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_ALWAYS, new Dn( SchemaConstants.OU_AT_OID
- + "=engineering," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=engineering," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.DEREF_ALWAYS,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
assertEquals( node, evaluator.getExpression() );
@@ -871,11 +889,12 @@ public class SubtreeScopeTest
public void testInvalidCursorPositionException() throws Exception
{
SubtreeScopeCursor<Long> cursor = null;
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID + "=sales," + SchemaConstants.O_AT_OID
+ "=good times co." );
+ long baseId = store.getEntryId( dn );
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
cursor = new SubtreeScopeCursor<Long>( store, evaluator );
cursor.get();
@@ -891,11 +910,13 @@ public class SubtreeScopeTest
public void testUnsupportBeforeWithoutIndex() throws Exception
{
SubtreeScopeCursor<Long> cursor = null;
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
cursor = new SubtreeScopeCursor<Long>( store, evaluator );
@@ -915,11 +936,13 @@ public class SubtreeScopeTest
public void testUnsupportAfterWithoutIndex() throws Exception
{
SubtreeScopeCursor<Long> cursor = null;
-
+ Dn dn = new Dn( SchemaConstants.OU_AT_OID
+ + "=sales," + SchemaConstants.O_AT_OID + "=good times co." );
+ long baseId = store.getEntryId( dn );
+
try
{
- ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE
);
+ ScopeNode<Long> node = new ScopeNode<Long>( AliasDerefMode.NEVER_DEREF_ALIASES,
dn, baseId, SearchScope.SUBTREE );
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
cursor = new SubtreeScopeCursor<Long>( store, evaluator );
@@ -939,7 +962,7 @@ public class SubtreeScopeTest
public void testIllegalStateBadScope() throws Exception
{
ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
- + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL
);
+ + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), null, SearchScope.ONELEVEL
);
SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry,
Long>( store, node );
assertNull( evaluator );
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ScopeNode.java?rev=1330989&r1=1330988&r2=1330989&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ScopeNode.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ScopeNode.java
Thu Apr 26 17:43:10 2012
@@ -31,7 +31,7 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ScopeNode extends AbstractExprNode
+public class ScopeNode<ID> extends AbstractExprNode
{
/** the scope of this node */
private final SearchScope scope;
@@ -39,6 +39,9 @@ public class ScopeNode extends AbstractE
/** the search base */
private final Dn baseDn;
+ /** the search ID */
+ private final ID baseId;
+
/** the alias dereferencing mode */
private final AliasDerefMode aliasDerefAliases;
@@ -50,12 +53,13 @@ public class ScopeNode extends AbstractE
* @param baseDn the search base
* @param scope the search scope
*/
- public ScopeNode( AliasDerefMode aliasDerefAliases, Dn baseDn, SearchScope scope )
+ public ScopeNode( AliasDerefMode aliasDerefAliases, Dn baseDn, ID baseId, SearchScope
scope )
{
super( AssertionType.SCOPE );
this.scope = scope;
this.baseDn = baseDn;
this.aliasDerefAliases = aliasDerefAliases;
+ this.baseId = baseId;
isSchemaAware = true;
}
@@ -95,6 +99,17 @@ public class ScopeNode extends AbstractE
/**
+ * Gets the base ID.
+ *
+ * @return the base ID
+ */
+ public ID getBaseId()
+ {
+ return baseId;
+ }
+
+
+ /**
* Gets the alias dereferencing mode type safe enumeration.
*
* @return the alias dereferencing enumeration constant.
|