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/21 20:26:32 UTC
svn commit: r658798 - 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/ core/
core/src/main/java/org/apache/directory/server/core/ core/...
Author: akarasulu
Date: Wed May 21 11:26:31 2008
New Revision: 658798
URL: http://svn.apache.org/viewvc?rev=658798&view=rev
Log:
fixing some issues with generics and correcting compilation issues with Cursor returns on search
Added:
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java
Removed:
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResult.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreeSearchResultEnumeration.java
Modified:
directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java
directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java
directory/apacheds/branches/bigbang/core/pom.xml
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java
directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Store.java Wed May 21 11:26:31 2008
@@ -20,10 +20,7 @@
package org.apache.directory.server.xdbm;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
@@ -117,7 +114,7 @@
void setUserIndices( Set<Index<?,E>> userIndices );
- Set<Index> getUserIndices();
+ Set<Index<?,E>> getUserIndices();
void setContextEntry( ServerEntry contextEntry );
@@ -186,7 +183,7 @@
void sync() throws Exception;
- void addIndex( Index index ) throws Exception;
+ void addIndex( Index<?,E> index ) throws Exception;
Index<String,E> getPresenceIndex();
@@ -249,10 +246,10 @@
boolean hasSystemIndexOn( String id ) throws Exception;
- Index getUserIndex( String id ) throws IndexNotFoundException;
+ Index<?,E> getUserIndex( String id ) throws IndexNotFoundException;
- Index getSystemIndex( String id ) throws IndexNotFoundException;
+ Index<?,E> getSystemIndex( String id ) throws IndexNotFoundException;
Long getEntryId( String dn ) throws Exception;
@@ -302,7 +299,7 @@
* @return an IndexEntry Cursor over the child entries
* @throws Exception on failures to access the underlying store
*/
- Cursor<IndexEntry<Long,E>> list( Long id ) throws Exception;
+ IndexCursor<Long,E> list( Long id ) throws Exception;
int getChildCount( Long id ) throws Exception;
Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java Wed May 21 11:26:31 2008
@@ -24,9 +24,7 @@
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.message.AliasDerefMode;
import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.IndexCursor;
-import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.entry.ServerEntry;
import javax.naming.directory.SearchControls;
@@ -86,7 +84,7 @@
* @return enumeration over SearchResults
* @throws Exception if the search fails
*/
- IndexCursor<?,E> cursor( LdapDN base,
+ IndexCursor<Long,E> cursor( LdapDN base,
AliasDerefMode aliasDerefMode,
ExprNode filter,
SearchControls searchCtls ) throws Exception;
Modified: directory/apacheds/branches/bigbang/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/pom.xml?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/pom.xml (original)
+++ directory/apacheds/branches/bigbang/core/pom.xml Wed May 21 11:26:31 2008
@@ -45,6 +45,12 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-xdbm-search</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-schema-bootstrap</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed May 21 11:26:31 2008
@@ -523,7 +523,7 @@
}
- public void removePartition( Partition partition ) throws NamingException
+ public void removePartition( Partition partition ) throws Exception
{
partitions.remove( partition );
@@ -539,7 +539,7 @@
// ------------------------------------------------------------------------
- // BackendSubsystem Interface Method Implemetations
+ // BackendSubsystem Interface Method Implementations
// ------------------------------------------------------------------------
@@ -628,7 +628,7 @@
}
- public long revert() throws NamingException
+ public long revert() throws Exception
{
if ( changeLog == null || ! changeLog.isEnabled() )
{
@@ -653,7 +653,7 @@
}
- public long revert( long revision ) throws NamingException
+ public long revert( long revision ) throws Exception
{
if ( changeLog == null || ! changeLog.isEnabled() )
{
@@ -739,7 +739,7 @@
/**
* @throws NamingException if the LDAP server cannot be started
*/
- public synchronized void startup() throws NamingException
+ public synchronized void startup() throws Exception
{
if ( started )
{
@@ -1277,7 +1277,7 @@
*
* @throws javax.naming.NamingException if there are problems along the way
*/
- private void initialize() throws NamingException
+ private void initialize() throws Exception
{
if ( LOG.isDebugEnabled() )
{
@@ -1325,7 +1325,7 @@
ResultCodeEnum.OTHER );
}
- Set<Index> indexedAttributes = new HashSet<Index>();
+ Set<Index<Object,ServerEntry>> indexedAttributes = new HashSet<Index<Object,ServerEntry>>();
for ( String attributeId : listing.getIndexedAttributes() )
{
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Wed May 21 11:26:31 2008
@@ -35,7 +35,6 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.ldap.LdapContext;
import java.io.File;
@@ -62,13 +61,13 @@
* @param revision the revision number to revert to
* @return the new revision reached by applying all changes needed to revert to the
* original state
- * @throws NamingException if there are problems reverting back to the earlier state
+ * @throws Exception if there are problems reverting back to the earlier state
* @throws IllegalArgumentException if the revision provided is greater than the current
* revision or less than 0
* @throws UnsupportedOperationException if this feature is not supported by the
* change log
*/
- long revert( long revision ) throws NamingException;
+ long revert( long revision ) throws Exception;
/**
@@ -81,11 +80,11 @@
* @return the new revision reached by applying all changes needed to revert
* to the new state or the same version before this call if no revert actually
* took place
- * @throws NamingException if there are problems reverting back to the earlier state
+ * @throws Exception if there are problems reverting back to the earlier state
* @throws UnsupportedOperationException if this feature is not supported by the
* change log
*/
- long revert() throws NamingException;
+ long revert() throws Exception;
PartitionNexus getPartitionNexus();
@@ -94,10 +93,10 @@
InterceptorChain getInterceptorChain();
- void addPartition( Partition partition ) throws NamingException;
+ void addPartition( Partition partition ) throws Exception;
- void removePartition( Partition partition ) throws NamingException;
+ void removePartition( Partition partition ) throws Exception;
Registries getRegistries();
@@ -115,24 +114,24 @@
/**
* Starts up this service.
*
- * @throws NamingException if failed to start up
+ * @throws Exception if failed to start up
*/
- void startup() throws NamingException;
+ void startup() throws Exception;
/**
* Shuts down this service.
*
- * @throws NamingException if failed to shut down
+ * @throws Exception if failed to shut down
*/
- void shutdown() throws NamingException;
+ void shutdown() throws Exception;
/**
* Calls {@link Partition#sync()} for all registered {@link Partition}s.
- * @throws NamingException if synchronization failed
+ * @throws Exception if synchronization failed
*/
- void sync() throws NamingException;
+ void sync() throws Exception;
/**
@@ -147,9 +146,9 @@
* This bypasses authentication within the server.
*
* @return a JNDI context to the RootDSE
- * @throws NamingException if failed to create a context
+ * @throws Exception if failed to create a context
*/
- LdapContext getJndiContext() throws NamingException;
+ LdapContext getJndiContext() throws Exception;
/**
@@ -158,9 +157,9 @@
*
* @param dn the distinguished name of the entry
* @return a JNDI context to the entry at the specified DN
- * @throws NamingException if failed to create a context
+ * @throws Exception if failed to create a context
*/
- LdapContext getJndiContext( String dn ) throws NamingException;
+ LdapContext getJndiContext( String dn ) throws Exception;
/**
@@ -169,9 +168,9 @@
*
* @param principal the user to associate with the context
* @return a JNDI context to the RootDSE as a specific user
- * @throws NamingException if failed to create a context
+ * @throws Exception if failed to create a context
*/
- LdapContext getJndiContext( LdapPrincipal principal ) throws NamingException;
+ LdapContext getJndiContext( LdapPrincipal principal ) throws Exception;
/**
@@ -181,9 +180,9 @@
* @param principal the user to associate with the context
* @param dn the distinguished name of the entry
* @return a JNDI context to the specified entry as a specific user
- * @throws NamingException if failed to create a context
+ * @throws Exception if failed to create a context
*/
- LdapContext getJndiContext( LdapPrincipal principal, String dn ) throws NamingException;
+ LdapContext getJndiContext( LdapPrincipal principal, String dn ) throws Exception;
/**
@@ -197,10 +196,10 @@
* @param authentication {@link Context#SECURITY_AUTHENTICATION} value
* @param dn the distinguished name of the entry
* @return a JNDI context to the specified entry as a specific user
- * @throws NamingException if failed to create a context
+ * @throws Exception if failed to create a context
*/
LdapContext getJndiContext( LdapDN principalDn, String principal, byte[] credential,
- String authentication, String dn ) throws NamingException;
+ String authentication, String dn ) throws Exception;
void setInstanceId( String instanceId );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java Wed May 21 11:26:31 2008
@@ -153,7 +153,7 @@
/**
* Deinitialized this partition.
*/
- void destroy();
+ void destroy() throws Exception;
/**
@@ -239,7 +239,7 @@
* @return a NamingEnumeration containing objects of type {@link ServerSearchResult}
* @throws Exception if there are any problems
*/
- Cursor<ServerSearchResult> list( ListOperationContext opContext ) throws Exception;
+ Cursor<ServerEntry> list( ListOperationContext opContext ) throws Exception;
/**
@@ -256,7 +256,7 @@
* <a href="http://java.sun.com/j2se/1.4.2/docs/api/
* javax/naming/directory/SearchResult.html">SearchResult</a>.
*/
- Cursor<ServerSearchResult> search( SearchOperationContext opContext )
+ Cursor<ServerEntry> search( SearchOperationContext opContext )
throws Exception;
@@ -273,6 +273,10 @@
* @throws Exception if there are any problems
*/
ServerEntry lookup( LookupOperationContext lookupContext ) throws Exception;
+
+
+ ServerEntry lookup( Long id ) throws Exception;
+
/**
* Fast operation to check and see if a particular entry exists.
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Wed May 21 11:26:31 2008
@@ -22,8 +22,6 @@
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerSearchResult;
-import org.apache.directory.server.core.enumeration.SearchResultEnumeration;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
@@ -78,7 +76,7 @@
}
/** the search engine used to search the database */
- protected SearchEngine searchEngine;
+ protected SearchEngine<ServerEntry> searchEngine;
protected Optimizer optimizer;
protected Registries registries;
@@ -208,8 +206,9 @@
* since the registries are used by elements in the search engine.
*
* @param registries the schema entity registries
+ * @throws Exception
*/
- public abstract void setRegistries( Registries registries );
+ public abstract void setRegistries( Registries registries ) throws Exception;
// ------------------------------------------------------------------------
@@ -222,7 +221,7 @@
*
* @return the search engine
*/
- public SearchEngine getSearchEngine()
+ public SearchEngine<ServerEntry> getSearchEngine()
{
return searchEngine;
}
@@ -263,23 +262,16 @@
public abstract void modify( ModifyOperationContext opContext ) throws Exception;
- private static final String[] ENTRY_DELETED_ATTRS = new String[] { "entrydeleted" };
-
-
- public Cursor<ServerSearchResult> list( ListOperationContext opContext ) throws Exception
+ public Cursor<ServerEntry> list( ListOperationContext opContext ) throws Exception
{
- SearchResultEnumeration list;
- list = new BTreeSearchResultEnumeration( ENTRY_DELETED_ATTRS, list( getEntryId( opContext.getDn().getNormName() ) ),
- this, registries );
- return list;
+ return new ServerEntryCursorAdaptor( this, list( getEntryId( opContext.getDn().getNormName() ) ) );
}
- public Cursor<ServerSearchResult> search( SearchOperationContext opContext ) throws Exception
+ public Cursor<ServerEntry> search( SearchOperationContext opContext ) throws Exception
{
SearchControls searchCtls = opContext.getSearchControls();
- String[] attrIds = searchCtls.getReturningAttributes();
- Cursor<IndexEntry> underlying;
+ IndexCursor<Long,ServerEntry> underlying;
underlying = searchEngine.cursor(
opContext.getDn(),
@@ -287,7 +279,7 @@
opContext.getFilter(),
searchCtls );
- return new BTreeSearchResultEnumeration( attrIds, underlying, this, registries );
+ return new ServerEntryCursorAdaptor( this, underlying );
}
@@ -334,7 +326,7 @@
public abstract void sync() throws Exception;
- public abstract void destroy();
+ public abstract void destroy() throws Exception;
public abstract boolean isInitialized();
@@ -354,7 +346,7 @@
// Index Operations
// ------------------------------------------------------------------------
- public abstract void addIndexOn( Index index ) throws Exception;
+ public abstract void addIndexOn( Index<Long,ServerEntry> index ) throws Exception;
public abstract boolean hasUserIndexOn( String attribute ) throws Exception;
@@ -363,16 +355,25 @@
public abstract boolean hasSystemIndexOn( String attribute ) throws Exception;
- public abstract Index getExistanceIndex();
+ public abstract Index<String,ServerEntry> getPresenceIndex();
+
+
+ /**
+ * Gets the Index mapping the Long primary keys of parents to the
+ * Long primary keys of their children.
+ *
+ * @return the one level Index
+ */
+ public abstract Index<Long,ServerEntry> getOneLevelIndex();
/**
- * Gets the Index mapping the BigInteger primary keys of parents to the
- * BigInteger primary keys of their children.
+ * Gets the Index mapping the Long primary keys of ancestors to the
+ * Long primary keys of their descendants.
*
- * @return the hierarchy Index
+ * @return the sub tree level Index
*/
- public abstract Index getHierarchyIndex();
+ public abstract Index<Long,ServerEntry> getSubLevelIndex();
/**
@@ -381,7 +382,7 @@
*
* @return the user provided distinguished name Index
*/
- public abstract Index getUpdnIndex();
+ public abstract Index<String,ServerEntry> getUpdnIndex();
/**
@@ -390,7 +391,7 @@
*
* @return the normalized distinguished name Index
*/
- public abstract Index getNdnIndex();
+ public abstract Index<String,ServerEntry> getNdnIndex();
/**
@@ -400,7 +401,7 @@
*
* @return the one alias index
*/
- public abstract Index getOneAliasIndex();
+ public abstract Index<Long,ServerEntry> getOneAliasIndex();
/**
@@ -410,7 +411,7 @@
*
* @return the sub alias index
*/
- public abstract Index getSubAliasIndex();
+ public abstract Index<Long,ServerEntry> getSubAliasIndex();
/**
@@ -419,7 +420,7 @@
*
* @return the index on the ALIAS_ATTRIBUTE
*/
- public abstract Index getAliasIndex();
+ public abstract Index<String,ServerEntry> getAliasIndex();
/**
@@ -429,7 +430,7 @@
* @param index the index on the ALIAS_ATTRIBUTE
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setAliasIndexOn( Index index ) throws Exception;
+ public abstract void setAliasIndexOn( Index<String,ServerEntry> index ) throws Exception;
/**
@@ -438,17 +439,18 @@
* @param index the attribute existance Index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setExistanceIndexOn( Index index ) throws Exception;
+ public abstract void setPresenceIndexOn( Index<String,ServerEntry> index ) throws Exception;
/**
- * Sets the hierarchy Index.
+ * Sets the one level Index.
*
- * @param index the hierarchy Index
+ * @param index the one level Index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setHierarchyIndexOn( Index index ) throws Exception;
+ public abstract void setOneLevelIndexOn( Index<Long,ServerEntry> index ) throws Exception;
+ // TODO - add sub level index setter
/**
* Sets the user provided distinguished name Index.
@@ -456,7 +458,7 @@
* @param index the updn Index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setUpdnIndexOn( Index index ) throws Exception;
+ public abstract void setUpdnIndexOn( Index<String,ServerEntry> index ) throws Exception;
/**
@@ -465,7 +467,7 @@
* @param index the ndn Index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setNdnIndexOn( Index index ) throws Exception;
+ public abstract void setNdnIndexOn( Index<String,ServerEntry> index ) throws Exception;
/**
@@ -476,7 +478,7 @@
* @param index a one level alias index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setOneAliasIndexOn( Index index ) throws Exception;
+ public abstract void setOneAliasIndexOn( Index<Long,ServerEntry> index ) throws Exception;
/**
@@ -487,13 +489,13 @@
* @param index a subtree alias index
* @throws Exception if there is a problem setting up the index
*/
- public abstract void setSubAliasIndexOn( Index index ) throws Exception;
+ public abstract void setSubAliasIndexOn( Index<Long,ServerEntry> index ) throws Exception;
- public abstract Index getUserIndex( String attribute ) throws Exception;
+ public abstract Index<?,ServerEntry> getUserIndex( String attribute ) throws Exception;
- public abstract Index getSystemIndex( String attribute ) throws Exception;
+ public abstract Index<?,ServerEntry> getSystemIndex( String attribute ) throws Exception;
public abstract Long getEntryId( String dn ) throws Exception;
@@ -534,7 +536,7 @@
public abstract void delete( Long id ) throws Exception;
- public abstract IndexCursor<Long,ForwardIndexEntry> list( Long id ) throws Exception;
+ public abstract IndexCursor<Long,ServerEntry> list( Long id ) throws Exception;
public abstract int getChildCount( Long id ) throws Exception;
Added: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java?rev=658798&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java (added)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java Wed May 21 11:26:31 2008
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.Iterator;
+
+import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.CursorIterator;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.IndexEntry;
+
+
+/**
+ * TODO ServerEntryCursorAdaptor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerEntryCursorAdaptor implements Cursor<ServerEntry>
+{
+ private final Partition db;
+ private final IndexCursor<Long, ServerEntry> indexCursor;
+
+
+ public ServerEntryCursorAdaptor( Partition db, IndexCursor<Long, ServerEntry> indexCursor )
+ {
+ this.db = db;
+ this.indexCursor = indexCursor;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#after(java.lang.Object)
+ */
+ public void after( ServerEntry element ) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#afterLast()
+ */
+ public void afterLast() throws Exception
+ {
+ this.indexCursor.afterLast();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#available()
+ */
+ public boolean available()
+ {
+ return indexCursor.available();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#before(java.lang.Object)
+ */
+ public void before( ServerEntry element ) throws Exception
+ {
+ throw new UnsupportedOperationException();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#beforeFirst()
+ */
+ public void beforeFirst() throws Exception
+ {
+ indexCursor.beforeFirst();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#close()
+ */
+ public void close() throws Exception
+ {
+ indexCursor.close();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#first()
+ */
+ public boolean first() throws Exception
+ {
+ return indexCursor.first();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#get()
+ */
+ public ServerEntry get() throws Exception
+ {
+ IndexEntry<Long,ServerEntry> indexEntry = indexCursor.get();
+
+ if ( indexEntry.getObject() == null )
+ {
+ indexEntry.setObject( db.lookup( indexEntry.getId() ) );
+ }
+
+ return indexEntry.getObject();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#isClosed()
+ */
+ public boolean isClosed() throws Exception
+ {
+ return indexCursor.isClosed();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#isElementReused()
+ */
+ public boolean isElementReused()
+ {
+ return indexCursor.isElementReused();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#last()
+ */
+ public boolean last() throws Exception
+ {
+ return indexCursor.last();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#next()
+ */
+ public boolean next() throws Exception
+ {
+ return indexCursor.next();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.server.core.cursor.Cursor#previous()
+ */
+ public boolean previous() throws Exception
+ {
+ return indexCursor.previous();
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Iterable#iterator()
+ */
+ public Iterator<ServerEntry> iterator()
+ {
+ return new CursorIterator<ServerEntry>( this );
+ }
+}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Wed May 21 11:26:31 2008
@@ -32,14 +32,19 @@
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.partition.impl.btree.BTreePartition;
import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexCursor;
import org.apache.directory.server.xdbm.IndexNotFoundException;
import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.search.impl.CursorBuilder;
+import org.apache.directory.server.xdbm.search.impl.DefaultOptimizer;
+import org.apache.directory.server.xdbm.search.impl.DefaultSearchEngine;
+import org.apache.directory.server.xdbm.search.impl.EvaluatorBuilder;
+import org.apache.directory.server.xdbm.search.impl.NoOpOptimizer;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
-import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import java.io.File;
@@ -59,9 +64,9 @@
*/
public class JdbmPartition extends BTreePartition
{
- private JdbmStore store;
+ private JdbmStore<ServerEntry> store;
private boolean optimizerEnabled = true;
- private Set<Index> indexedAttributes;
+ private Set<Index<Object,ServerEntry>> indexedAttributes;
// ------------------------------------------------------------------------
@@ -74,8 +79,8 @@
*/
public JdbmPartition()
{
- store = new JdbmStore();
- indexedAttributes = new HashSet<Index>();
+ store = new JdbmStore<ServerEntry>();
+ indexedAttributes = new HashSet<Index<Object,ServerEntry>>();
}
@@ -96,13 +101,13 @@
}
- public void setIndexedAttributes( Set<Index> indexedAttributes )
+ public void setIndexedAttributes( Set<Index<Object,ServerEntry>> indexedAttributes )
{
this.indexedAttributes = indexedAttributes;
}
- public Set<Index> getIndexedAttributes()
+ public Set<Index<Object,ServerEntry>> getIndexedAttributes()
{
return indexedAttributes;
}
@@ -137,24 +142,27 @@
// ------------------------------------------------------------------------
- public void setRegistries( Registries registries )
+ public void setRegistries( Registries registries ) throws Exception
{
initRegistries( registries );
}
- protected void initRegistries( Registries registries )
+ protected void initRegistries( Registries registries ) throws Exception
{
this.registries = registries;
- ExpressionEvaluator evaluator = new ExpressionEvaluator( this, registries );
- ExpressionEnumerator enumerator = new ExpressionEnumerator( this, registries.getAttributeTypeRegistry(), evaluator );
- this.searchEngine = new DefaultSearchEngine( this, evaluator, enumerator, optimizer );
store.initRegistries( registries );
}
- public final void init( DirectoryService directoryService ) throws NamingException
+ @SuppressWarnings("unchecked")
+ public final void init( DirectoryService directoryService ) throws Exception
{
+ initRegistries( directoryService.getRegistries() );
+
+ EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( store, registries );
+ CursorBuilder cursorBuilder = new CursorBuilder( store, evaluatorBuilder );
+
// setup optimizer and registries for parent
if ( ! optimizerEnabled )
{
@@ -162,10 +170,10 @@
}
else
{
- optimizer = new DefaultOptimizer( this );
+ optimizer = new DefaultOptimizer<ServerEntry>( store );
}
- initRegistries( directoryService.getRegistries() );
+ searchEngine = new DefaultSearchEngine( store, cursorBuilder, evaluatorBuilder, optimizer );
// initialize the store
store.setCacheSize( cacheSize );
@@ -174,53 +182,55 @@
store.setSuffixDn( suffix );
store.setWorkingDirectory( new File( directoryService.getWorkingDirectory().getPath() + File.separator + id ) );
- Set<JdbmIndex> userIndices = new HashSet<JdbmIndex>();
- for ( Index obj : indexedAttributes )
+ Set<Index<?,ServerEntry>> userIndices = new HashSet<Index<?,ServerEntry>>();
+
+ for ( Index<?,ServerEntry> obj : indexedAttributes )
{
- JdbmIndex index;
+ Index<?,ServerEntry> index;
if ( obj instanceof JdbmIndex )
{
- index = ( JdbmIndex ) obj;
+ index = ( JdbmIndex<?,ServerEntry> ) obj;
}
else
{
- index = new JdbmIndex();
+ index = new JdbmIndex<Object,ServerEntry>();
index.setAttributeId( obj.getAttributeId() );
index.setCacheSize( obj.getCacheSize() );
index.setWkDirPath( obj.getWkDirPath() );
}
String oid = registries.getOidRegistry().getOid( index.getAttributeId() );
+
if ( SYS_INDEX_OIDS.contains( registries.getOidRegistry().getOid( index.getAttributeId() ) ) )
{
if ( oid.equals( Store.ALIAS ) )
{
- store.setAliasIndex( index );
+ store.setAliasIndex( ( Index<String,ServerEntry> ) index );
}
else if ( oid.equals( Store.PRESENCE ) )
{
- store.setPresenceIndex( index );
+ store.setPresenceIndex( ( Index<String,ServerEntry> ) index );
}
else if ( oid.equals( Store.ONELEVEL ) )
{
- store.setOneLevelIndex( index );
+ store.setOneLevelIndex( ( Index<Long,ServerEntry> ) index );
}
else if ( oid.equals( Store.NDN ) )
{
- store.setNdnIndex( index );
+ store.setNdnIndex( ( Index<String,ServerEntry> ) index );
}
else if ( oid.equals( Store.ONEALIAS ) )
{
- store.setOneAliasIndex( index );
+ store.setOneAliasIndex( ( Index<Long,ServerEntry> ) index );
}
else if ( oid.equals( Store.SUBALIAS ) )
{
- store.setSubAliasIndex( index );
+ store.setSubAliasIndex( ( Index<Long,ServerEntry> ) index );
}
else if ( oid.equals( Store.UPDN ) )
{
- store.setUpdnIndex( index );
+ store.setUpdnIndex( ( Index<String,ServerEntry> ) index );
}
else
{
@@ -231,15 +241,15 @@
{
userIndices.add( index );
}
+
store.setUserIndices( userIndices );
- store.setEnableOptimizer( isOptimizerEnabled() );
}
store.init( registries );
}
- public final void destroy()
+ public final void destroy() throws Exception
{
store.destroy();
}
@@ -262,117 +272,93 @@
// ------------------------------------------------------------------------
- public final void addIndexOn( Index index ) throws NamingException
+ public final void addIndexOn( Index<Long, ServerEntry> index ) throws Exception
{
- if ( index instanceof JdbmIndex )
- {
- store.addIndex( ( JdbmIndex ) index );
- }
+ store.addIndex( index );
}
- public final Index getExistanceIndex()
+ public final Index<String, ServerEntry> getExistanceIndex()
{
return store.getPresenceIndex();
}
- public final void setExistanceIndexOn( Index index ) throws NamingException
+ public final void setPresenceIndexOn( Index<String, ServerEntry> index ) throws Exception
{
- if ( index instanceof JdbmIndex )
- {
- store.setPresenceIndex( ( JdbmIndex ) index );
- }
+ store.setPresenceIndex( index );
}
- public final Index getHierarchyIndex()
+ public final Index<Long, ServerEntry> getOneLevelIndex()
{
return store.getOneLevelIndex();
}
- public final void setHierarchyIndexOn( Index index ) throws NamingException
+ public final void setOneLevelIndexOn( Index<Long, ServerEntry> index ) throws Exception
{
- if ( index instanceof JdbmIndex )
- {
- store.setOneLevelIndex( ( JdbmIndex ) index );
- }
+ store.setOneLevelIndex( index );
}
- public final Index getAliasIndex()
+ public final Index<String, ServerEntry> getAliasIndex()
{
return store.getAliasIndex();
}
- public final void setAliasIndexOn( Index index ) throws NamingException
+ public final void setAliasIndexOn( Index<String, ServerEntry> index ) throws Exception
{
- if ( index instanceof JdbmIndex )
- {
- store.setAliasIndex( ( JdbmIndex ) index );
- }
+ store.setAliasIndex( index );
}
- public final Index getOneAliasIndex()
+ public final Index<Long,ServerEntry> getOneAliasIndex()
{
return store.getOneAliasIndex();
}
- public final void setOneAliasIndexOn( Index index ) throws NamingException
+ public final void setOneAliasIndexOn( Index<Long,ServerEntry> index ) throws NamingException
{
- if ( index instanceof JdbmIndex )
- {
- store.setOneAliasIndex( ( JdbmIndex ) index );
- }
+ store.setOneAliasIndex( ( Index<Long,ServerEntry> ) index );
}
- public final Index getSubAliasIndex()
+ public final Index<Long,ServerEntry> getSubAliasIndex()
{
return store.getSubAliasIndex();
}
- public final void setSubAliasIndexOn( Index index ) throws NamingException
+ public final void setSubAliasIndexOn( Index<Long,ServerEntry> index ) throws NamingException
{
- if ( index instanceof JdbmIndex )
- {
- store.setSubAliasIndex( ( JdbmIndex ) index );
- }
+ store.setSubAliasIndex( ( Index<Long,ServerEntry> ) index );
}
- public final Index getUpdnIndex()
+ public final Index<String,ServerEntry> getUpdnIndex()
{
return store.getUpdnIndex();
}
- public final void setUpdnIndexOn( Index index ) throws NamingException
+ public final void setUpdnIndexOn( Index<String,ServerEntry> index ) throws NamingException
{
- if ( index instanceof JdbmIndex )
- {
- store.setUpdnIndex( ( JdbmIndex ) index );
- }
+ store.setUpdnIndex( ( Index<String,ServerEntry> ) index );
}
- public final Index getNdnIndex()
+ public final Index<String,ServerEntry> getNdnIndex()
{
return store.getNdnIndex();
}
- public final void setNdnIndexOn( Index index ) throws NamingException
+ public final void setNdnIndexOn( Index<String,ServerEntry> index ) throws NamingException
{
- if ( index instanceof JdbmIndex )
- {
- store.setNdnIndex( ( JdbmIndex ) index );
- }
+ store.setNdnIndex( ( Index<String,ServerEntry> ) index );
}
@@ -403,7 +389,7 @@
/**
* @see org.apache.directory.server.core.partition.impl.btree.BTreePartition#getUserIndex(String)
*/
- public final Index getUserIndex( String id ) throws IndexNotFoundException
+ public final Index<?,ServerEntry> getUserIndex( String id ) throws IndexNotFoundException
{
return store.getUserIndex( id );
}
@@ -412,79 +398,79 @@
/**
* @see BTreePartition#getEntryId(String)
*/
- public final Index getSystemIndex( String id ) throws IndexNotFoundException
+ public final Index<?,ServerEntry> getSystemIndex( String id ) throws IndexNotFoundException
{
return store.getSystemIndex( id );
}
- public final Long getEntryId( String dn ) throws NamingException
+ public final Long getEntryId( String dn ) throws Exception
{
return store.getEntryId( dn );
}
- public final String getEntryDn( Long id ) throws NamingException
+ public final String getEntryDn( Long id ) throws Exception
{
return store.getEntryDn( id );
}
- public final Long getParentId( String dn ) throws NamingException
+ public final Long getParentId( String dn ) throws Exception
{
return store.getParentId( dn );
}
- public final Long getParentId( Long childId ) throws NamingException
+ public final Long getParentId( Long childId ) throws Exception
{
return store.getParentId( childId );
}
- public final String getEntryUpdn( Long id ) throws NamingException
+ public final String getEntryUpdn( Long id ) throws Exception
{
return store.getEntryUpdn( id );
}
- public final String getEntryUpdn( String dn ) throws NamingException
+ public final String getEntryUpdn( String dn ) throws Exception
{
return store.getEntryUpdn( dn );
}
- public final int count() throws NamingException
+ public final int count() throws Exception
{
return store.count();
}
- public final void add( AddOperationContext addContext ) throws NamingException
+ public final void add( AddOperationContext addContext ) throws Exception
{
store.add( addContext.getDn(), addContext.getEntry() );
}
- public final ServerEntry lookup( Long id ) throws NamingException
+ public final ServerEntry lookup( Long id ) throws Exception
{
return store.lookup( id );
}
- public final void delete( Long id ) throws NamingException
+ public final void delete( Long id ) throws Exception
{
store.delete( id );
}
- public final NamingEnumeration list( Long id ) throws NamingException
+ public final IndexCursor<Long, ServerEntry> list( Long id ) throws Exception
{
return store.list( id );
}
- public final int getChildCount( Long id ) throws NamingException
+ public final int getChildCount( Long id ) throws Exception
{
return store.getChildCount( id );
}
@@ -501,42 +487,36 @@
}
- public final ServerEntry getSuffixEntry() throws NamingException
+ public final ServerEntry getSuffixEntry() throws Exception
{
return store.getSuffixEntry();
}
- public final void setProperty( String propertyName, String propertyValue ) throws NamingException
+ public final void setProperty( String propertyName, String propertyValue ) throws Exception
{
store.setProperty( propertyName, propertyValue );
}
- public final String getProperty( String propertyName ) throws NamingException
+ public final String getProperty( String propertyName ) throws Exception
{
return store.getProperty( propertyName );
}
-
- public final ServerEntry getIndices( Long id ) throws NamingException
- {
- return store.getIndices( id );
- }
-
- public final void modify( ModifyOperationContext modifyContext ) throws NamingException
+ public final void modify( ModifyOperationContext modifyContext ) throws Exception
{
store.modify( modifyContext.getDn(), modifyContext.getModItems() );
}
- public final void rename( RenameOperationContext renameContext ) throws NamingException
+ public final void rename( RenameOperationContext renameContext ) throws Exception
{
store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn() );
}
- public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws NamingException
+ public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws Exception
{
store.move( moveAndRenameContext.getDn(),
moveAndRenameContext.getParent(),
@@ -545,13 +525,13 @@
}
- public final void move( MoveOperationContext moveContext ) throws NamingException
+ public final void move( MoveOperationContext moveContext ) throws Exception
{
store.move( moveContext.getDn(), moveContext.getParent() );
}
- public final void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId ) throws NamingException
+ public final void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId ) throws Exception
{
if ( bindDn == null || credentials == null || mechanisms == null || saslAuthId == null )
{
@@ -566,7 +546,7 @@
}
- public final void bind( BindOperationContext bindContext ) throws NamingException
+ public final void bind( BindOperationContext bindContext ) throws Exception
{
// does nothing
throw new LdapAuthenticationNotSupportedException(
@@ -576,7 +556,31 @@
}
- public final void unbind( UnbindOperationContext unbindContext ) throws NamingException
+ public final void unbind( UnbindOperationContext unbindContext ) throws Exception
+ {
+ }
+
+
+ @Override
+ public ServerEntry getIndices( Long id ) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Index<String, ServerEntry> getPresenceIndex()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Index<Long, ServerEntry> getSubLevelIndex()
{
+ // TODO Auto-generated method stub
+ return null;
}
}
Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java Wed May 21 11:26:31 2008
@@ -20,8 +20,6 @@
package org.apache.directory.server.core.partition.impl.btree.jdbm;
-import org.apache.directory.server.xdbm.Tuple;
-import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.*;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.cursor.CursorIterator;
@@ -75,15 +73,19 @@
public void beforeValue( Long id, K key ) throws Exception
{
- //noinspection unchecked
- ( ( TupleCursor ) wrappedCursor ).beforeKey( key );
+ if ( wrappedCursor instanceof TupleCursor )
+ {
+ ( ( TupleCursor ) wrappedCursor ).beforeValue( key, id );
+ }
}
public void afterValue( Long id, K key ) throws Exception
{
- //noinspection unchecked
- ( ( TupleCursor ) wrappedCursor ).afterKey( key );
+ if ( wrappedCursor instanceof TupleCursor )
+ {
+ ( ( TupleCursor ) wrappedCursor ).afterValue( key, id );
+ }
}
Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Wed May 21 11:26:31 2008
@@ -29,13 +29,11 @@
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.entry.ServerEntryUtils;
-import org.apache.directory.server.core.partition.impl.btree.*;
import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.entry.ServerStringValue;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.server.xdbm.Store;
import org.apache.directory.server.xdbm.*;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -81,11 +79,14 @@
/** the working directory to use for files */
private File workingDirectory;
/** the master table storing entries by primary key */
- private JdbmMasterTable<E> master;
- /** a map of attributeType numeric ids to user userIndices */
- private Map<String, JdbmIndex> userIndices = new HashMap<String, JdbmIndex>();
- /** a map of attributeType numeric ids to system userIndices */
- private Map<String, JdbmIndex> systemIndices = new HashMap<String, JdbmIndex>();
+ private JdbmMasterTable<ServerEntry> master;
+
+ /** a map of attributeType numeric ID to user userIndices */
+ private Map<String, Index<?,E>> userIndices = new HashMap<String, Index<?,E>>();
+
+ /** a map of attributeType numeric ID to system userIndices */
+ private Map<String, Index<?,E>> systemIndices = new HashMap<String, Index<?,E>>();
+
/** true if initialized */
private boolean initialized;
/** true if we sync disks on every write operation */
@@ -95,27 +96,24 @@
private JdbmIndex<String,E> ndnIdx;
/** the user provided distinguished name index */
private JdbmIndex<String,E> updnIdx;
- /** the attribute existance index */
- private JdbmIndex<String,E> existanceIdx;
+ /** the attribute existence index */
+ private JdbmIndex<String,E> existenceIdx;
+ /** a system index on aliasedObjectName attribute */
+ private JdbmIndex<String,E> aliasIdx;
+
+ /** a system index on the entries of descendants of root DN*/
+ private JdbmIndex<Long,E> subLevelIdx;
/** the parent child relationship index */
private JdbmIndex<Long,E> oneLevelIdx;
/** the one level scope alias index */
private JdbmIndex<Long,E> oneAliasIdx;
/** the subtree scope alias index */
private JdbmIndex<Long,E> subAliasIdx;
- /** a system index on aliasedObjectName attribute */
- private JdbmIndex<String,E> aliasIdx;
-
- /** a system index on the entries of descendants of root DN*/
- private JdbmIndex<Long,E> subLevelIdx;
/** Two static declaration to avoid lookup all over the code */
private static AttributeType OBJECT_CLASS_AT;
private static AttributeType ALIASED_OBJECT_NAME_AT;
- /** A pointer on the global registries */
- private Registries registries;
-
/** A pointer on the AT registry */
private AttributeTypeRegistry attributeTypeRegistry;
@@ -247,7 +245,6 @@
*/
public synchronized void init( Registries registries ) throws Exception
{
- this.registries = registries;
this.oidRegistry = registries.getOidRegistry();
this.attributeTypeRegistry = registries.getAttributeTypeRegistry();
@@ -277,7 +274,7 @@
recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
// Create the master table (the table wcontaining all the entries)
- master = new JdbmMasterTable<E>( recMan, registries );
+ master = new JdbmMasterTable<ServerEntry>( recMan, registries );
// -------------------------------------------------------------------
// Initializes the user and system indices
@@ -299,12 +296,13 @@
{
if ( systemIndices.size() > 0 )
{
- HashMap<String, JdbmIndex> tmp = new HashMap<String, JdbmIndex>();
- for ( JdbmIndex index : systemIndices.values() )
+ HashMap<String, Index<?,E>> tmp = new HashMap<String, Index<?,E>>();
+
+ for ( Index<?,E> index : systemIndices.values() )
{
String oid = oidRegistry.getOid( index.getAttributeId() );
tmp.put( oid, index );
- index.init( attributeTypeRegistry.lookup( oid ), workingDirectory );
+ ( ( JdbmIndex ) index ).init( attributeTypeRegistry.lookup( oid ), workingDirectory );
}
systemIndices = tmp;
}
@@ -325,12 +323,12 @@
updnIdx.init( attributeTypeRegistry.lookup( UPDN ), workingDirectory );
}
- if ( existanceIdx == null )
+ if ( existenceIdx == null )
{
- existanceIdx = new JdbmIndex<String,E>();
- existanceIdx.setAttributeId( PRESENCE );
- systemIndices.put( PRESENCE, existanceIdx );
- existanceIdx.init( attributeTypeRegistry.lookup( PRESENCE ), workingDirectory );
+ existenceIdx = new JdbmIndex<String,E>();
+ existenceIdx.setAttributeId( PRESENCE );
+ systemIndices.put( PRESENCE, existenceIdx );
+ existenceIdx.init( attributeTypeRegistry.lookup( PRESENCE ), workingDirectory );
}
if ( oneLevelIdx == null )
@@ -379,18 +377,19 @@
{
if ( userIndices != null && userIndices.size() > 0 )
{
- HashMap<String, JdbmIndex> tmp = new HashMap<String, JdbmIndex>();
- for ( JdbmIndex index : userIndices.values() )
+ Map<String, Index<?,E>> tmp = new HashMap<String, Index<?,E>>();
+
+ for ( Index<?,E> index : userIndices.values() )
{
String oid = oidRegistry.getOid( index.getAttributeId() );
tmp.put( oid, index );
- index.init( attributeTypeRegistry.lookup( oid ), workingDirectory );
+ ( ( JdbmIndex ) index ).init( attributeTypeRegistry.lookup( oid ), workingDirectory );
}
userIndices = tmp;
}
else
{
- userIndices = new HashMap<String, JdbmIndex>();
+ userIndices = new HashMap<String, Index<?,E>>();
}
}
@@ -433,12 +432,12 @@
return;
}
- List<JdbmIndex> array = new ArrayList<JdbmIndex>();
+ List<Index<?,E>> array = new ArrayList<Index<?,E>>();
array.addAll( userIndices.values() );
array.addAll( systemIndices.values() );
MultiException errors = new MultiException( "Errors encountered on destroy()" );
- for ( JdbmIndex index : array )
+ for ( Index<?,E> index : array )
{
try
{
@@ -507,7 +506,7 @@
return;
}
- List<Index> array = new ArrayList<Index>();
+ List<Index<?,E>> array = new ArrayList<Index<?,E>>();
array.addAll( userIndices.values() );
array.add( ndnIdx );
array.add( updnIdx );
@@ -515,11 +514,11 @@
array.add( oneAliasIdx );
array.add( subAliasIdx );
array.add( oneLevelIdx );
- array.add( existanceIdx );
+ array.add( existenceIdx );
array.add( subLevelIdx );
// Sync all user defined userIndices
- for ( Index idx : array )
+ for ( Index<?,E> idx : array )
{
idx.sync();
}
@@ -534,16 +533,16 @@
// ------------------------------------------------------------------------
- private JdbmIndex<?, E> convertIndex( Index<?,E> index )
+ private<K> JdbmIndex<K, E> convertIndex( Index<K,E> index )
{
if ( index instanceof JdbmIndex )
{
- return ( JdbmIndex<?,E> ) index;
+ return ( JdbmIndex<K,E> ) index;
}
LOG.warn( "Supplied index {} is not a JdbmIndex. " +
"Will create new JdbmIndex using copied configuration parameters.", index );
- JdbmIndex<?,E> jdbmIndex = new JdbmIndex<Object, E>( index.getAttributeId() );
+ JdbmIndex<K,E> jdbmIndex = new JdbmIndex<K, E>( index.getAttributeId() );
jdbmIndex.setCacheSize( index.getCacheSize() );
jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
jdbmIndex.setWkDirPath( index.getWkDirPath() );
@@ -554,19 +553,19 @@
public void setUserIndices( Set<Index<?,E>> userIndices )
{
protect( "userIndices" );
- for ( Index index : userIndices )
+ for ( Index<?,E> index : userIndices )
{
this.userIndices.put( index.getAttributeId(), convertIndex( index ) );
}
}
- public Set<Index> getUserIndices()
+ public Set<Index<?,E>> getUserIndices()
{
- return new HashSet<Index>( userIndices.values() );
+ return new HashSet<Index<?,E>>( userIndices.values() );
}
- public void addIndex( Index index ) throws NamingException
+ public void addIndex( Index<?,E> index ) throws Exception
{
userIndices.put( index.getAttributeId(), convertIndex( index ) );
}
@@ -574,15 +573,15 @@
public Index<String,E> getPresenceIndex()
{
- return existanceIdx;
+ return existenceIdx;
}
- public void setPresenceIndex( Index<String,E> index ) throws NamingException
+ public void setPresenceIndex( Index<String,E> index ) throws Exception
{
protect( "existanceIndex" );
- existanceIdx = ( JdbmIndex<String,E> ) convertIndex( index );
- systemIndices.put( index.getAttributeId(), existanceIdx );
+ existenceIdx = convertIndex( index );
+ systemIndices.put( index.getAttributeId(), existenceIdx );
}
@@ -592,10 +591,10 @@
}
- public void setOneLevelIndex( Index<Long,E> index ) throws NamingException
+ public void setOneLevelIndex( Index<Long,E> index ) throws Exception
{
protect( "hierarchyIndex" );
- oneLevelIdx = ( JdbmIndex<Long,E> ) convertIndex( index );
+ oneLevelIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), oneLevelIdx );
}
@@ -609,7 +608,7 @@
public void setAliasIndex( Index<String,E> index ) throws NamingException
{
protect( "aliasIndex" );
- aliasIdx = ( JdbmIndex<String,E> ) convertIndex( index );
+ aliasIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), aliasIdx );
}
@@ -623,7 +622,7 @@
public void setOneAliasIndex( Index<Long,E> index ) throws NamingException
{
protect( "oneAliasIndex" );
- oneAliasIdx = ( JdbmIndex<Long,E> ) convertIndex( index );
+ oneAliasIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), oneAliasIdx );
}
@@ -637,7 +636,7 @@
public void setSubAliasIndex( Index<Long,E> index ) throws NamingException
{
protect( "subAliasIndex" );
- subAliasIdx = ( JdbmIndex<Long,E> ) convertIndex( index );
+ subAliasIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), subAliasIdx );
}
@@ -651,7 +650,7 @@
public void setUpdnIndex( Index<String,E> index ) throws NamingException
{
protect( "updnIndex" );
- updnIdx = ( JdbmIndex<String,E> ) convertIndex( index );
+ updnIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), updnIdx );
}
@@ -665,7 +664,7 @@
public void setNdnIndex( Index<String,E> index ) throws NamingException
{
protect( "ndnIndex" );
- ndnIdx = ( JdbmIndex<String,E> ) convertIndex( index );
+ ndnIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), ndnIdx );
}
@@ -679,7 +678,7 @@
public void setSubLevelIndex( Index<Long,E> index ) throws NamingException
{
protect( "subLevelIndex" );
- subLevelIdx = ( JdbmIndex<Long,E> ) convertIndex( index );
+ subLevelIdx = convertIndex( index );
systemIndices.put( index.getAttributeId(), subLevelIdx );
}
@@ -708,7 +707,7 @@
}
- public Index getUserIndex( String id ) throws IndexNotFoundException
+ public Index<?,E> getUserIndex( String id ) throws IndexNotFoundException
{
try
{
@@ -730,7 +729,7 @@
}
- public Index getSystemIndex( String id ) throws IndexNotFoundException
+ public Index<?,E> getSystemIndex( String id ) throws IndexNotFoundException
{
try
{
@@ -766,12 +765,12 @@
/**
* Gets the Long id of an entry's parent using the child entry's
- * normalized dn. Note that the suffix entry returns 0, which does not
+ * normalized DN. Note that the suffix entry returns 0, which does not
* map to any entry.
*
* @param dn the normalized distinguished name of the child
* @return the id of the parent entry or zero if the suffix entry the
- * normalized suffix dn string is used
+ * normalized suffix DN string is used
* @throws Exception on failures to access the underlying store
*/
public Long getParentId( String dn ) throws Exception
@@ -1061,9 +1060,9 @@
if ( hasUserIndexOn( attributeOid ) )
{
- Index idx = getUserIndex( attributeOid );
+ Index<Object,E> idx = ( Index<Object,E> ) getUserIndex( attributeOid );
- // here lookup by attributeId is ok since we got attributeId from
+ // here lookup by attributeId is OK since we got attributeId from
// the entry via the enumeration - it's in there as is for sure
for ( Value<?> value : attribute )
@@ -1072,11 +1071,11 @@
}
// Adds only those attributes that are indexed
- existanceIdx.add( attributeOid, id );
+ existenceIdx.add( attributeOid, id );
}
}
- master.put( id, ( E ) entry );
+ master.put( id, entry );
if ( isSyncOnWrite )
{
@@ -1130,16 +1129,16 @@
if ( hasUserIndexOn( attributeOid ) )
{
- Index index = getUserIndex( attributeOid );
+ Index<?,E> index = getUserIndex( attributeOid );
// here lookup by attributeId is ok since we got attributeId from
// the entry via the enumeration - it's in there as is for sure
for ( Value<?> value : attribute )
{
- index.drop( value.get(), id );
+ ( ( JdbmIndex ) index ).drop( value.get(), id );
}
- existanceIdx.drop( attributeOid, id );
+ existenceIdx.drop( attributeOid, id );
}
}
@@ -1159,12 +1158,10 @@
* @return an IndexEntry Cursor over the child entries
* @throws Exception on failures to access the underlying store
*/
- public Cursor<IndexEntry<Long,E>> list( Long id ) throws Exception
+ public IndexCursor<Long,E> list( Long id ) throws Exception
{
- Cursor<IndexEntry<Long,E>> cursor = oneLevelIdx.forwardCursor( id );
- ForwardIndexEntry<Long,E> recordForward = new ForwardIndexEntry<Long,E>();
- recordForward.setId( id );
- cursor.before( recordForward );
+ IndexCursor<Long,E> cursor = oneLevelIdx.forwardCursor( id );
+ cursor.beforeValue( id, null );
return cursor;
}
@@ -1228,17 +1225,17 @@
if ( hasUserIndexOn( modsOid ) )
{
- Index idx = getUserIndex( modsOid );
+ Index<?,E> index = getUserIndex( modsOid );
- for ( Value value : mods )
+ for ( Value<?> value : mods )
{
- idx.add( value.get(), id );
+ ( ( JdbmIndex ) index ).add( value.get(), id );
}
- // If the attr didn't exist for this id add it to existance index
- if ( !existanceIdx.forward( modsOid, id ) )
+ // If the attr didn't exist for this id add it to existence index
+ if ( !existenceIdx.forward( modsOid, id ) )
{
- existanceIdx.add( modsOid, id );
+ existenceIdx.add( modsOid, id );
}
}
@@ -1277,16 +1274,16 @@
if ( hasUserIndexOn( modsOid ) )
{
- Index idx = getUserIndex( modsOid );
- idx.drop( ServerEntryUtils.toAttributeImpl( mods ), id );
+ Index<?,E> index = getUserIndex( modsOid );
+ ( ( JdbmIndex ) index ).drop( ServerEntryUtils.toAttributeImpl( mods ), id );
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
*/
- if ( null == idx.reverseLookup( id ) )
+ if ( null == index.reverseLookup( id ) )
{
- existanceIdx.drop( modsOid, id );
+ existenceIdx.drop( modsOid, id );
}
}
@@ -1350,19 +1347,19 @@
if ( hasUserIndexOn( modsOid ) )
{
- Index idx = getUserIndex( modsOid );
+ Index<?,E> index = getUserIndex( modsOid );
// Drop all existing attribute value index entries and add new ones
- idx.drop( id );
- idx.add( ServerEntryUtils.toAttributeImpl( mods ), id );
+ ( ( JdbmIndex ) index ).drop( id );
+ ( ( JdbmIndex ) index ).add( ServerEntryUtils.toAttributeImpl( mods ), id );
/*
* If no attribute values exist for this entryId in the index then
* we remove the existance index entry for the removed attribute.
*/
- if ( null == idx.reverseLookup( id ) )
+ if ( null == index.reverseLookup( id ) )
{
- existanceIdx.drop( modsOid, id );
+ existenceIdx.drop( modsOid, id );
}
}
@@ -1421,7 +1418,7 @@
}
}
- master.put( id, ( E ) entry );
+ master.put( id, entry );
if ( isSyncOnWrite )
{
@@ -1458,7 +1455,7 @@
}
}
- master.put( id, ( E ) entry );
+ master.put( id, entry );
if ( isSyncOnWrite )
{
@@ -1485,7 +1482,7 @@
*/
public void rename( LdapDN dn, Rdn newRdn, boolean deleteOldRdn ) throws Exception
{
- String newRdnAttr = newRdn.getNormType();
+// String newRdnAttr = newRdn.getNormType();
String newRdnValue = ( String ) newRdn.getValue();
Long id = getEntryId( dn.getNormName() );
ServerEntry entry = lookup( id );
@@ -1518,13 +1515,13 @@
if ( hasUserIndexOn( newRdn.getNormType() ) )
{
- Index idx = getUserIndex( newRdn.getNormType() );
- idx.add( newRdnValue, id );
+ Index<?,E> index = getUserIndex( newRdn.getNormType() );
+ ( ( JdbmIndex ) index ).add( newRdnValue, id );
- // Make sure the altered entry shows the existance of the new attrib
- if ( !existanceIdx.forward( newRdn.getNormType(), id ) )
+ // Make sure the altered entry shows the existence of the new attrib
+ if ( !existenceIdx.forward( newRdn.getNormType(), id ) )
{
- existanceIdx.add( newRdn.getNormType(), id );
+ existenceIdx.add( newRdn.getNormType(), id );
}
}
@@ -1552,16 +1549,16 @@
if ( hasUserIndexOn( oldRdn.getNormType() ) )
{
- Index idx = getUserIndex( oldRdn.getNormType() );
- idx.drop( oldRdn.getValue(), id );
+ Index<?,E> index = getUserIndex( oldRdn.getNormType() );
+ ( ( JdbmIndex ) index ).drop( oldRdn.getValue(), id );
/*
* If there is no value for id in this index due to our
* drop above we remove the oldRdnAttr from the existance idx
*/
- if ( null == idx.reverseLookup( id ) )
+ if ( null == index.reverseLookup( id ) )
{
- existanceIdx.drop( oldRdn.getNormType(), id );
+ existenceIdx.drop( oldRdn.getNormType(), id );
}
}
}
@@ -1588,7 +1585,7 @@
// Update the current entry
entry.setDn( newUpdn );
- master.put( id, ( E ) entry );
+ master.put( id, entry );
if ( isSyncOnWrite )
{
@@ -1654,11 +1651,11 @@
while ( children.next() )
{
// Get the child and its id
- IndexEntry rec = children.get();
+ IndexEntry<Long,E> rec = children.get();
Long childId = rec.getId();
/*
- * Calculate the Dn for the child's new name by copying the parents
+ * Calculate the DN for the child's new name by copying the parents
* new name and adding the child's old upRdn to new name as its Rdn
*/
LdapDN childUpdn = ( LdapDN ) updn.clone();
@@ -1672,7 +1669,7 @@
// Modify the child
ServerEntry entry = lookup( childId );
entry.setDn( childUpdn );
- master.put( childId, ( E ) entry );
+ master.put( childId, entry );
// Recursively change the names of the children below
modifyDn( childId, childUpdn, isMove );
@@ -1831,15 +1828,15 @@
*/
private void dropMovedAliasIndices( final LdapDN movedBase ) throws Exception
{
- // Find all the aliases from movedBase down
- IndexAssertion isBaseDescendant = new IndexAssertion()
- {
- public boolean assertCandidate( IndexEntry rec ) throws Exception
- {
- String dn = getEntryDn( rec.getId() );
- return dn.endsWith( movedBase.toString() );
- }
- };
+// // Find all the aliases from movedBase down
+// IndexAssertion<Object,E> isBaseDescendant = new IndexAssertion<Object,E>()
+// {
+// public boolean assertCandidate( IndexEntry<Object,E> rec ) throws Exception
+// {
+// String dn = getEntryDn( rec.getId() );
+// return dn.endsWith( movedBase.toString() );
+// }
+// };
Long movedBaseId = getEntryId( movedBase.toString() );
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java Wed May 21 11:26:31 2008
@@ -52,7 +52,8 @@
if ( hasIndex )
{
//noinspection unchecked
- wrapped = db.getUserIndex( evaluator.getExpression().getAttribute() ).forwardCursor();
+ wrapped = ( ( Index<String,ServerEntry> ) db.getUserIndex( evaluator.getExpression().getAttribute() ) )
+ .forwardCursor();
}
else
{
Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=658798&r1=658797&r2=658798&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Wed May 21 11:26:31 2008
@@ -105,7 +105,7 @@
if ( db.hasUserIndexOn( node.getAttribute() ) )
{
//noinspection unchecked
- idx = db.getUserIndex( node.getAttribute() );
+ idx = ( Index<String,ServerEntry> ) db.getUserIndex( node.getAttribute() );
}
else
{