directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r659749 - in /directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl: AllEntriesCursor.java SubtreeScopeCursor.java
Date Sat, 24 May 2008 05:04:28 GMT
Author: akarasulu
Date: Fri May 23 22:04:25 2008
New Revision: 659749

URL: http://svn.apache.org/viewvc?rev=659749&view=rev
Log:
fixing handling of subtree cursor when the candidate is the context entry and all entries
in the store must be returned

Added:
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
Modified:
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java

Added: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java?rev=659749&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
(added)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
Fri May 23 22:04:25 2008
@@ -0,0 +1,168 @@
+/*
+ *   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.xdbm.search.impl;
+
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
+
+
+/**
+ * A Cursor over all entries in a partition which returns IndexEntries.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AllEntriesCursor extends AbstractIndexCursor<Long,ServerEntry>
+{
+    private IndexEntry<Long, ServerEntry> indexEntry = new ForwardIndexEntry<Long,
ServerEntry>();
+    private final IndexCursor<String,ServerEntry> wrapped;
+
+    
+    public AllEntriesCursor( Store<ServerEntry> db ) throws Exception
+    {
+        // Get a reverse cursor because we want to sort by ID
+        wrapped = db.getNdnIndex().reverseCursor();
+    }
+    
+    
+    /* 
+     * @see org.apache.directory.server.xdbm.IndexCursor#afterValue(Long, Object)
+     */
+    public void afterValue( Long key, Long value ) throws Exception
+    {
+        wrapped.afterValue( key, null );
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.xdbm.IndexCursor#beforeValue(java.lang.Long, java.lang.Object)
+     */
+    public void beforeValue( Long id, Long value ) throws Exception
+    {
+        wrapped.beforeValue( id, null );
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#after(java.lang.Object)
+     */
+    public void after( IndexEntry<Long,ServerEntry> indexEntry ) throws Exception
+    {
+        wrapped.afterValue( indexEntry.getId(), null );
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#afterLast()
+     */
+    public void afterLast() throws Exception
+    {
+        wrapped.afterLast();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#available()
+     */
+    public boolean available()
+    {
+        return wrapped.available();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#before(java.lang.Object)
+     */
+    public void before( IndexEntry<Long,ServerEntry> indexEntry ) throws Exception
+    {
+        wrapped.beforeValue( indexEntry.getId(), null );
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#beforeFirst()
+     */
+    public void beforeFirst() throws Exception
+    {
+        wrapped.beforeFirst();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#first()
+     */
+    public boolean first() throws Exception
+    {
+        return wrapped.first();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#get()
+     */
+    public IndexEntry<Long,ServerEntry> get() throws Exception
+    {
+        IndexEntry<String,ServerEntry> wrappedEntry = wrapped.get();
+        indexEntry.setId( wrappedEntry.getId() );
+        indexEntry.setValue( wrappedEntry.getId() );
+        return indexEntry;
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#isElementReused()
+     */
+    public boolean isElementReused()
+    {
+        return true;
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#last()
+     */
+    public boolean last() throws Exception
+    {
+        return wrapped.last();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#next()
+     */
+    public boolean next() throws Exception
+    {
+        return wrapped.next();
+    }
+
+
+    /* 
+     * @see org.apache.directory.server.core.cursor.Cursor#previous()
+     */
+    public boolean previous() throws Exception
+    {
+        return wrapped.previous();
+    }
+}

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=659749&r1=659748&r2=659749&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
(original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
Fri May 23 22:04:25 2008
@@ -44,7 +44,7 @@
     private final Store<ServerEntry> db;
 
     /** A ScopeNode Evaluator */
-    private final SubtreeScopeEvaluator evaluator;
+    private final SubtreeScopeEvaluator<ServerEntry> evaluator;
 
     /** A Cursor over the entries in the scope of the search base */
     private final IndexCursor<Long,ServerEntry> scopeCursor;
@@ -66,11 +66,19 @@
      * @param evaluator an IndexEntry (candidate) evaluator
      * @throws Exception on db access failures
      */
-    public SubtreeScopeCursor( Store<ServerEntry> db, SubtreeScopeEvaluator evaluator
) throws Exception
+    public SubtreeScopeCursor( Store<ServerEntry> db, SubtreeScopeEvaluator<ServerEntry>
evaluator ) throws Exception
     {
         this.db = db;
         this.evaluator = evaluator;
-        scopeCursor = db.getSubLevelIndex().forwardCursor( evaluator.getBaseId() );
+        
+        if ( evaluator.getBaseId().longValue() == db.getContextEntryId().longValue() )
+        {
+            scopeCursor = new AllEntriesCursor( db );
+        }
+        else
+        {
+            scopeCursor = db.getSubLevelIndex().forwardCursor( evaluator.getBaseId() );
+        }
 
         if ( evaluator.isDereferencing() )
         {



Mime
View raw message