You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/05/14 00:48:43 UTC
svn commit: r656041 - in /directory/apacheds/branches/bigbang:
btree-base/src/main/java/org/apache/directory/server/xdbm/
btree-base/src/main/java/org/apache/directory/server/xdbm/search/
xdbm-search/src/main/java/org/apache/directory/server/xdbm/searc...
Author: akarasulu
Date: Tue May 13 15:48:42 2008
New Revision: 656041
URL: http://svn.apache.org/viewvc?rev=656041&view=rev
Log:
fixing some generics issues and class cast exceptions due to use of Value instead of raw wrapped value - all tests in NestedFilterTest now pass
Modified:
directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/Optimizer.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NoOpOptimizer.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java Tue May 13 15:48:42 2008
@@ -130,7 +130,7 @@
* @return the normalized value.
* @throws Exception if something goes wrong.
*/
- K getNormalized( K attrVal ) throws Exception;
+ <K> K getNormalized( K attrVal ) throws Exception;
/**
@@ -150,28 +150,28 @@
* @return the number of key/value pairs in this index with the value value
* @throws Exception on failure to access index db files
*/
- int count( K attrVal ) throws Exception;
+ <K> int count( K attrVal ) throws Exception;
- int greaterThanCount( K attrVal ) throws Exception;
+ <K> int greaterThanCount( K attrVal ) throws Exception;
- int lessThanCount( K attrVal ) throws Exception;
+ <K> int lessThanCount( K attrVal ) throws Exception;
- Long forwardLookup( K attrVal ) throws Exception;
+ <K> Long forwardLookup( K attrVal ) throws Exception;
K reverseLookup( Long id ) throws Exception;
- void add( K attrVal, Long id ) throws Exception;
+ <K> void add( K attrVal, Long id ) throws Exception;
void drop( Long id ) throws Exception;
- void drop( K attrVal, Long id ) throws Exception;
+ <K> void drop( K attrVal, Long id ) throws Exception;
IndexCursor<K, O> reverseCursor() throws Exception;
@@ -183,49 +183,49 @@
IndexCursor<K, O> reverseCursor( Long id ) throws Exception;
- IndexCursor<K, O> forwardCursor( K key ) throws Exception;
+ <K> IndexCursor<K, O> forwardCursor( K key ) throws Exception;
Cursor<K> reverseValueCursor( Long id ) throws Exception;
- Cursor<Long> forwardValueCursor( K key ) throws Exception;
+ <K> Cursor<Long> forwardValueCursor( K key ) throws Exception;
- boolean forward( K attrVal ) throws Exception;
+ <K> boolean forward( K attrVal ) throws Exception;
- boolean forward( K attrVal, Long id ) throws Exception;
+ <K> boolean forward( K attrVal, Long id ) throws Exception;
boolean reverse( Long id ) throws Exception;
- boolean reverse( Long id, K attrVal ) throws Exception;
+ <K> boolean reverse( Long id, K attrVal ) throws Exception;
- boolean forwardGreaterOrEq( K attrVal ) throws Exception;
+ <K> boolean forwardGreaterOrEq( K attrVal ) throws Exception;
- boolean forwardGreaterOrEq( K attrVal, Long id ) throws Exception;
+ <K> boolean forwardGreaterOrEq( K attrVal, Long id ) throws Exception;
boolean reverseGreaterOrEq( Long id ) throws Exception;
- boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception;
+ <K> boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception;
- boolean forwardLessOrEq( K attrVal ) throws Exception;
+ <K> boolean forwardLessOrEq( K attrVal ) throws Exception;
- boolean forwardLessOrEq( K attrVal, Long id ) throws Exception;
+ <K> boolean forwardLessOrEq( K attrVal, Long id ) throws Exception;
boolean reverseLessOrEq( Long id ) throws Exception;
- boolean reverseLessOrEq( Long id, K attrVal ) throws Exception;
+ <K> boolean reverseLessOrEq( Long id, K attrVal ) throws Exception;
void close() throws Exception;
Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/Optimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/Optimizer.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/Optimizer.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/Optimizer.java Tue May 13 15:48:42 2008
@@ -42,5 +42,5 @@
* @param node the root of the expression node tree
* @throws Exception if there are failures while optimizing
*/
- void annotate( ExprNode node ) throws Exception;
+ Long annotate( ExprNode node ) throws Exception;
}
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Tue May 13 15:48:42 2008
@@ -75,7 +75,7 @@
*
* @see org.apache.directory.server.xdbm.search.Optimizer#annotate(ExprNode)
*/
- public void annotate( ExprNode node ) throws Exception
+ public Long annotate( ExprNode node ) throws Exception
{
// Start off with the worst case unless scan count says otherwise.
Long count = Long.MAX_VALUE;
@@ -160,6 +160,8 @@
}
else if ( node instanceof NotNode )
{
+ annotate( ( ( NotNode ) node ).getFirstChild() );
+
/*
* A negation filter is always worst case since we will have
* to retrieve all entries from the master table then test
@@ -181,6 +183,7 @@
}
node.set( "count", count );
+ return count;
}
@@ -248,7 +251,7 @@
{
//noinspection unchecked
Index<Object,E> idx = db.getUserIndex( node.getAttribute() );
- return idx.count( node.getValue() );
+ return idx.count( node.getValue().get() );
}
// count for non-indexed attribute is unknown so we presume da worst
@@ -273,11 +276,11 @@
Index<Object, E> idx = db.getUserIndex( node.getAttribute() );
if ( isGreaterThan )
{
- return idx.greaterThanCount( node.getValue() );
+ return idx.greaterThanCount( node.getValue().get() );
}
else
{
- return idx.lessThanCount( node.getValue() );
+ return idx.lessThanCount( node.getValue().get() );
}
}
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java Tue May 13 15:48:42 2008
@@ -61,7 +61,7 @@
this.equalityEvaluator = equalityEvaluator;
String attribute = equalityEvaluator.getExpression().getAttribute();
- Object value = equalityEvaluator.getExpression().getValue();
+ Object value = equalityEvaluator.getExpression().getValue().get();
if ( db.hasUserIndexOn( attribute ) )
{
//noinspection unchecked
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java Tue May 13 15:48:42 2008
@@ -52,7 +52,7 @@
private final AttributeType type;
private final Normalizer normalizer;
private final Comparator comparator;
- private final Index<Number,ServerEntry> idx;
+ private final Index<?,ServerEntry> idx;
public EqualityEvaluator( EqualityNode node, Store<ServerEntry> db, Registries registries )
@@ -99,7 +99,7 @@
{
if ( idx != null )
{
- return idx.forward( ( Number ) indexEntry.getValue(), indexEntry.getId() );
+ return idx.forward( indexEntry.getValue(), indexEntry.getId() );
}
ServerEntry entry = indexEntry.getObject();
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NoOpOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NoOpOptimizer.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NoOpOptimizer.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NoOpOptimizer.java Tue May 13 15:48:42 2008
@@ -39,19 +39,19 @@
/** the maximum size for a count Integer.MAX_VALUE as a BigInteger */
private static final Long MAX = Long.MAX_VALUE;
- public void annotate( ExprNode node ) throws NamingException
+ public Long annotate( ExprNode node ) throws NamingException
{
if ( node.isLeaf() )
{
node.set( "count", MAX );
- return;
+ return MAX;
}
BranchNode bnode = ( BranchNode ) node;
if ( bnode.getChildren().size() == 0 )
{
bnode.set( "count", MAX );
- return;
+ return MAX;
}
final int limit = bnode.getChildren().size();
@@ -69,5 +69,6 @@
}
bnode.set( "count", MAX );
+ return MAX;
}
}
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java Tue May 13 15:48:42 2008
@@ -73,8 +73,8 @@
{
public int compare( Evaluator<? extends ExprNode, ServerEntry> e1, Evaluator<? extends ExprNode, ServerEntry> e2 )
{
- int scanCount1 = ( Integer ) e1.getExpression().get( "count" );
- int scanCount2 = ( Integer ) e2.getExpression().get( "count" );
+ long scanCount1 = ( Long ) e1.getExpression().get( "count" );
+ long scanCount2 = ( Long ) e2.getExpression().get( "count" );
if ( scanCount1 == scanCount2 )
{
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java?rev=656041&r1=656040&r2=656041&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java Tue May 13 15:48:42 2008
@@ -142,7 +142,6 @@
}
- @Ignore ( "fails with ClassCast ex at line 59 in DeepTrimToLowerNormalizer" )
@Test
public void testNestedAndnOr() throws Exception
{
@@ -172,7 +171,6 @@
}
- @Ignore ( "fails with ClassCast ex at line 102 in EqualityEvaluator" )
@Test
public void testNestedAndnNot() throws Exception
{
@@ -192,7 +190,6 @@
}
- @Ignore ( "fails with ClassCast ex at line 102 in EqualityEvaluator" )
@Test
public void testNestedNotnOrnAnd() throws Exception
{
@@ -210,14 +207,13 @@
assertTrue( cursor.next() );
assertTrue( cursor.available() );
- assertEquals( 9, ( long ) cursor.get().getId() );
+ assertEquals( 8, ( long ) cursor.get().getId() );
assertEquals( "2.5.4.3=jack daniels,2.5.4.11=engineering,2.5.4.10=good times co.", cursor.get().getValue() );
assertFalse( cursor.next() );
}
- @Ignore
@Test
public void testNestedOrnNot() throws Exception
{