jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1169501 [1/2] - in /jackrabbit/branches/JCR-2936: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/ jackrabbit-core/src/main/java/org/apache/jackra...
Date Sun, 11 Sep 2011 18:57:13 GMT
Author: jukka
Date: Sun Sep 11 18:57:11 2011
New Revision: 1169501

URL: http://svn.apache.org/viewvc?rev=1169501&view=rev
Log:
Merge recent changes from trunk to the JCR-2936 branch

Added:
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleDumper.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/
      - copied from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/AbstractFieldComparator.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/AbstractFieldComparator.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparator.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparator.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparatorSource.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/DynamicOperandFieldComparatorSource.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/RowComparator.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/RowComparator.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/ValueComparableWrapper.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/sort/ValueComparableWrapper.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OffsetLimitTest.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OffsetLimitTest.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OrderByTest.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OrderByTest.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/FilterIterator.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/FilterIterator.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/SizedIterator.java
      - copied unchanged from r1169494, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/SizedIterator.java
Modified:
    jackrabbit/branches/JCR-2936/   (props changed)
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryFactory.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/QueryEngine.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
    jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/pom.xml
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/FilterIterator.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddLabel.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveLabel.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Update.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/WorkspaceImport.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
    jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ImportHandler.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoBuilder.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatingChangeLog.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NameFactoryImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/PathBuilder.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/OrderQueryNode.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryConstants.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/QueryNode.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql/JCRSQLQueryBuilder.java
    jackrabbit/branches/JCR-2936/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
    jackrabbit/branches/JCR-2936/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractPerformanceTest.java
    jackrabbit/branches/JCR-2936/test/performance/base/src/main/java/org/apache/jackrabbit/performance/AbstractTest.java
    jackrabbit/branches/JCR-2936/test/performance/base/src/main/java/org/apache/jackrabbit/performance/BigFileReadTest.java
    jackrabbit/branches/JCR-2936/test/performance/base/src/main/java/org/apache/jackrabbit/performance/BigFileWriteTest.java
    jackrabbit/branches/JCR-2936/test/performance/jackrabbit23/src/test/java/org/apache/jackrabbit/performance/PerformanceTest.java

Propchange: jackrabbit/branches/JCR-2936/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Sep 11 18:57:11 2011
@@ -1 +1,2 @@
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
+/jackrabbit/trunk:1160161-1169494

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java Sun Sep 11 18:57:11 2011
@@ -47,6 +47,11 @@ import javax.jcr.PropertyType;
  */
 class BundleReader {
 
+    /*
+     * Implementation note: if you change this class, also change BundleDumper
+     * accordingly.
+     */
+
     /** Logger instance */
     private static Logger log = LoggerFactory.getLogger(BundleReader.class);
 
@@ -578,7 +583,7 @@ class BundleReader {
         TimeZone tz;
         if ((ts & 1) == 0) {
             tz = COMMON_TIMEZONES[0];
-            ts >>= 1; 
+            ts >>= 1;
         } else if ((ts & 2) == 0) {
             tz = COMMON_TIMEZONES[((int) ts >> 2) & 0x1f]; // 5 bits;
             ts >>= 7;

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java Sun Sep 11 18:57:11 2011
@@ -134,6 +134,7 @@ public class QueryImpl extends AbstractQ
                         return "query.execute(" + statement + ")";
                     }
                 });
+
         final QueryStat queryStat = sessionContext.getRepositoryContext()
                 .getStatManager().getQueryStat();
         if (queryStat.isEnabled() || log.isDebugEnabled()) {

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/FieldComparatorBase.java Sun Sep 11 18:57:11 2011
@@ -25,7 +25,7 @@ import java.io.IOException;
  * Abstract base class for <code>FieldComparator</code> implementations
  * which are based on values in the form of <code>Comparables</code>.
  */
-abstract class FieldComparatorBase extends FieldComparator {
+abstract public class FieldComparatorBase extends FieldComparator {
 
     /**
      * The bottom value.

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexSearcher.java Sun Sep 11 18:57:11 2011
@@ -106,8 +106,8 @@ public class JackrabbitIndexSearcher
             if (sort.getSort().length == 0) {
                 hits = new LuceneQueryHits(reader, this, query);
             } else {
-                hits = new SortedLuceneQueryHits(
-                        reader, this, query, sort, resultFetchHint);
+                hits = new SortedLuceneQueryHits(this, query, sort,
+                        resultFetchHint);
             }
         }
         return hits;

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryFactory.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryFactory.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryFactory.java Sun Sep 11 18:57:11 2011
@@ -107,6 +107,7 @@ import org.apache.lucene.queryParser.Que
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
 
 /**
  * Factory that creates Lucene queries from QOM elements.
@@ -166,10 +167,30 @@ public class LuceneQueryFactory {
         this.primaryTypeField = nsMappings.translateName(JCR_PRIMARYTYPE);
     }
 
-    public List<Row> execute(
-            Map<String, PropertyValue> columns, Selector selector,
-            Constraint constraint) throws RepositoryException, IOException {
+    /**
+     * @param columns
+     * @param selector
+     * @param constraint
+     * @param externalSort
+     *            if <code>true</code> it means that the lqf should just let the
+     *            QueryEngine take care of sorting and applying applying offset
+     *            and limit constraints
+     * @param offsetIn
+     *            used in pagination
+     * @param limitIn
+     *            used in pagination
+     * @return a list of rows
+     * @throws RepositoryException
+     * @throws IOException
+     */
+    public List<Row> execute(Map<String, PropertyValue> columns,
+            Selector selector, Constraint constraint, Sort sort,
+            boolean externalSort, long offsetIn, long limitIn)
+            throws RepositoryException, IOException {
         final IndexReader reader = index.getIndexReader(true);
+        final int offset = offsetIn < 0 ? 0 : (int) offsetIn;
+        final int limit = limitIn < 0 ? Integer.MAX_VALUE : (int) limitIn;
+
         QueryHits hits = null;
         try {
             JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
@@ -192,25 +213,47 @@ public class LuceneQueryFactory {
             }
 
             List<Row> rows = new ArrayList<Row>();
-            hits = searcher.evaluate(qp.mainQuery);
+
+            // TODO depending on the filters, we could push the offset info
+            // into the searcher
+            hits = searcher.evaluate(qp.mainQuery, sort, offset + limit);
+            int currentNode = 0;
+            int addedNodes = 0;
+
             ScoreNode node = hits.nextScoreNode();
             while (node != null) {
+                Row row = null;
                 try {
-                    Row row = new SelectorRow(
-                            columns, evaluator, selector.getSelectorName(),
+                    row = new SelectorRow(columns, evaluator,
+                            selector.getSelectorName(),
                             session.getNodeById(node.getNodeId()),
                             node.getScore());
-                    if (filter.evaluate(row)) {
-                        rows.add(row);
-                    }
                 } catch (ItemNotFoundException e) {
                     // skip the node
                 }
+                if (row != null && filter.evaluate(row)) {
+                    if (externalSort) {
+                        // return everything and not worry about sort
+                        rows.add(row);
+                    } else {
+                        // apply limit and offset rules locally
+                        if (currentNode >= offset
+                                && currentNode - offset < limit) {
+                            rows.add(row);
+                            addedNodes++;
+                        }
+                        currentNode++;
+                        // end the loop when going over the limit
+                        if (addedNodes == limit) {
+                            break;
+                        }
+                    }
+                }
                 node = hits.nextScoreNode();
             }
             return rows;
         } finally {
-            if(hits != null){
+            if (hits != null) {
                 hits.close();
             }
             Util.closeOrRelease(reader);

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Sun Sep 11 18:57:11 2011
@@ -532,6 +532,9 @@ public class SearchIndex extends Abstrac
         indexingConfig = createIndexingConfiguration(nsMappings);
         analyzer.setIndexingConfig(indexingConfig);
 
+        // initialize the Tika parser
+        parser = createParser();
+
         index = new MultiIndex(this, excludedIDs);
         if (index.numDocs() == 0) {
             Path rootPath;
@@ -928,50 +931,51 @@ public class SearchIndex extends Abstrac
      *
      * @return the configured parser
      */
-    public synchronized Parser getParser() {
-        if (parser == null) {
-            URL url = null;
-            if (tikaConfigPath != null) {
-                File file = new File(tikaConfigPath);
-                if (file.exists()) {
-                    try {
-                        url = file.toURI().toURL();
-                    } catch (MalformedURLException e) {
-                        log.warn("Invalid Tika configuration path: " + file, e);
-                    }
-                } else {
-                    ClassLoader loader = SearchIndex.class.getClassLoader();
-                    url = loader.getResource(tikaConfigPath);
-                }
-            }
-            if (url == null) {
-                url = SearchIndex.class.getResource("tika-config.xml");
-            }
+    public Parser getParser() {
+        return parser;
+    }
 
-            TikaConfig config = null;
-            if (url != null) {
+    private Parser createParser() {
+        URL url = null;
+        if (tikaConfigPath != null) {
+            File file = new File(tikaConfigPath);
+            if (file.exists()) {
                 try {
-                    config = new TikaConfig(url);
-                } catch (Exception e) {
-                    log.warn("Tika configuration not available: " + url, e);
+                    url = file.toURI().toURL();
+                } catch (MalformedURLException e) {
+                    log.warn("Invalid Tika configuration path: " + file, e);
                 }
+            } else {
+                ClassLoader loader = SearchIndex.class.getClassLoader();
+                url = loader.getResource(tikaConfigPath);
             }
-            if (config == null) {
-                config = TikaConfig.getDefaultConfig();
-            }
+        }
+        if (url == null) {
+            url = SearchIndex.class.getResource("tika-config.xml");
+        }
 
-            if (forkJavaCommand == null) {
-                parser = new AutoDetectParser(config);
-            } else {
-                ForkParser forkParser = new ForkParser(
-                        SearchIndex.class.getClassLoader(),
-                        new AutoDetectParser(config));
-                forkParser.setJavaCommand(forkJavaCommand);
-                forkParser.setPoolSize(extractorPoolSize);
-                parser = forkParser;
+        TikaConfig config = null;
+        if (url != null) {
+            try {
+                config = new TikaConfig(url);
+            } catch (Exception e) {
+                log.warn("Tika configuration not available: " + url, e);
             }
         }
-        return parser;
+        if (config == null) {
+            config = TikaConfig.getDefaultConfig();
+        }
+
+        if (forkJavaCommand != null) {
+            ForkParser forkParser = new ForkParser(
+                    SearchIndex.class.getClassLoader(),
+                    new AutoDetectParser(config));
+            forkParser.setJavaCommand(forkJavaCommand);
+            forkParser.setPoolSize(extractorPoolSize);
+            return forkParser;
+        } else {
+            return new AutoDetectParser(config);
+        }
     }
 
     /**
@@ -1179,7 +1183,7 @@ public class SearchIndex extends Abstrac
             throws RepositoryException {
         NodeIndexer indexer = new NodeIndexer(
                 node, getContext().getItemStateManager(), nsMappings,
-                getContext().getExecutor(), getParser());
+                getContext().getExecutor(), parser);
         indexer.setSupportHighlighting(supportHighlighting);
         indexer.setIndexingConfiguration(indexingConfig);
         indexer.setIndexFormatVersion(indexFormatVersion);

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldComparatorSource.java Sun Sep 11 18:57:11 2011
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.core.query
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.id.PropertyId;
+import org.apache.jackrabbit.core.query.lucene.sort.AbstractFieldComparator;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.value.InternalValue;
@@ -34,8 +35,6 @@ import org.apache.lucene.search.FieldCom
 import org.apache.lucene.search.FieldComparatorSource;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * Implements a <code>FieldComparatorSource</code> for <code>FieldComparator</code>s which
@@ -110,122 +109,6 @@ public class SharedFieldComparatorSource
     }
 
     /**
-     * Abstract base class for <code>FieldComparator</code>s which keep their values
-     * (<code>Comparable</code>s) in an array.
-     */
-    private abstract static class AbstractFieldComparator extends FieldComparatorBase {
-
-        /**
-         * The values for comparing.
-         */
-        private final Comparable[] values;
-
-        /**
-         * The index readers.
-         */
-
-        protected final List<IndexReader> readers = new ArrayList<IndexReader>();
-        /**
-         * The document number starts for the {@link #readers}.
-         */
-        protected int[] starts;
-
-        /**
-         * Create a new instance with the given number of values.
-         *
-         * @param numHits  the number of values
-         */
-        protected AbstractFieldComparator(int numHits) {
-            values = new Comparable[numHits];
-        }
-
-        /**
-         * Returns the reader index for document <code>n</code>.
-         *
-         * @param n document number.
-         * @return the reader index.
-         */
-        protected final int readerIndex(int n) {
-            int lo = 0;
-            int hi = readers.size() - 1;
-
-            while (hi >= lo) {
-                int mid = (lo + hi) >> 1;
-                int midValue = starts[mid];
-                if (n < midValue) {
-                    hi = mid - 1;
-                }
-                else if (n > midValue) {
-                    lo = mid + 1;
-                }
-                else {
-                    while (mid + 1 < readers.size() && starts[mid + 1] == midValue) {
-                        mid++;
-                    }
-                    return mid;
-                }
-            }
-            return hi;
-        }
-
-        /**
-         * Add the given value to the values array
-         *
-         * @param slot   index into values
-         * @param value  value for adding
-         */
-        @Override
-        public void setValue(int slot, Comparable value) {
-            values[slot] = value;
-        }
-
-        /**
-         * Return a value from the values array
-         *
-         * @param slot  index to retrieve
-         * @return  the retrieved value
-         */
-        @Override
-        public Comparable getValue(int slot) {
-            return values[slot];
-        }
-
-        @Override
-        public void setNextReader(IndexReader reader, int docBase) throws IOException {
-            getIndexReaders(readers, reader);
-
-            int maxDoc = 0;
-            starts = new int[readers.size() + 1];
-
-            for (int i = 0; i < readers.size(); i++) {
-                IndexReader r = readers.get(i);
-                starts[i] = maxDoc;
-                maxDoc += r.maxDoc();
-            }
-            starts[readers.size()] = maxDoc;
-        }
-
-        /**
-         * Checks if <code>reader</code> is of type {@link MultiIndexReader} and if
-         * so calls itself recursively for each reader within the
-         * <code>MultiIndexReader</code> or otherwise adds the reader to the list.
-         *
-         * @param readers  list of index readers.
-         * @param reader   reader to decompose
-         */
-        private static void getIndexReaders(List<IndexReader> readers, IndexReader reader) {
-            if (reader instanceof MultiIndexReader) {
-                for (IndexReader r : ((MultiIndexReader) reader).getIndexReaders()) {
-                    getIndexReaders(readers, r);
-                }
-            }
-            else {
-                readers.add(reader);
-            }
-        }
-    }
-
-    /**
      * A <code>FieldComparator</code> which works for order by clauses with properties
      * directly on the result nodes.
      */

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java Sun Sep 11 18:57:11 2011
@@ -16,8 +16,10 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import java.io.IOException;
+
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Sort;
@@ -25,11 +27,6 @@ import org.apache.lucene.search.TopField
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * Wraps a lucene query result and adds a close method that allows to release
  * resources after a query has been executed and the results have been read
@@ -53,14 +50,9 @@ public final class SortedLuceneQueryHits
     private static final int MIN_FETCH_SIZE = 32;
 
     /**
-     * The IndexReader in use by the lucene hits.
-     */
-    private final IndexReader reader;
-
-    /**
      * The index searcher.
      */
-    private final JackrabbitIndexSearcher searcher;
+    private final IndexSearcher searcher;
 
     /**
      * The query to execute.
@@ -80,7 +72,7 @@ public final class SortedLuceneQueryHits
     /**
      * The score docs.
      */
-    private final List<ScoreDoc> scoreDocs = new ArrayList<ScoreDoc>();
+    private ScoreDoc[] scoreDocs = new ScoreDoc[0];
 
     /**
      * The total number of hits.
@@ -88,26 +80,30 @@ public final class SortedLuceneQueryHits
     private int size;
 
     /**
-     * Number of hits to retrieve.
+     * Number of hits to be pre-fetched from the lucene index (will be around 2x
+     * resultFetchHint).
      */
     private int numHits;
 
+    private int offset = 0;
+
     /**
      * Creates a new <code>QueryHits</code> instance wrapping <code>hits</code>.
-     *
-     * @param reader          the IndexReader in use.
-     * @param searcher        the index searcher.
-     * @param query           the query to execute.
-     * @param sort            the sort criteria.
-     * @param resultFetchHint a hint on how many results should be fetched.
-     * @throws IOException if an error occurs while reading from the index.
-     */
-    public SortedLuceneQueryHits(IndexReader reader,
-                                 JackrabbitIndexSearcher searcher,
-                                 Query query,
-                                 Sort sort,
-                                 long resultFetchHint) throws IOException {
-        this.reader = reader;
+     * 
+     * @param searcher
+     *            the index searcher.
+     * @param query
+     *            the query to execute.
+     * @param sort
+     *            the sort criteria.
+     * @param resultFetchHint
+     *            a hint on how many results should be pre-fetched from the
+     *            lucene index.
+     * @throws IOException
+     *             if an error occurs while reading from the index.
+     */
+    public SortedLuceneQueryHits(IndexSearcher searcher, Query query,
+            Sort sort, long resultFetchHint) throws IOException {
         this.searcher = searcher;
         this.query = query;
         this.sort = sort;
@@ -131,13 +127,13 @@ public final class SortedLuceneQueryHits
         if (++hitIndex >= size) {
             // no more score nodes
             return null;
-        } else if (hitIndex >= scoreDocs.size()) {
+        } else if (hitIndex - offset >= scoreDocs.length) {
             // refill at least numHits or twice hitIndex
             this.numHits = Math.max(this.numHits, hitIndex * 2);
             getHits();
         }
-        ScoreDoc doc = scoreDocs.get(hitIndex);
-        String uuid = reader.document(doc.doc,
+        ScoreDoc doc = scoreDocs[hitIndex - offset];
+        String uuid = searcher.doc(doc.doc,
                 FieldSelectors.UUID).get(FieldNames.UUID);
         NodeId id = new NodeId(uuid);
         return new ScoreNode(id, doc.score, doc.doc);
@@ -159,11 +155,10 @@ public final class SortedLuceneQueryHits
         TopFieldCollector collector = TopFieldCollector.create(sort, numHits, false, true, false, false);
         searcher.search(query, collector);
         size = collector.getTotalHits();
-        ScoreDoc[] docs = collector.topDocs().scoreDocs;
-        scoreDocs.addAll(Arrays.asList(docs).subList(scoreDocs.size(), docs.length));
-        log.debug("getHits() {}/{}", scoreDocs.size(), numHits);
+        offset += scoreDocs.length;
+        scoreDocs = collector.topDocs(offset, numHits).scoreDocs;
+        log.debug("getHits() {}/{}", scoreDocs.length, numHits);
         // double hits for next round
         numHits *= 2;
     }
-
 }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/QueryEngine.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/QueryEngine.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/QueryEngine.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/join/QueryEngine.java Sun Sep 11 18:57:11 2011
@@ -18,13 +18,13 @@ package org.apache.jackrabbit.core.query
 
 import static javax.jcr.query.qom.QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER;
 import static javax.jcr.query.qom.QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER;
-import static javax.jcr.query.qom.QueryObjectModelConstants.JCR_ORDER_DESCENDING;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -48,18 +48,23 @@ import javax.jcr.query.RowIterator;
 import javax.jcr.query.qom.Column;
 import javax.jcr.query.qom.Constraint;
 import javax.jcr.query.qom.Join;
-import javax.jcr.query.qom.Operand;
 import javax.jcr.query.qom.Ordering;
 import javax.jcr.query.qom.PropertyValue;
+import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.query.qom.QueryObjectModelFactory;
 import javax.jcr.query.qom.Selector;
 import javax.jcr.query.qom.Source;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.jackrabbit.commons.iterator.RowIteratorAdapter;
 import org.apache.jackrabbit.commons.query.qom.OperandEvaluator;
 import org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory;
+import org.apache.jackrabbit.core.query.lucene.sort.DynamicOperandFieldComparatorSource;
+import org.apache.jackrabbit.core.query.lucene.sort.RowComparator;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,58 +75,16 @@ public class QueryEngine {
      */
     private static final Logger log = LoggerFactory
             .getLogger(QueryEngine.class);
+    
+    //TODO remove this when the implementation is stable
+    public static final String NATIVE_SORT_SYSTEM_PROPERTY = "useNativeSort";
 
-    private static final int printIndentStep = 4;
-
-    /**
-     * Row comparator.
-     */
-    private static class RowComparator implements Comparator<Row> {
-
-        private final ValueComparator comparator = new ValueComparator();
-
-        private final Ordering[] orderings;
-
-        private final OperandEvaluator evaluator;
-
-        private RowComparator(Ordering[] orderings, OperandEvaluator evaluator) {
-            this.orderings = orderings;
-            this.evaluator = evaluator;
-        }
-
-        public int compare(Row a, Row b) {
-            try {
-                for (Ordering ordering : orderings) {
-                    Operand operand = ordering.getOperand();
-                    Value[] va = evaluator.getValues(operand, a);
-                    Value[] vb = evaluator.getValues(operand, b);
-                    int d = compare(va, vb);
-                    if (d != 0) {
-                        if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) {
-                            return -d;
-                        } else {
-                            return d;
-                        }
-                    }
-                }
-                return 0;
-            } catch (RepositoryException e) {
-                throw new RuntimeException("Unable to compare rows " + a
-                        + " and " + b, e);
-            }
-        }
-
-        private int compare(Value[] a, Value[] b) {
-            for (int i = 0; i < a.length && i < b.length; i++) {
-                int d = comparator.compare(a[i], b[i]);
-                if (d != 0) {
-                    return d;
-                }
-            }
-            return a.length - b.length;
-        }
+    private static final boolean NATIVE_SORT = Boolean.valueOf(System
+            .getProperty(NATIVE_SORT_SYSTEM_PROPERTY, "false"));
 
-    }
+    private static final int printIndentStep = 4;
+    
+    private final Session session;
 
     private final LuceneQueryFactory lqf;
 
@@ -135,8 +98,8 @@ public class QueryEngine {
 
     public QueryEngine(Session session, LuceneQueryFactory lqf,
             Map<String, Value> variables) throws RepositoryException {
+        this.session = session;
         this.lqf = lqf;
-
         Workspace workspace = session.getWorkspace();
         this.ntManager = workspace.getNodeTypeManager();
         this.qomFactory = workspace.getQueryManager().getQOMFactory();
@@ -151,8 +114,8 @@ public class QueryEngine {
         long time = System.currentTimeMillis();
         QueryResult qr = execute(columns, source, constraint, orderings,
                 offset, limit, 2);
-        log.debug("SQL2 QUERY execute took {} ms.", System.currentTimeMillis()
-                - time);
+        log.debug("SQL2 QUERY execute took {} ms. native sort is {}.",
+                System.currentTimeMillis() - time, NATIVE_SORT);
         return qr;
     }
 
@@ -251,7 +214,7 @@ public class QueryEngine {
             return new SimpleQueryResult(merger.getColumnNames(),
                     merger.getSelectorNames(), new RowIteratorAdapter(allRows));
         }
-        
+
         Set<Row> leftRows = buildLeftRowsJoin(csInfo, leftCo, printIndentation
                 + printIndentStep);
         if (log.isDebugEnabled()) {
@@ -483,23 +446,79 @@ public class QueryEngine {
         String[] columnNames = columnMap.keySet().toArray(
                 new String[columnMap.size()]);
 
+        Sort sort = new Sort();
+        if (NATIVE_SORT) {
+            sort = new Sort(createSortFields(orderings, session));
+        }
+
+        // if true it means that the LuceneQueryFactory should just let the
+        // QueryEngine take care of sorting and applying offset and limit
+        // constraints
+        boolean externalSort = !NATIVE_SORT;
+        RowIterator rows = null;
         try {
-            RowIterator rows = new RowIteratorAdapter(lqf.execute(columnMap,
-                    selector, constraint));
-            QueryResult result = new SimpleQueryResult(columnNames,
-                    selectorNames, rows);
-            return sort(result, orderings, evaluator, offset, limit);
+            rows = new RowIteratorAdapter(lqf.execute(columnMap, selector,
+                    constraint, sort, externalSort, offset, limit));
         } catch (IOException e) {
             throw new RepositoryException("Failed to access the query index", e);
         } finally {
-            if (log.isDebugEnabled()) {
-                time = System.currentTimeMillis() - time;
-                log.debug(genString(printIndentation) + "SQL2 SELECT took "
-                        + time + " ms. selector: " + selector + ", columns: "
-                        + Arrays.toString(columnNames) + ", constraint: "
-                        + constraint);
+            log.debug(
+                    "{}SQL2 SELECT took {} ms. selector: {}, columns: {}, constraint: {}, offset {}, limit {}",
+                    new Object[] { genString(printIndentation),
+                            System.currentTimeMillis() - time, selector,
+                            Arrays.toString(columnNames), constraint, offset,
+                            limit });
+        }
+        QueryResult result = new SimpleQueryResult(columnNames, selectorNames,
+                rows);
+        if (NATIVE_SORT) {
+            return result;
+        }
+
+        long timeSort = System.currentTimeMillis();
+        QueryResult sorted = sort(result, orderings, evaluator, offset, limit);
+        log.debug("{}SQL2 SORT took {} ms.", genString(printIndentation),
+                System.currentTimeMillis() - timeSort);
+        return sorted;
+    }
+
+    public SortField[] createSortFields(Ordering[] orderings, Session session)
+            throws RepositoryException {
+
+        if (orderings == null || orderings.length == 0) {
+            return new SortField[] { SortField.FIELD_SCORE };
+        }
+        // orderings[] -> (property, ordering)
+        Map<String, Ordering> orderByProperties = new HashMap<String, Ordering>();
+        for (Ordering o : orderings) {
+            final String p = o.toString();
+            if (!orderByProperties.containsKey(p)) {
+                orderByProperties.put(p, o);
+            }
+        }
+        final DynamicOperandFieldComparatorSource dofcs = new DynamicOperandFieldComparatorSource(
+                session, evaluator, orderByProperties);
+
+        List<SortField> sortFields = new ArrayList<SortField>();
+
+        // as it turn out, orderByProperties.keySet() doesn't keep the original
+        // insertion order
+        for (Ordering o : orderings) {
+            final String p = o.toString();
+            // order on jcr:score does not use the natural order as
+            // implemented in lucene. score ascending in lucene means that
+            // higher scores are first. JCR specs that lower score values
+            // are first.
+            boolean isAsc = QueryObjectModelConstants.JCR_ORDER_ASCENDING
+                    .equals(o.getOrder());
+            if (JcrConstants.JCR_SCORE.equals(p)) {
+                sortFields.add(new SortField(null, SortField.SCORE, !isAsc));
+            } else {
+                // TODO use native sort if available
+                sortFields.add(new SortField(p, dofcs, isAsc));
             }
         }
+        return sortFields.toArray(new SortField[sortFields.size()]);
     }
 
     private Map<String, PropertyValue> getColumnMap(Column[] columns,

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/FineGrainedISMLocking.java Sun Sep 11 18:57:11 2011
@@ -385,9 +385,11 @@ public class FineGrainedISMLocking imple
             }
             for (int i = 0; i < slots.length; i++) {
                 Map<ItemId, Integer> locks = slots[i];
-                for (ItemId id : locks.keySet()) {
-                    if (FineGrainedISMLocking.hasDependency(changes, id)) {
-                        return true;
+                synchronized (locks) {
+                    for (ItemId id : locks.keySet()) {
+                        if (FineGrainedISMLocking.hasDependency(changes, id)) {
+                            return true;
+                        }
                     }
                 }
             }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/TestAll.java Sun Sep 11 18:57:11 2011
@@ -70,6 +70,8 @@ public class TestAll extends TestCase {
         suite.addTestSuite(SQL2PathEscapingTest.class);
         suite.addTestSuite(SQL2QueryResultTest.class);
         suite.addTestSuite(LimitedAccessQueryTest.class);
+        suite.addTestSuite(SQL2OffsetLimitTest.class);
+        suite.addTestSuite(SQL2OrderByTest.class);
 
         return suite;
     }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/pom.xml?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/pom.xml (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/pom.xml Sun Sep 11 18:57:11 2011
@@ -46,8 +46,13 @@
               org.apache.jackrabbit.util.Base64
             </Main-Class>
             <Export-Package>
+              !org.apache.jackrabbit.api.*,
               org.apache.jackrabbit.*;version=${project.version}
             </Export-Package>
+            <Import-Package>
+              *,
+              org.apache.jackrabbit.api.security.user;version="[2.2,3)";resolution:=optional
+            </Import-Package>
           </instructions>
         </configuration>
       </plugin>

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java Sun Sep 11 18:57:11 2011
@@ -29,6 +29,7 @@ import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import javax.imageio.spi.ServiceRegistry;
 import javax.jcr.Binary;
@@ -41,6 +42,7 @@ import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.QueryResult;
@@ -864,4 +866,275 @@ public class JcrUtils {
         }
     }
 
+    /**
+     * Creates or gets the {@link javax.jcr.Node Node} at the given Path.
+     * In case it has to create the Node all non-existent intermediate path-elements
+     * will be created with the given NodeType.
+     *
+     * <p>
+     * Changes made are not saved by this method, so <code>session.save()</code>
+     * has to be called to persist them.
+     *
+     * @param absolutePath     absolute path to create
+     * @param nodeType to use for creation of nodes If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param session  to use
+     * @return the Node at path
+     * @throws RepositoryException in case of exception accessing the Repository
+     */
+    public static Node getOrCreateByPath(String absolutePath, String nodeType, Session session)
+            throws RepositoryException {
+        return getOrCreateByPath(absolutePath, false, nodeType, nodeType, session, false);
+    }
+
+    /**
+     * Creates or gets the {@link javax.jcr.Node Node} at the given Path.
+     * In case it has to create the Node all non-existent intermediate path-elements
+     * will be created with the given intermediate node type and the returned node
+     * will be created with the given nodeType.
+     *
+     * @param absolutePath         absolute path to create
+     * @param intermediateNodeType to use for creation of intermediate nodes. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param nodeType             to use for creation of the final node. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param session              to use
+     * @param autoSave             Should save be called when a new node is created?
+     * @return the Node at absolutePath
+     * @throws RepositoryException in case of exception accessing the Repository
+     */
+    public static Node getOrCreateByPath(String absolutePath,
+                                  String intermediateNodeType,
+                                  String nodeType,
+                                  Session session,
+                                  boolean autoSave)
+            throws RepositoryException {
+        return getOrCreateByPath(absolutePath, false, intermediateNodeType, nodeType, session, autoSave);
+    }
+
+    /**
+     * Creates a {@link javax.jcr.Node Node} at the given Path. In case it has
+     * to create the Node all non-existent intermediate path-elements will be
+     * created with the given intermediate node type and the returned node will
+     * be created with the given nodeType.
+     *
+     * <p>
+     * If the path points to an existing node, the leaf node name will be
+     * regarded as a name hint and a unique node name will be created by
+     * appending a number to the given name (eg. <code>/some/path/foobar2</code>).
+     * Please note that <b>the uniqueness check is not an atomic JCR operation</b>,
+     * so it is possible that you get a {@link RepositoryException} (path
+     * already exists) if another concurrent session created the same node in
+     * the meantime.
+     *
+     * <p>
+     * Changes made are not saved by this method, so <code>session.save()</code>
+     * has to be called to persist them.
+     *
+     * @param pathHint
+     *            path to create
+     * @param nodeType
+     *            to use for creation of nodes. . If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param session
+     *            to use
+     * @return the newly created Node
+     * @throws RepositoryException
+     *             in case of exception accessing the Repository
+     */
+    public static Node getOrCreateUniqueByPath(String pathHint, String nodeType, Session session)
+           throws RepositoryException {
+        return getOrCreateByPath(pathHint, true, nodeType, nodeType, session, false);
+    }
+
+    /**
+     * Creates or gets the {@link javax.jcr.Node Node} at the given Path. In
+     * case it has to create the Node all non-existent intermediate
+     * path-elements will be created with the given intermediate node type and
+     * the returned node will be created with the given nodeType.
+     *
+     * <p>
+     * If the parameter <code>createUniqueLeaf</code> is set, it will not get
+     * an existing node but rather try to create a unique node by appending a
+     * number to the last path element (leaf node). Please note that <b>the
+     * uniqueness check is not an atomic JCR operation</b>, so it is possible
+     * that you get a {@link RepositoryException} (path already exists) if
+     * another concurrent session created the same node in the meantime.
+     *
+     * @param absolutePath
+     *            absolute path to create
+     * @param createUniqueLeaf
+     *            whether the leaf of the path should be regarded as a name hint
+     *            and a unique node name should be created by appending a number
+     *            to the given name (eg. <code>/some/path/foobar2</code>)
+     * @param intermediateNodeType
+     *            to use for creation of intermediate nodes. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param nodeType
+     *            to use for creation of the final node. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param session
+     *            to use
+     * @param autoSave
+     *            Should save be called when a new node is created?
+     * @return the Node at absolutePath
+     * @throws RepositoryException
+     *             in case of exception accessing the Repository
+     */
+    public static Node getOrCreateByPath(String absolutePath,
+                                  boolean createUniqueLeaf,
+                                  String intermediateNodeType,
+                                  String nodeType,
+                                  Session session,
+                                  boolean autoSave)
+            throws RepositoryException {
+        if (absolutePath == null || absolutePath.length() == 0 || "/".equals(absolutePath)) {
+            // path denotes root node
+            return session.getRootNode();
+        }
+        // create path relative to the root node
+        return getOrCreateByPath(session.getRootNode(), absolutePath.substring(1),
+                createUniqueLeaf, intermediateNodeType, nodeType, autoSave);
+    }
+
+    /**
+     * Creates or gets the {@link javax.jcr.Node Node} at the given Path. In
+     * case it has to create the Node all non-existent intermediate
+     * path-elements will be created with the given intermediate node type and
+     * the returned node will be created with the given nodeType.
+     *
+     * <p>
+     * If the node name points to an existing node, the node name will be
+     * regarded as a name hint and a unique node name will be created by
+     * appending a number to the given name (eg. <code>/some/path/foobar2</code>).
+     * Please note that <b>the uniqueness check is not an atomic JCR operation</b>,
+     * so it is possible that you get a {@link RepositoryException} (path
+     * already exists) if another concurrent session created the same node in
+     * the meantime.
+     *
+     * <p>
+     * Changes made are not saved by this method, so <code>session.save()</code>
+     * has to be called to persist them.
+     *
+     * @param parent
+     *            existing parent node for the new node
+     * @param nodeNameHint
+     *            name hint for the new node
+     * @param nodeType
+     *            to use for creation of the node. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @return the newly created Node
+     * @throws RepositoryException
+     *             in case of exception accessing the Repository
+     */
+    public static Node getOrCreateUniqueByPath(Node parent,
+                                        String nodeNameHint,
+                                        String nodeType)
+            throws RepositoryException {
+        return getOrCreateByPath(parent, nodeNameHint, true, nodeType, nodeType, false);
+    }
+
+    /**
+     * Creates or gets the {@link javax.jcr.Node Node} at the given path
+     * relative to the baseNode. In case it has to create the Node all
+     * non-existent intermediate path-elements will be created with the given
+     * intermediate node type and the returned node will be created with the
+     * given nodeType.
+     *
+     * <p>
+     * If the parameter <code>createUniqueLeaf</code> is set, it will not get
+     * an existing node but rather try to create a unique node by appending a
+     * number to the last path element (leaf node). Please note that <b>the
+     * uniqueness check is not an atomic JCR operation</b>, so it is possible
+     * that you get a {@link RepositoryException} (path already exists) if
+     * another concurrent session created the same node in the meantime.
+     *
+     * @param baseNode
+     *            existing node that should be the base for the relative path
+     * @param path
+     *            relative path to create
+     * @param createUniqueLeaf
+     *            whether the leaf of the path should be regarded as a name hint
+     *            and a unique node name should be created by appending a number
+     *            to the given name (eg. <code>/some/path/foobar2</code>)
+     * @param intermediateNodeType
+     *            to use for creation of intermediate nodes. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param nodeType
+     *            to use for creation of the final node. If <code>null</code> the node type
+     *            is determined by the child node definitions of the parent node.
+     * @param autoSave
+     *            Should save be called when a new node is created?
+     * @return the Node at path
+     * @throws RepositoryException
+     *             in case of exception accessing the Repository
+     */
+    public static Node getOrCreateByPath(Node baseNode,
+                                  String path,
+                                  boolean createUniqueLeaf,
+                                  String intermediateNodeType,
+                                  String nodeType,
+                                  boolean autoSave)
+            throws RepositoryException {
+
+        if (!createUniqueLeaf && baseNode.hasNode(path)) {
+            // node at path already exists, quicker way
+            return baseNode.getNode(path);
+        }
+
+        Node node = baseNode;
+        int pos = path.lastIndexOf('/');
+
+        // intermediate path elements
+        if (pos != -1) {
+            final StringTokenizer st = new StringTokenizer(path.substring(0, pos), "/");
+            while (st.hasMoreTokens()) {
+                final String token = st.nextToken();
+                if (!node.hasNode(token)) {
+                    try {
+                        if ( intermediateNodeType != null ) {
+                            node.addNode(token, intermediateNodeType);
+                        } else {
+                            node.addNode(token);
+                        }
+                        if (autoSave) node.getSession().save();
+                    } catch (RepositoryException e) {
+                        // we ignore this as this folder might be created from a different task
+                        node.refresh(false);
+                    }
+                }
+                node = node.getNode(token);
+            }
+            path = path.substring(pos + 1);
+        }
+
+        // last path element (path = leaf node name)
+        if (!node.hasNode(path)) {
+            if ( nodeType != null ) {
+                node.addNode(path, nodeType);
+            } else {
+                node.addNode(path);
+            }
+            if (autoSave) node.getSession().save();
+        } else if (createUniqueLeaf) {
+            // leaf node already exists, create new unique name
+            String leafNodeName;
+            int i = 0;
+            do {
+                leafNodeName = path + String.valueOf(i);
+                i++;
+            } while (node.hasNode(leafNodeName));
+
+            Node leaf;
+            if ( nodeType != null ) {
+                leaf = node.addNode(leafNodeName, nodeType);
+            } else {
+                leaf = node.addNode(leafNodeName);
+            }
+            if (autoSave) node.getSession().save();
+            return leaf;
+        }
+
+        return node.getNode(path);
+    }
 }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java Sun Sep 11 18:57:11 2011
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.commons.flat;
 
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.commons.iterator.FilterIterator;
+import org.apache.jackrabbit.commons.iterator.SizedIterator;
 import org.apache.jackrabbit.commons.predicate.Predicate;
 
 import javax.jcr.Item;

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/FilterIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/FilterIterator.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/FilterIterator.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/FilterIterator.java Sun Sep 11 18:57:11 2011
@@ -24,53 +24,18 @@ import java.util.NoSuchElementException;
 /**
  * Iterator filtering out items which do not match a given predicate.
  * @param <T>
+ * @deprecated use {@link org.apache.jackrabbit.commons.iterator.FilterIterator}
  */
-public class FilterIterator<T> implements Iterator<T> {
-    private final Iterator<T> iterator;
-    private final Predicate predicate;
-
-    private T next = null;
+public class FilterIterator<T> extends org.apache.jackrabbit.commons.iterator.FilterIterator<T> {
 
     /**
      * Create a new filtered iterator based on the given <code>iterator</code>.
      *
      * @param iterator  iterator to filter
-     * @param predicate  only item matching this predicate are included
-     */
-    public FilterIterator(Iterator<T> iterator, Predicate predicate) {
-        super();
-        this.iterator = iterator;
-        this.predicate = predicate;
-    }
-
-    public boolean hasNext() {
-        while (next == null && iterator.hasNext()) {
-            T e = iterator.next();
-            if (predicate.evaluate(e)) {
-                next = e;
-            }
-        }
-
-        return next != null;
-    }
-
-    public T next() {
-        if (hasNext()) {
-            T e = next;
-            next = null;
-            return e;
-        }
-        else {
-            throw new NoSuchElementException();
-        }
-    }
-
-    /**
-     * @throws  UnsupportedOperationException always
-     * @see java.util.Iterator#remove()
+     * @param predicate only item matching this predicate are included
      */
-    public void remove() {
-        throw new UnsupportedOperationException();
+    public FilterIterator(Iterator<T> tIterator, Predicate predicate) {
+        super(tIterator, predicate);
     }
 
 }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java Sun Sep 11 18:57:11 2011
@@ -19,17 +19,11 @@ package org.apache.jackrabbit.commons.fl
 import java.util.Iterator;
 
 /**
- * <code>SizedIterator</code> extends {@link Iterator} with a
+ * <code>SizedIterator</code> extends {@link java.util.Iterator} with a
  * <code>getSize</code> method.
  *
  * @param <T> the type of elements of this iterator
+ * @deprecated use {@link org.apache.jackrabbit.commons.iterator.SizedIterator}
  */
-public interface SizedIterator<T> extends Iterator<T> {
-
-    /**
-     * The number of elements of this iterator or -1 if not known.
-     *
-     * @return number of elements.
-     */
-    long getSize();
+public interface SizedIterator<T> extends org.apache.jackrabbit.commons.iterator.SizedIterator<T> {
 }

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java Sun Sep 11 18:57:11 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.commons.fl
 
 import static org.apache.jackrabbit.commons.iterator.LazyIteratorChain.chain;
 
+import org.apache.jackrabbit.commons.iterator.FilterIterator;
 import org.apache.jackrabbit.commons.predicate.Predicate;
 
 import javax.jcr.Item;

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java Sun Sep 11 18:57:11 2011
@@ -322,7 +322,7 @@ public abstract class ItemImpl implement
             /**
              * Nothing to do for
              * - Status#EXISTING : modifications reverted or saved
-             *   inform listeneres about an update (status was MODIFIED before)
+             *   inform listeners about an update (status was MODIFIED before)
              *   or a simple refresh without modification (status was INVALIDATED).
              */
             case Status.EXISTING:
@@ -335,7 +335,7 @@ public abstract class ItemImpl implement
              * - Status#EXISTING_MODIFIED : transient modification
              * - Status#STALE_MODIFIED : external modifications while transient changes pending
              * - Status#STALE_DESTROYED : external modifications while transient changes pending
-             * - Status#MODIFIED : externaly modified -> marker for sessionISM states only
+             * - Status#MODIFIED : externally modified -> marker for sessionISM states only
              * - Status#EXISTING_REMOVED : transient removal
              */
             case Status.EXISTING_MODIFIED:

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java Sun Sep 11 18:57:11 2011
@@ -34,7 +34,7 @@ import javax.jcr.Property;
  * instance. It is the factory for <code>Node</code> and <code>Property</code>
  * instances.
  * <p/>
- * The <code>ItemManager</code>'s responsabilities are:
+ * The <code>ItemManager</code>'s responsibilities are:
  * <ul>
  * <li>providing access to <code>Item</code> instances by <code>ItemState</code>
  * whereas <code>Node</code> and <code>Item</code> are only providing relative access.

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/Jcr2spiRepositoryFactory.java Sun Sep 11 18:57:11 2011
@@ -46,7 +46,7 @@ public class Jcr2spiRepositoryFactory im
     /**
      * This parameter determines the {@link RepositoryServiceFactory} to create the
      * {@link RepositoryService}. This is either an instance of <code>RepositoryServiceFactory
-     * </code> or a fully quallyfied class name of a <code>RepositoryServiceFactory</code>
+     * </code> or a fully qualified class name of a <code>RepositoryServiceFactory</code>
      * having a no argument constructor.
      */
     public static final String PARAM_REPOSITORY_SERVICE_FACTORY = "org.apache.jackrabbit.spi.RepositoryServiceFactory";

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java Sun Sep 11 18:57:11 2011
@@ -334,7 +334,7 @@ public class JcrVersionManager implement
      * after successful completion of the operation must reside within scope
      * defined by this session.
      * <br>
-     * In addition this method varifies that the passed node is of type nt:activity.
+     * In addition this method verifies that the passed node is of type nt:activity.
      *
      * @param activityNode
      * @param methodName

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Sun Sep 11 18:57:11 2011
@@ -714,7 +714,7 @@ public class NodeImpl extends ItemImpl i
         checkIsWritable();
         Name mixinQName = getQName(mixinName);
 
-        // get mixin types present in the jcr:mixintypes property without
+        // get mixin types present in the jcr:mixinTypes property without
         // modifying the NodeState.
         List<Name> mixinValue = getMixinTypes();
         if (!mixinValue.contains(mixinQName) && !isNodeType(mixinQName)) {

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java Sun Sep 11 18:57:11 2011
@@ -553,7 +553,7 @@ public class WorkspaceManager
     /**
      * Create a new workspace with the specified <code>name</code>. If
      * <code>srcWorkspaceName</code> isn't <code>null</code> the content of
-     * that workspace is used as inital content, otherwise an empty workspace
+     * that workspace is used as initial content, otherwise an empty workspace
      * will be created.
      *
      * @param name The name of the workspace to be created.
@@ -742,7 +742,7 @@ public class WorkspaceManager
 
     //--------------------------------------------------------------------------
     /**
-     * Called when local or external events occured. This method is called after
+     * Called when local or external events occurred. This method is called after
      * changes have been applied to the repository.
      *
      * @param eventBundles the event bundles generated by the repository service

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java Sun Sep 11 18:57:11 2011
@@ -120,7 +120,7 @@ public interface ChildNodeEntries {
     void add(NodeEntry entry, int index, NodeEntry beforeEntry);
 
     /**
-     * Removes the child node entry refering to the node state.
+     * Removes the child node entry referring to the node state.
      *
      * @param childEntry the entry to be removed.
      * @return the removed entry or <code>null</code> if there is no such entry.

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java Sun Sep 11 18:57:11 2011
@@ -105,7 +105,7 @@ final class ChildNodeEntriesImpl impleme
 
     /**
      * @param childEntry
-     * @return The node entry that directly preceeds the given <code>childEntry</code>
+     * @return The node entry that directly precedes the given <code>childEntry</code>
      * or <code>null</code> if the given <code>childEntry</code> is the first
      * or was not found in this <code>ChildNodeEntries</code>.
      */
@@ -318,7 +318,7 @@ final class ChildNodeEntriesImpl impleme
     }
 
     /**
-     * Removes the child node entry refering to the node state.
+     * Removes the child node entry referring to the node state.
      *
      * @param childEntry the entry to be removed.
      * @return the removed entry or <code>null</code> if there is no such entry.
@@ -414,7 +414,7 @@ final class ChildNodeEntriesImpl impleme
                         break;
                     } else if (ln != insertLN && insertName.equals(ln.qName)) {
                         position++;
-                    } // else: ln == inserLN OR no SNS -> not relevant for position count
+                    } // else: ln == insertLN OR no SNS -> not relevant for position count
                 }
             }
             entriesByName.reorder(insertName, insertLN, position);
@@ -728,10 +728,10 @@ final class ChildNodeEntriesImpl impleme
         private final Map<Name, LinkedEntries.LinkNode> nameMap = new HashMap<Name, LinkedEntries.LinkNode>();
 
         /**
-         * Return true if more than one NodeEnty with the given name exists.
+         * Return true if more than one NodeEntry with the given name exists.
          *
          * @param qName
-         * @return true if more than one NodeEnty with the given name exists.
+         * @return true if more than one NodeEntry with the given name exists.
          */
         public boolean containsSiblings(Name qName) {
             return snsMap.containsKey(qName);

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java Sun Sep 11 18:57:11 2011
@@ -176,7 +176,7 @@ public interface HierarchyEntry {
 
     /**
      * The required generation of this <code>HierarchyEntry</code> . This is used by the
-     * {@link ItemInfoCache} to determine wheter an item info in the cache is up to date or not.
+     * {@link ItemInfoCache} to determine whether an item info in the cache is up to date or not.
      * That is whether the generation of the item info in the cache is the same or more recent
      * as the required generation of this entry.
      */

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEventListener.java Sun Sep 11 18:57:11 2011
@@ -60,7 +60,7 @@ public class HierarchyEventListener impl
                 filter = wspManager.createEventFilter(Event.ALL_TYPES, root, true, null, null, true);
             } catch (RepositoryException e) {
                 // SPI does not support observation, or another error occurred.
-                log.debug("Creating event filter for cache behavoir observation failed", e);
+                log.debug("Creating event filter for cache behavior observation failed", e);
             }
             if (filter == null) {
                 this.eventFilter = Collections.emptyList();
@@ -189,7 +189,7 @@ public class HierarchyEventListener impl
                     }
                     break;
                 case Event.PROPERTY_CHANGED:
-                    // notify parent in case jcr:mixintypes or jcr:uuid was changed.
+                    // notify parent in case jcr:mixinTypes or jcr:uuid was changed.
                     // if parent is 'null' (i.e. not yet loaded) the prop-entry does
                     // not exist either -> no need to inform propEntry
                     if (parent != null) {

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Sun Sep 11 18:57:11 2011
@@ -70,7 +70,7 @@ public interface NodeEntry extends Hiera
     public void setUniqueID(String uniqueID);
 
     /**
-     * @return the index of this child node entry to suppport same-name siblings.
+     * @return the index of this child node entry to support same-name siblings.
      * If the index of this entry cannot be determined
      * {@link org.apache.jackrabbit.spi.Path#INDEX_UNDEFINED} is returned.
      * @throws InvalidItemStateException

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockManagerImpl.java Sun Sep 11 18:57:11 2011
@@ -138,7 +138,7 @@ public class LockManagerImpl implements 
 
     /**
      * If the session created a lock on the node with the given state, we already
-     * know the lock. Otherwise, the node state and its ancestores are searched
+     * know the lock. Otherwise, the node state and its ancestors are searched
      * for properties indicating a lock.<br>
      * Note, that the flag indicating session-scoped lock cannot be retrieved
      * unless the current session is the lock holder.
@@ -288,7 +288,7 @@ public class LockManagerImpl implements 
      * verification regarding nodetypes present.
      *
      * @param nodeState <code>NodeState</code> from which searching starts.
-     * Note, that the given state must not have an overlayed state.
+     * Note, that the given state must not have an overlaid state.
      * @return a state holding a lock or <code>null</code> if neither the
      * given state nor any of its ancestors is locked.
      */
@@ -657,7 +657,7 @@ public class LockManagerImpl implements 
         /**
          *
          * @param lockState
-         * Note, that the given state must not have an overlayed state.
+         * Note, that the given state must not have an overlaid state.
          * @param lockHoldingNode the lock holding <code>Node</code> itself.
          */
         public LockImpl(LockState lockState, Node lockHoldingNode) {

Modified: jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java?rev=1169501&r1=1169500&r2=1169501&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java (original)
+++ jackrabbit/branches/JCR-2936/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java Sun Sep 11 18:57:11 2011
@@ -269,7 +269,7 @@ class BitsetENTCacheImpl implements Effe
         /**
          * Creates a ew bitset key.
          * @param names the node type names
-         * @param maxBit the approximative number of the geatest bit
+         * @param maxBit the approximate number of the greatest bit
          */
         public BitsetKey(Name[] names, int maxBit) {
             this.names = names;



Mime
View raw message