Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/PredicateDerefQuery.java (revision )
@@ -16,10 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Set;
-
import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.jackrabbit.spi.Name;
import org.apache.lucene.index.IndexReader;
@@ -32,6 +28,10 @@
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Set;
+
/**
* Implements a Lucene Query which returns the nodes which have a
* reference property which matches the nodes of the subquery.
@@ -258,49 +258,44 @@
this.subQueryHits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
-
/**
* Perform the sub query
* For each reference property UUID
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java (revision )
@@ -369,7 +369,7 @@
// never fulltext index jcr:uuid String
if (name.equals(NameConstants.JCR_UUID)) {
addStringValue(doc, fieldName, value.getString(),
- false, false, DEFAULT_BOOST);
+ false, false, DEFAULT_BOOST, true);
} else {
addStringValue(doc, fieldName, value.getString(),
true, isIncludedInNodeIndex(name),
@@ -666,7 +666,7 @@
* addStringValue(Document, String, Object, boolean)} instead.
*/
protected void addStringValue(Document doc, String fieldName, Object internalValue) {
- addStringValue(doc, fieldName, internalValue, true, true, DEFAULT_BOOST);
+ addStringValue(doc, fieldName, internalValue, true, true, DEFAULT_BOOST, true);
}
/**
@@ -682,7 +682,7 @@
*/
protected void addStringValue(Document doc, String fieldName,
Object internalValue, boolean tokenized) {
- addStringValue(doc, fieldName, internalValue, tokenized, true, DEFAULT_BOOST);
+ addStringValue(doc, fieldName, internalValue, tokenized, true, DEFAULT_BOOST, true);
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/QueryHitsQuery.java (revision )
@@ -214,48 +214,44 @@
docs = sortedDocs.iterator();
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
if (docs.hasNext()) {
currentDoc = docs.next();
- return true;
}
- return false;
+ else {
+ currentDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- */
- public int doc() {
return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
+ public int docID() {
+ return currentDoc == null? -1 : currentDoc;
+ }
+
+ @Override
public float score() throws IOException {
return scores.get(currentDoc);
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
do {
- if (!next()) {
- return false;
+ if (nextDoc() == NO_MORE_DOCS) {
+ return NO_MORE_DOCS;
}
- } while (target > doc());
- return true;
+ } while (target > docID());
+ return docID();
}
- /**
- * {@inheritDoc}
- */
- public Explanation explain(int doc) throws IOException {
- return new Explanation();
- }
- }
+ }
+}
-}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java (revision )
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.core.query.lucene;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
@@ -180,14 +179,16 @@
this.reader = reader;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (docNo == NO_MORE_DOCS) {
+ return docNo;
+ }
+
if (docNo == -1) {
// get first doc of context scorer
int docId = contextScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+ if (docId != NO_MORE_DOCS) {
contextNo = docId;
}
}
@@ -200,50 +201,45 @@
while (contextNo != -1 && contextNo == docNo) {
docNo++;
int docId = contextScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
- contextNo = docId;
- } else {
+ if (docId == NO_MORE_DOCS) {
contextNo = -1;
+ } else {
+ contextNo = docId;
}
}
- return docNo < reader.maxDoc();
+ if (docNo >= reader.maxDoc()) {
+ docNo = NO_MORE_DOCS;
- }
+ }
+ return docNo;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return docNo;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (docNo == NO_MORE_DOCS) {
+ return docNo;
+ }
+
if (contextNo != -1 && contextNo < target) {
int docId = contextScorer.advance(target);
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
+ if (docId != NO_MORE_DOCS) {
contextNo = docId;
} else {
contextNo = -1;
}
}
docNo = target - 1;
- return next();
+ return nextDoc();
}
- /**
- * @throws UnsupportedOperationException always
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
- }
+ }
+}
-}
Index: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java
===================================================================
--- jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java (revision 881299)
+++ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexMigrationTest.java (revision )
@@ -16,10 +16,7 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
+import junit.framework.TestCase;
import org.apache.jackrabbit.core.query.lucene.directory.DirectoryManager;
import org.apache.jackrabbit.core.query.lucene.directory.RAMDirectoryManager;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -27,8 +24,11 @@
import org.apache.lucene.document.Field;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
/**
* IndexMigrationTest contains a test case for JCR-2393.
@@ -50,7 +50,7 @@
DirectoryManager dirMgr = new RAMDirectoryManager();
PersistentIndex idx = new PersistentIndex("index",
- new StandardAnalyzer(), Similarity.getDefault(),
+ new StandardAnalyzer(Version.LUCENE_24), Similarity.getDefault(),
new DocNumberCache(100),
new IndexingQueue(new IndexingQueueStore(new RAMDirectory())),
dirMgr, 0);
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractScoreDocComparator.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractScoreDocComparator.java (revision 782644)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractScoreDocComparator.java (revision )
@@ -16,17 +16,17 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.util.List;
-import java.util.ArrayList;
-import java.io.IOException;
-
-import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.ScoreDocComparator;
import org.apache.lucene.search.SortField;
-import org.apache.lucene.index.IndexReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
- * Abstract base class of {@link ScoreDocComparator} implementations.
+ * Abstract base class of {@link ScoreDocComparator} implementations.// fixme lucene
*/
abstract class AbstractScoreDocComparator implements ScoreDocComparator {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/RangeQuery.java (revision )
@@ -16,14 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
@@ -39,6 +31,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* Implements a variant of the lucene class {@link org.apache.lucene.search.RangeQuery}.
* This class does not rewrite to basic {@link org.apache.lucene.search.TermQuery}
@@ -358,44 +358,42 @@
hits = result;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * Returns an empty Explanation object.
- * @return an empty Explanation object.
- */
- public Explanation explain(int doc) {
- return new Explanation();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ParentAxisQuery.java (revision )
@@ -16,12 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.jackrabbit.core.query.lucene.hits.Hits;
import org.apache.jackrabbit.core.query.lucene.hits.ScorerHits;
@@ -34,6 +28,12 @@
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Weight;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
/**
* ParentAxisQuery selects the parent nodes of a context query.
*/
@@ -268,25 +268,26 @@
this.hResolver = resolver;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateParent();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
Float score = scores.get(nextDoc);
if (score == null) {
@@ -295,23 +296,18 @@
return score;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateParent();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
private void calculateParent() throws IOException {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/AbstractExcerpt.java (revision )
@@ -250,6 +250,7 @@
termMap.put(termText, info);
}
ts.end();
+ ts.close();
} catch (IOException e) {
// should never happen, we are reading from a string
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java (revision 782644)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/UpperCaseSortComparator.java (revision )
@@ -16,19 +16,19 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-
-import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.ScoreDocComparator;
import org.apache.lucene.search.SortComparatorSource;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.SortField;
+import java.io.IOException;
+
/**
* UpperCaseSortComparator implements a sort comparator that
* compares the upper-cased string values of a base sort comparator.
*/
-public class UpperCaseSortComparator implements SortComparatorSource {
+public class UpperCaseSortComparator implements SortComparatorSource {// fixme lucene
private static final long serialVersionUID = 2562371983498948119L;
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/WildcardQuery.java (revision )
@@ -316,44 +316,42 @@
hits = result;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateHits();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * Returns an empty Explanation object.
- * @return an empty Explanation object.
- */
- public Explanation explain(int doc) {
- return new Explanation();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldCache.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldCache.java (revision 782644)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldCache.java (revision )
@@ -18,18 +18,17 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
import org.apache.lucene.index.TermEnum;
import org.apache.lucene.index.TermPositions;
-import org.apache.lucene.index.TermDocs;
import org.apache.lucene.search.SortComparatorSource;
+import javax.jcr.PropertyType;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
-import javax.jcr.PropertyType;
-
/**
* Implements a variant of the lucene class org.apache.lucene.search.FieldCacheImpl.
* The lucene FieldCache class has some sort of support for custom comparators
@@ -147,7 +146,7 @@
public ValueIndex getValueIndex(IndexReader reader,
String field,
String prefix,
- SortComparatorSource comparator)
+ SortComparatorSource comparator)// fixme lucene
throws IOException {
if (reader instanceof ReadOnlyIndexReader) {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java (revision 831851)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedLuceneQueryHits.java (revision )
@@ -16,10 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.jackrabbit.core.id.NodeId;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
@@ -29,6 +25,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+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
@@ -155,8 +155,8 @@
//-------------------------------< internal >-------------------------------
private void getHits() throws IOException {
- TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);
- searcher.search(query, collector);
+ TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);// fixme lucene
+ searcher.search(query, collector);// fixme lucene
this.size = collector.getTotalHits();
ScoreDoc[] docs = collector.topDocs().scoreDocs;
for (int i = scoreDocs.size(); i < docs.length; i++) {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java (revision 784760)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/Ordering.java (revision )
@@ -16,23 +16,23 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.QOMTreeVisitor;
+import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.commons.query.qom.DefaultTraversingQOMTreeVisitor;
-import org.apache.jackrabbit.spi.commons.query.qom.LengthImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.PropertyValueImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.LowerCaseImpl;
import org.apache.jackrabbit.spi.commons.query.qom.DynamicOperandImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.UpperCaseImpl;
import org.apache.jackrabbit.spi.commons.query.qom.FullTextSearchScoreImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.LengthImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.LowerCaseImpl;
import org.apache.jackrabbit.spi.commons.query.qom.NodeLocalNameImpl;
import org.apache.jackrabbit.spi.commons.query.qom.NodeNameImpl;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.lucene.search.SortField;
+import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.PropertyValueImpl;
+import org.apache.jackrabbit.spi.commons.query.qom.QOMTreeVisitor;
+import org.apache.jackrabbit.spi.commons.query.qom.UpperCaseImpl;
import org.apache.lucene.search.SortComparatorSource;
+import org.apache.lucene.search.SortField;
+import javax.jcr.RepositoryException;
+
/**
* Ordering implements a single ordering specification.
*/
@@ -84,7 +84,7 @@
* QOM ordering.
*/
public static Ordering fromQOM(final OrderingImpl ordering,
- final SortComparatorSource scs,
+ final SortComparatorSource scs,// fixme lucene
final NamespaceMappings nsMappings)
throws RepositoryException {
final Name[] selectorName = new Name[1];
@@ -93,7 +93,7 @@
public Object visit(LengthImpl node, Object data) throws Exception {
PropertyValueImpl propValue = (PropertyValueImpl) node.getPropertyValue();
selectorName[0] = propValue.getSelectorQName();
- return new SortField(propValue.getPropertyQName().toString(),
+ return new SortField(propValue.getPropertyQName().toString(),// fixme lucene
new LengthSortComparator(nsMappings),
!ordering.isAscending());
}
@@ -103,7 +103,7 @@
SortField sf = (SortField) ((DynamicOperandImpl) node.getOperand()).accept(this, data);
selectorName[0] = node.getSelectorQName();
return new SortField(sf.getField(),
- new LowerCaseSortComparator(sf.getFactory()),
+ new LowerCaseSortComparator(sf.getFactory()),// fixme lucene
!ordering.isAscending());
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java (revision 784061)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SortedMultiColumnQueryHits.java (revision )
@@ -16,20 +16,20 @@
*/
package org.apache.jackrabbit.core.query.lucene;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.search.SortField;
+
import java.io.IOException;
-import java.util.List;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.search.ScoreDocComparator;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.jackrabbit.spi.Name;
-
/**
* SortedMultiColumnQueryHits implements sorting of query hits
* based on {@link Ordering}s.
@@ -113,7 +113,7 @@
/**
* The score doc comparator for each of the {@link #orderings}.
*/
- private final ScoreDocComparator[] comparators;
+ private final ScoreDocComparator[] comparators; // fixme lucene
/**
* The reverse flag for each of the {@link #orderings}.
@@ -148,12 +148,12 @@
this.orderings = orderings;
List names = Arrays.asList(selectorNames);
this.idx = new int[orderings.length];
- this.comparators = new ScoreDocComparator[orderings.length];
+ this.comparators = new ScoreDocComparator[orderings.length];// fixme lucene
this.isReverse = new boolean[orderings.length];
for (int i = 0; i < orderings.length; i++) {
idx[i] = names.indexOf(orderings[i].getSelectorName());
SortField sf = orderings[i].getSortField();
- if (sf.getFactory() != null) {
+ if (sf.getFactory() != null) {// fixme lucene
comparators[i] = sf.getFactory().newComparator(reader, sf.getField());
}
isReverse[i] = sf.getReverse();
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java (revision 756444)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SingletonTokenStream.java (revision )
@@ -16,12 +16,13 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-
-import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.index.Payload;
+import java.io.IOException;
+
/**
* SingletonTokenStream implements a token stream that wraps a
* single value with a given property type. The property type is stored as a
@@ -38,42 +39,44 @@
* The payload of the token.
*/
private final Payload payload;
+ private TermAttribute termAttribute;
+ private PayloadAttribute payloadAttribute;
/**
- * Creates a new SingleTokenStream with the given value and a property
- * type.
+ * Creates a new SingleTokenStream with the given value and payload.
*
* @param value the string value that will be returned with the token.
- * @param type the JCR property type.
+ * @param payload the payload that will be attached to this token
*/
- public SingletonTokenStream(String value, int type) {
+ public SingletonTokenStream(String value, Payload payload) {
this.value = value;
- this.payload = new Payload(new PropertyMetaData(type).toByteArray());
+ this.payload = payload;
+ termAttribute = (TermAttribute) addAttribute(TermAttribute.class);
+ payloadAttribute = (PayloadAttribute) addAttribute(PayloadAttribute.class);
}
/**
- * Creates a new SingleTokenStream with the given token.
+ * Creates a new SingleTokenStream with the given value and a property
+ * type.
*
- * @param t the token.
+ * @param value the string value that will be returned with the token.
+ * @param type the JCR property type.
*/
- public SingletonTokenStream(Token t) {
- this.value = t.term();
- this.payload = t.getPayload();
+ public SingletonTokenStream(String value, int type) {
+ this(value, new Payload(new PropertyMetaData(type).toByteArray()));
}
- /**
- * {@inheritDoc}
- */
- public Token next(Token reusableToken) throws IOException {
+ @Override
+ public boolean incrementToken() throws IOException {
if (value == null) {
- return null;
+ return false;
}
- reusableToken.clear();
- reusableToken.setTermBuffer(value);
- reusableToken.setPayload(payload);
- reusableToken.setStartOffset(0);
- reusableToken.setEndOffset(value.length());
+
+ clearAttributes();
+ termAttribute.setTermBuffer(value);
+ payloadAttribute.setPayload(payload);
+
value = null;
- return reusableToken;
+ return true;
}
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (revision 1055117)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (revision )
@@ -16,27 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.InvalidQueryException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.jackrabbit.core.HierarchyManager;
import org.apache.jackrabbit.core.SessionImpl;
import org.apache.jackrabbit.core.fs.FileSystem;
@@ -50,6 +29,7 @@
import org.apache.jackrabbit.core.query.QueryHandlerContext;
import org.apache.jackrabbit.core.query.lucene.directory.DirectoryManager;
import org.apache.jackrabbit.core.query.lucene.directory.FSDirectoryManager;
+import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.jackrabbit.core.session.SessionContext;
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.ItemStateManager;
@@ -63,15 +43,17 @@
import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory;
import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl;
import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.index.Payload;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
-import org.apache.lucene.search.HitCollector;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Similarity;
@@ -85,6 +67,26 @@
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* Implements a {@link org.apache.jackrabbit.core.query.QueryHandler} using
* Lucene.
@@ -442,7 +444,7 @@
/**
* The sort comparator source for indexed properties.
*/
- private SortComparatorSource scs;
+ private SortComparatorSource scs;// fixme lucene
/**
* Flag that indicates whether the hierarchy cache should be initialized
@@ -691,7 +693,8 @@
try {
Query q = new TermQuery(new Term(
FieldNames.WEAK_REFS, id.toString()));
- searcher.search(q, new HitCollector() {
+ searcher.search(q, new AbstractHitCollector() {
+ @Override
public void collect(int doc, float score) {
docs.add(doc);
}
@@ -1030,7 +1033,7 @@
sortFields.add(new SortField(null, SortField.SCORE, orderSpecs[i]));
} else {
if ("upper-case".equals(orderFuncs[i])) {
- sortFields.add(new SortField(orderProps[i].getString(), new UpperCaseSortComparator(scs), !orderSpecs[i]));
+ sortFields.add(new SortField(orderProps[i].getString(), new UpperCaseSortComparator(scs), !orderSpecs[i]));// fixme lucene
} else if ("lower-case".equals(orderFuncs[i])) {
sortFields.add(new SortField(orderProps[i].getString(), new LowerCaseSortComparator(scs), !orderSpecs[i]));
} else {
@@ -1100,7 +1103,7 @@
*/
protected SortComparatorSource getSortComparatorSource() {
return scs;
- }
+ }// fixme lucene
/**
* @param namespaceMappings The namespace mappings
@@ -1376,11 +1379,15 @@
try {
// find the right fields to transfer
Fieldable[] fields = aDoc.getFieldables(FieldNames.PROPERTIES);
- Token t = new Token();
for (Fieldable field : fields) {
+
// assume properties fields use SingleTokenStream
- t = field.tokenStreamValue().next(t);
- String value = new String(t.termBuffer(), 0, t.termLength());
+ TokenStream tokenStream = field.tokenStreamValue();
+ TermAttribute termAttribute = (TermAttribute) tokenStream.addAttribute(TermAttribute.class);
+ PayloadAttribute payloadAttribute = (PayloadAttribute) tokenStream.addAttribute(PayloadAttribute.class);
+ tokenStream.incrementToken();
+
+ String value = new String(termAttribute.termBuffer(), 0, termAttribute.termLength());
if (value.startsWith(namePrefix)) {
// extract value
value = value.substring(namePrefix.length());
@@ -1388,9 +1395,11 @@
Path p = getRelativePath(state, propState);
String path = getNamespaceMappings().translatePath(p);
value = FieldNames.createNamedValue(path, value);
- t.setTermBuffer(value);
- doc.add(new Field(field.name(), new SingletonTokenStream(t)));
- doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, parent.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
+ termAttribute.setTermBuffer(value);
+ doc.add(new Field(field.name(),
+ new SingletonTokenStream(value, (Payload) payloadAttribute.getPayload().clone())));
+ doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID,
+ parent.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
}
}
} finally {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java (revision )
@@ -16,17 +16,16 @@
*/
package org.apache.jackrabbit.core.query.lucene;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.Weight;
import org.apache.lucene.search.Sort;
-import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
+import org.apache.lucene.search.Weight;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,10 +33,10 @@
import javax.jcr.RepositoryException;
import java.io.IOException;
import java.util.BitSet;
-import java.util.Set;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
-import java.util.Iterator;
/**
* Implements a lucene Query which filters a sub query by checking
@@ -431,6 +430,8 @@
*/
private final int[] singleDoc = new int[1];
+ private int currentDoc = -1;
+
/**
* Creates a new DescendantSelfAxisScorer.
*
@@ -447,53 +448,57 @@
this.contextHits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
- collectContextHits();
- int nextDoc = subScorer.nextDoc();
- if (nextDoc == DocIdSetIterator.NO_MORE_DOCS || contextHits.isEmpty()) {
- return false;
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
}
- while (nextDoc != DocIdSetIterator.NO_MORE_DOCS) {
- if (isValid(nextDoc)) {
- return true;
+ collectContextHits();
+ currentDoc = subScorer.nextDoc();
+ if (contextHits.isEmpty()) {
+ currentDoc = NO_MORE_DOCS;
- }
+ }
+ while (currentDoc != NO_MORE_DOCS) {
+ if (isValid(currentDoc)) {
+ return currentDoc;
+ }
// try next
- nextDoc = subScorer.nextDoc();
+ currentDoc = subScorer.nextDoc();
}
- return false;
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return subScorer.docID();
+ @Override
+ public int docID() {
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return subScorer.score();
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- int docId = subScorer.nextDoc();
- if (docId != DocIdSetIterator.NO_MORE_DOCS) {
- collectContextHits();
- return isValid(docId) || next();
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
+ currentDoc = subScorer.nextDoc();
+ if (currentDoc == NO_MORE_DOCS) {
+ return NO_MORE_DOCS;
} else {
- return false;
+ collectContextHits();
+ if (isValid(currentDoc)) {
+ return currentDoc;
- }
+ }
+ else {
+ return nextDoc();
- }
+ }
+ }
+ }
private void collectContextHits() throws IOException {
if (!contextHitsCalculated) {
@@ -518,14 +523,6 @@
}
/**
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /**
* Returns true if doc is a valid match from
* the sub scorer against the context hits. The caller must ensure
* that the context hits are calculated before this method is called!
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldSortComparator.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldSortComparator.java (revision 793840)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SharedFieldSortComparator.java (revision )
@@ -16,30 +16,30 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.ScoreDocComparator;
-import org.apache.lucene.search.SortComparator;
-import org.apache.lucene.document.Document;
-import org.apache.jackrabbit.core.state.ItemStateManager;
-import org.apache.jackrabbit.core.state.PropertyState;
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.state.ItemStateManager;
+import org.apache.jackrabbit.core.state.PropertyState;
import org.apache.jackrabbit.core.value.InternalValue;
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
import org.apache.jackrabbit.spi.commons.name.PathBuilder;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.search.SortComparator;
+import java.io.IOException;
+
/**
* Implements a SortComparator which knows how to sort on a lucene
* field that contains values for multiple properties.
*/
-public class SharedFieldSortComparator extends SortComparator {
+public class SharedFieldSortComparator extends SortComparator {// fixme lucene
private static final long serialVersionUID = 2609351820466200052L;
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiScorer.java (revision )
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Similarity;
@@ -49,6 +48,8 @@
*/
private boolean hasNext = true;
+ private int currentDoc = -1;
+
/**
* Creates a new MultiScorer that spans multiple
* scorers.
@@ -63,13 +64,16 @@
this.starts = starts;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
while (hasNext) {
- if (scorers[current].nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
- return true;
+ if (scorers[current].nextDoc() != NO_MORE_DOCS) {
+ currentDoc = scorers[current].docID() + starts[current];
+ return currentDoc;
} else if (++current < scorers.length) {
// advance to next scorer
} else {
@@ -77,38 +81,41 @@
hasNext = false;
}
}
- return hasNext;
+
+ currentDoc = NO_MORE_DOCS;
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return scorers[current].docID() + starts[current];
+ @Override
+ public int docID() {
+ return currentDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return scorers[current].score();
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (currentDoc == NO_MORE_DOCS) {
+ return currentDoc;
+ }
+
current = scorerIndex(target);
- if (scorers[current].advance(target - starts[current]) != DocIdSetIterator.NO_MORE_DOCS) {
- return true;
+ if (scorers[current].advance(target - starts[current]) != NO_MORE_DOCS) {
+ currentDoc = scorers[current].docID() + starts[current];
+ return currentDoc;
} else {
if (++current < scorers.length) {
// simply move to the next if there is any
- return next();
+ currentDoc = nextDoc();
+ return currentDoc;
} else {
// no more document
hasNext = false;
- return hasNext;
+ currentDoc = NO_MORE_DOCS;
+ return currentDoc;
}
}
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DerefQuery.java (revision )
@@ -258,46 +258,42 @@
this.hits = new BitSet(reader.maxDoc());
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LengthSortComparator.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LengthSortComparator.java (revision 783337)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LengthSortComparator.java (revision )
@@ -16,21 +16,21 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-
-import org.apache.lucene.search.SortComparatorSource;
-import org.apache.lucene.search.ScoreDocComparator;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.index.IndexReader;
import org.apache.jackrabbit.spi.NameFactory;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.search.SortComparatorSource;
+import java.io.IOException;
+
/**
* LengthSortComparator implements a sort comparator source that
* sorts on the length of property values.
*/
-public class LengthSortComparator implements SortComparatorSource {
+public class LengthSortComparator implements SortComparatorSource {// fixme lucene
private static final long serialVersionUID = 2513564768671391632L;
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ChildAxisQuery.java (revision )
@@ -387,52 +387,48 @@
this.hResolver = hResolver;
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
do {
nextDoc = hits.next();
} while (nextDoc > -1 && !indexIsValid(nextDoc));
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
calculateChildren();
nextDoc = hits.skipTo(target);
while (nextDoc > -1 && !indexIsValid(nextDoc)) {
- next();
+ nextDoc();
}
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException this implementation always
- * throws an UnsupportedOperationException.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
+ return nextDoc;
}
private void calculateChildren() throws IOException {
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LowerCaseSortComparator.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LowerCaseSortComparator.java (revision 782644)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LowerCaseSortComparator.java (revision )
@@ -16,19 +16,19 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-
-import org.apache.lucene.search.ScoreDocComparator;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.ScoreDocComparator;
import org.apache.lucene.search.SortComparatorSource;
-import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.SortField;
+import java.io.IOException;
+
/**
* LowerCaseSortComparator implements a sort comparator that
* compares the lower-cased string values of a base sort comparator.
*/
-public class LowerCaseSortComparator implements SortComparatorSource {
+public class LowerCaseSortComparator implements SortComparatorSource {// fixme lucene
private static final long serialVersionUID = 5396206509020979445L;
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MatchAllScorer.java (revision )
@@ -57,11 +57,6 @@
private BitSet docFilter;
/**
- * Explanation object. the same for all docs
- */
- private final Explanation matchExpl;
-
- /**
* Creates a new MatchAllScorer.
*
* @param reader the IndexReader
@@ -74,59 +69,49 @@
super(Similarity.getDefault());
this.reader = reader;
this.field = field;
- matchExpl
- = new Explanation(Similarity.getDefault().idf(reader.maxDoc(),
- reader.maxDoc()),
- "matchAll");
calculateDocFilter(cache);
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void score(Collector collector) throws IOException {
collector.setScorer(this);
- while (next()) {
- collector.collect(doc());
+ while (nextDoc() != NO_MORE_DOCS) {
+ collector.collect(docID());
}
}
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
+ @Override
+ public int nextDoc() throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
+ }
+
nextDoc = docFilter.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
+ if (nextDoc < 0) {
+ nextDoc = NO_MORE_DOCS;
- }
+ }
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
+ @Override
+ public int docID() {
return nextDoc;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public float score() throws IOException {
return 1.0f;
}
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- nextDoc = target - 1;
- return next();
+ @Override
+ public int advance(int target) throws IOException {
+ if (nextDoc == NO_MORE_DOCS) {
+ return nextDoc;
- }
+ }
- /**
- * {@inheritDoc}
- */
- public Explanation explain(int doc) {
- return matchExpl;
+ nextDoc = target - 1;
+ return nextDoc();
}
/**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java (revision 959982)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ReadOnlyIndexReader.java (revision )
@@ -16,13 +16,14 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
import org.apache.lucene.index.TermPositions;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Map;
+
/**
* Overwrites the methods that would modify the index and throws an
* {@link UnsupportedOperationException} in each of those methods. A
@@ -175,7 +176,8 @@
/**
* @exception UnsupportedOperationException always
*/
- protected final void doCommit() {
+ @Override
+ protected void doCommit(Map commitUserData) throws IOException {
throw new UnsupportedOperationException("IndexReader is read-only");
}
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java (revision 1060863)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MoreLikeThis.java (revision )
@@ -755,6 +755,8 @@
cnt.x++;
}
}
+ ts.end();
+ ts.close();
}
/** determines if the passed term is likely to be of interest in "more like" comparisons
Index: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java
===================================================================
--- jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java (revision 884522)
+++ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ChainedTermEnumTest.java (revision )
@@ -16,12 +16,7 @@
*/
package org.apache.jackrabbit.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
+import junit.framework.TestCase;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -31,8 +26,13 @@
import org.apache.lucene.index.TermEnum;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
-import junit.framework.TestCase;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
/**
* ChainedTermEnumTest implements a test for JCR-2410.
@@ -61,7 +61,7 @@
protected TermEnum createTermEnum(String prefix, int numTerms)
throws IOException {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_24),
true, IndexWriter.MaxFieldLength.UNLIMITED);
for (int i = 0; i < numTerms; i++) {
Document doc = new Document();
@@ -70,7 +70,7 @@
writer.addDocument(doc);
}
writer.close();
- IndexReader reader = IndexReader.open(dir);
+ IndexReader reader = IndexReader.open(dir, false);
TermEnum terms = reader.terms();
if (terms.term() == null) {
// position at first term