You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ry...@apache.org on 2012/03/06 19:13:50 UTC
svn commit: r1297628 [3/13] - in /lucene/dev/branches/solr_3159_jetty8: ./
dev-tools/maven/ dev-tools/maven/lucene/ dev-tools/maven/lucene/contrib/demo/
dev-tools/maven/lucene/contrib/highlighter/
dev-tools/maven/lucene/contrib/memory/ dev-tools/maven/...
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiFields.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiFields.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiFields.java Tue Mar 6 18:13:38 2012
@@ -35,7 +35,7 @@ import org.apache.lucene.util.ReaderUtil
* Exposes flex API, merged from flex API of sub-segments.
* This is useful when you're interacting with an {@link
* IndexReader} implementation that consists of sequential
- * sub-readers (eg DirectoryReader or {@link
+ * sub-readers (eg {@link DirectoryReader} or {@link
* MultiReader}).
*
* <p><b>NOTE</b>: for multi readers, you'll get better
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiReader.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiReader.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/MultiReader.java Tue Mar 6 18:13:38 2012
@@ -19,15 +19,25 @@ package org.apache.lucene.index;
import java.io.IOException;
-/** An IndexReader which reads multiple indexes, appending
- * their content.
-
- <p><em>Please note:</em> This class extends from an internal (invisible)
- superclass that is generic: The type parameter {@code R} is
- {@link IndexReader}, see {@link #subReaders} and
- {@link #getSequentialSubReaders}.
+/** A {@link CompositeReader} which reads multiple indexes, appending
+ * their content. It can be used to create a view on several
+ * sub-readers (like {@link DirectoryReader}) and execute searches on it.
+ *
+ * <p> For efficiency, in this API documents are often referred to via
+ * <i>document numbers</i>, non-negative integers which each name a unique
+ * document in the index. These document numbers are ephemeral -- they may change
+ * as documents are added to and deleted from an index. Clients should thus not
+ * rely on a given document having the same number between sessions.
+ *
+ * <p><a name="thread-safety"></a><p><b>NOTE</b>: {@link
+ * IndexReader} instances are completely thread
+ * safe, meaning multiple threads can call any of its methods,
+ * concurrently. If your application requires external
+ * synchronization, you should <b>not</b> synchronize on the
+ * <code>IndexReader</code> instance; use your own
+ * (non-Lucene) objects instead.
*/
-public class MultiReader extends BaseMultiReader<IndexReader> {
+public class MultiReader extends BaseCompositeReader<IndexReader> {
private final boolean closeSubReaders;
/**
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java Tue Mar 6 18:13:38 2012
@@ -18,11 +18,8 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.codecs.DocValuesConsumer;
-import org.apache.lucene.document.DocValuesField;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.BytesRef;
public class NormsConsumerPerField extends InvertedDocEndConsumerPerField implements Comparable<NormsConsumerPerField> {
private final FieldInfo fieldInfo;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelAtomicReader.java Tue Mar 6 18:13:38 2012
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Collections;
-import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelCompositeReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelCompositeReader.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelCompositeReader.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/ParallelCompositeReader.java Tue Mar 6 18:13:38 2012
@@ -46,7 +46,7 @@ import java.util.Set;
* by number of documents per segment. If you use different {@link MergePolicy}s
* it might happen that the segment structure of your index is no longer predictable.
*/
-public final class ParallelCompositeReader extends BaseMultiReader<IndexReader> {
+public final class ParallelCompositeReader extends BaseCompositeReader<IndexReader> {
private final boolean closeSubReaders;
private final Set<CompositeReader> completeReaderSet =
Collections.newSetFromMap(new IdentityHashMap<CompositeReader,Boolean>());
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/PerDocWriteState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/PerDocWriteState.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/PerDocWriteState.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/PerDocWriteState.java Tue Mar 6 18:13:38 2012
@@ -1,22 +1,4 @@
package org.apache.lucene.index;
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.io.PrintStream;
-
import org.apache.lucene.codecs.PerDocConsumer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java Tue Mar 6 18:13:38 2012
@@ -81,7 +81,7 @@ public final class SortedBytesMergeUtils
}
}
- public static List<SortedSourceSlice> buildSlices(int[] docBases ,int[][] docMaps,
+ public static List<SortedSourceSlice> buildSlices(int[] docBases, int[][] docMaps,
DocValues[] docValues, MergeContext ctx) throws IOException {
final List<SortedSourceSlice> slices = new ArrayList<SortedSourceSlice>();
for (int i = 0; i < docValues.length; i++) {
@@ -111,7 +111,7 @@ public final class SortedBytesMergeUtils
* mapping in docIDToRelativeOrd. After the merge SortedSourceSlice#ordMapping
* contains the new global ordinals for the relative index.
*/
- private static void createOrdMapping(int[] docBases ,int[][] docMaps,
+ private static void createOrdMapping(int[] docBases, int[][] docMaps,
SortedSourceSlice currentSlice) {
final int readerIdx = currentSlice.readerIdx;
final int[] currentDocMap = docMaps[readerIdx];
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/index/TermsEnum.java Tue Mar 6 18:13:38 2012
@@ -179,13 +179,6 @@ public abstract class TermsEnum implemen
}
};
}
-
- /** Return the {@link BytesRef} Comparator used to sort
- * terms provided by the iterator. This may return
- * null if there are no terms. Callers may invoke this
- * method many times, so it's best to cache a single
- * instance & reuse it. */
- public abstract Comparator<BytesRef> getComparator() throws IOException;
/** An empty TermsEnum for quickly returning an empty instance e.g.
* in {@link org.apache.lucene.search.MultiTermQuery}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java Tue Mar 6 18:13:38 2012
@@ -203,8 +203,6 @@ final class BooleanScorer extends Scorer
private final int minNrShouldMatch;
private int end;
private Bucket current;
- private int doc = -1;
-
// Any time a prohibited clause matches we set bit 0:
private static final int PROHIBITED_MASK = 1;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java Tue Mar 6 18:13:38 2012
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery.BooleanWeight;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.search.Scorer.ChildScorer;
/* See the description in BooleanScorer.java, comparing
* BooleanScorer & BooleanScorer2 */
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java Tue Mar 6 18:13:38 2012
@@ -49,7 +49,7 @@ class ConjunctionTermScorer extends Scor
private int doNext(int doc) throws IOException {
do {
- if (lead.doc == DocsEnum.NO_MORE_DOCS) {
+ if (lead.doc == DocIdSetIterator.NO_MORE_DOCS) {
return NO_MORE_DOCS;
}
advanceHead: do {
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/ExactPhraseScorer.java Tue Mar 6 18:13:38 2012
@@ -76,7 +76,7 @@ final class ExactPhraseScorer extends Sc
// freq of rarest 2 terms is close:
final boolean useAdvance = postings[i].docFreq > 5*postings[0].docFreq;
chunkStates[i] = new ChunkState(postings[i].postings, -postings[i].position, useAdvance);
- if (i > 0 && postings[i].postings.nextDoc() == DocsEnum.NO_MORE_DOCS) {
+ if (i > 0 && postings[i].postings.nextDoc() == DocIdSetIterator.NO_MORE_DOCS) {
noDocs = true;
return;
}
@@ -89,7 +89,7 @@ final class ExactPhraseScorer extends Sc
// first (rarest) term
final int doc = chunkStates[0].posEnum.nextDoc();
- if (doc == DocsEnum.NO_MORE_DOCS) {
+ if (doc == DocIdSetIterator.NO_MORE_DOCS) {
docID = doc;
return doc;
}
@@ -140,8 +140,8 @@ final class ExactPhraseScorer extends Sc
// first term
int doc = chunkStates[0].posEnum.advance(target);
- if (doc == DocsEnum.NO_MORE_DOCS) {
- docID = DocsEnum.NO_MORE_DOCS;
+ if (doc == DocIdSetIterator.NO_MORE_DOCS) {
+ docID = DocIdSetIterator.NO_MORE_DOCS;
return doc;
}
@@ -171,7 +171,7 @@ final class ExactPhraseScorer extends Sc
}
doc = chunkStates[0].posEnum.nextDoc();
- if (doc == DocsEnum.NO_MORE_DOCS) {
+ if (doc == DocIdSetIterator.NO_MORE_DOCS) {
docID = doc;
return doc;
}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java Tue Mar 6 18:13:38 2012
@@ -367,7 +367,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -440,7 +440,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -544,7 +544,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -612,7 +612,7 @@ class FieldCacheImpl implements FieldCac
// TODO: use bulk API
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
res.set(docID);
@@ -694,7 +694,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -782,7 +782,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -871,7 +871,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
retArray[docID] = termval;
@@ -1052,7 +1052,7 @@ class FieldCacheImpl implements FieldCac
}
@Override
- public Comparator<BytesRef> getComparator() throws IOException {
+ public Comparator<BytesRef> getComparator() {
return BytesRef.getUTF8SortedAsUnicodeComparator();
}
@@ -1172,7 +1172,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
docToTermOrd.set(docID, termOrd);
@@ -1293,7 +1293,7 @@ class FieldCacheImpl implements FieldCac
docs = termsEnum.docs(null, docs, false);
while (true) {
final int docID = docs.nextDoc();
- if (docID == DocsEnum.NO_MORE_DOCS) {
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
docToOffset.set(docID, pointer);
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java Tue Mar 6 18:13:38 2012
@@ -459,6 +459,7 @@ public abstract class FieldCacheRangeFil
}
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
public final boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FieldCacheRangeFilter)) return false;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparator.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparator.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparator.java Tue Mar 6 18:13:38 2012
@@ -150,7 +150,7 @@ public abstract class FieldComparator<T>
* comparator across segments
* @throws IOException
*/
- public abstract FieldComparator setNextReader(AtomicReaderContext context) throws IOException;
+ public abstract FieldComparator<T> setNextReader(AtomicReaderContext context) throws IOException;
/** Sets the Scorer to use in case a document's score is
* needed.
@@ -201,7 +201,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<T> setNextReader(AtomicReaderContext context) throws IOException {
if (missingValue != null) {
docsWithField = FieldCache.DEFAULT.getDocsWithField(context.reader(), field);
// optimization to remove unneeded checks on the bit interface:
@@ -258,7 +258,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Byte> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getBytes(context.reader(), field, parser, missingValue != null);
@@ -335,7 +335,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Double> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getDoubles(context.reader(), field, parser, missingValue != null);
@@ -396,7 +396,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Double> setNextReader(AtomicReaderContext context) throws IOException {
final DocValues docValues = context.reader().docValues(field);
if (docValues != null) {
currentReaderValues = docValues.getSource();
@@ -478,7 +478,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Float> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getFloats(context.reader(), field, parser, missingValue != null);
@@ -540,7 +540,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Short> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getShorts(context.reader(), field, parser, missingValue != null);
@@ -624,7 +624,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Integer> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getInts(context.reader(), field, parser, missingValue != null);
@@ -689,7 +689,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Long> setNextReader(AtomicReaderContext context) throws IOException {
DocValues docValues = context.reader().docValues(field);
if (docValues != null) {
currentReaderValues = docValues.getSource();
@@ -772,7 +772,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<Long> setNextReader(AtomicReaderContext context) throws IOException {
// NOTE: must do this before calling super otherwise
// we compute the docsWithField Bits twice!
currentReaderValues = FieldCache.DEFAULT.getLongs(context.reader(), field, parser, missingValue != null);
@@ -824,7 +824,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) {
+ public FieldComparator<Float> setNextReader(AtomicReaderContext context) {
return this;
}
@@ -887,7 +887,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) {
+ public FieldComparator<Integer> setNextReader(AtomicReaderContext context) {
// TODO: can we "map" our docIDs to the current
// reader? saves having to then subtract on every
// compare call
@@ -1007,7 +1007,7 @@ public abstract class FieldComparator<T>
abstract class PerSegmentComparator extends FieldComparator<BytesRef> {
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
return TermOrdValComparator.this.setNextReader(context);
}
@@ -1055,32 +1055,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = (readerOrds[doc]&0xFF);
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (readerOrds[doc]&0xFF);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc]&0xFF;
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- if (bottomValue == null) {
- if (order == 0) {
- // unset
- return 0;
- }
- // bottom wins
- return -1;
- } else if (order == 0) {
- // doc wins
- return 1;
- }
- termsIndex.lookup(order, tempBR);
- return bottomValue.compareTo(tempBR);
+ return -1;
}
}
@@ -1116,32 +1101,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = (readerOrds[doc]&0xFFFF);
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (readerOrds[doc]&0xFFFF);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc]&0xFFFF;
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- if (bottomValue == null) {
- if (order == 0) {
- // unset
- return 0;
- }
- // bottom wins
- return -1;
- } else if (order == 0) {
- // doc wins
- return 1;
- }
- termsIndex.lookup(order, tempBR);
- return bottomValue.compareTo(tempBR);
+ return -1;
}
}
@@ -1177,32 +1147,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = readerOrds[doc];
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - readerOrds[doc];
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc];
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- if (bottomValue == null) {
- if (order == 0) {
- // unset
- return 0;
- }
- // bottom wins
- return -1;
- } else if (order == 0) {
- // doc wins
- return 1;
- }
- termsIndex.lookup(order, tempBR);
- return bottomValue.compareTo(tempBR);
+ return -1;
}
}
@@ -1239,32 +1194,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = (int) readerOrds.get(doc);
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (int) readerOrds.get(doc);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = (int) readerOrds.get(doc);
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- if (bottomValue == null) {
- if (order == 0) {
- // unset
- return 0;
- }
- // bottom wins
- return -1;
- } else if (order == 0) {
- // doc wins
- return 1;
- }
- termsIndex.lookup(order, tempBR);
- return bottomValue.compareTo(tempBR);
+ return -1;
}
}
@@ -1286,11 +1226,11 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
final int docBase = context.docBase;
termsIndex = FieldCache.DEFAULT.getTermsIndex(context.reader(), field);
final PackedInts.Reader docToOrd = termsIndex.getDocToOrd();
- FieldComparator perSegComp = null;
+ FieldComparator<BytesRef> perSegComp = null;
if (docToOrd.hasArray()) {
final Object arr = docToOrd.getArray();
if (arr instanceof byte[]) {
@@ -1457,7 +1397,7 @@ public abstract class FieldComparator<T>
abstract class PerSegmentComparator extends FieldComparator<BytesRef> {
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
return TermOrdValDocValuesComparator.this.setNextReader(context);
}
@@ -1499,21 +1439,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = readerOrds[doc]&0xFF;
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (readerOrds[doc]&0xFF);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc]&0xFF;
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- termsIndex.getByOrd(order, tempBR);
- return comp.compare(bottomValue, tempBR);
+ return -1;
}
}
@@ -1544,21 +1480,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = readerOrds[doc]&0xFFFF;
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (readerOrds[doc]&0xFFFF);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc]&0xFFFF;
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
-
- termsIndex.getByOrd(order, tempBR);
- return comp.compare(bottomValue, tempBR);
+ return -1;
}
}
@@ -1589,20 +1521,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = readerOrds[doc];
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - readerOrds[doc];
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = readerOrds[doc];
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
- termsIndex.getByOrd(order, tempBR);
- return comp.compare(bottomValue, tempBR);
+ return -1;
}
}
@@ -1632,20 +1561,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
assert bottomSlot != -1;
+ final int docOrd = (int) readerOrds.get(doc);
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - (int) readerOrds.get(doc);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = (int) readerOrds.get(doc);
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
- termsIndex.getByOrd(order, tempBR);
- return comp.compare(bottomValue, tempBR);
+ return -1;
}
}
@@ -1672,21 +1598,17 @@ public abstract class FieldComparator<T>
@Override
public int compareBottom(int doc) {
- assert bottomSlot != -1;
+ final int docOrd = termsIndex.ord(doc);
if (bottomSameReader) {
// ord is precisely comparable, even in the equal case
- return bottomOrd - termsIndex.ord(doc);
+ return bottomOrd - docOrd;
+ } else if (bottomOrd >= docOrd) {
+ // the equals case always means bottom is > doc
+ // (because we set bottomOrd to the lower bound in
+ // setBottom):
+ return 1;
} else {
- // ord is only approx comparable: if they are not
- // equal, we can use that; if they are equal, we
- // must fallback to compare by value
- final int order = termsIndex.ord(doc);
- final int cmp = bottomOrd - order;
- if (cmp != 0) {
- return cmp;
- }
- termsIndex.getByOrd(order, tempBR);
- return comp.compare(bottomValue, tempBR);
+ return -1;
}
}
@@ -1703,7 +1625,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
final int docBase = context.docBase;
final DocValues dv = context.reader().docValues(field);
@@ -1724,7 +1646,7 @@ public abstract class FieldComparator<T>
comp = termsIndex.getComparator();
- FieldComparator perSegComp = null;
+ FieldComparator<BytesRef> perSegComp = null;
if (termsIndex.hasPackedDocToOrd()) {
final PackedInts.Reader docToOrd = termsIndex.getDocToOrd();
if (docToOrd.hasArray()) {
@@ -1775,7 +1697,7 @@ public abstract class FieldComparator<T>
bottomSameReader = true;
readerGen[bottomSlot] = currentReaderGen;
} else {
- final int index = termsIndex.getByValue(bottomValue, tempBR);
+ final int index = termsIndex.getOrdByValue(bottomValue, tempBR);
if (index < 0) {
bottomOrd = -index - 2;
bottomSameReader = false;
@@ -1852,7 +1774,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
docTerms = FieldCache.DEFAULT.getTerms(context.reader(), field);
return this;
}
@@ -1921,7 +1843,7 @@ public abstract class FieldComparator<T>
}
@Override
- public FieldComparator setNextReader(AtomicReaderContext context) throws IOException {
+ public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
final DocValues dv = context.reader().docValues(field);
if (dv != null) {
docTerms = dv.getSource();
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparatorSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparatorSource.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparatorSource.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldComparatorSource.java Tue Mar 6 18:13:38 2012
@@ -36,6 +36,6 @@ public abstract class FieldComparatorSou
* @throws IOException
* If an error occurs reading the index.
*/
- public abstract FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed)
+ public abstract FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed)
throws IOException;
}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java Tue Mar 6 18:13:38 2012
@@ -129,6 +129,7 @@ public abstract class FieldValueHitQueue
}
// prevent instantiation and extension.
+ @SuppressWarnings({"rawtypes","unchecked"})
private FieldValueHitQueue(SortField[] fields, int size) {
super(size);
// When we get here, fields.length is guaranteed to be > 0, therefore no
@@ -169,7 +170,7 @@ public abstract class FieldValueHitQueue
}
}
- public FieldComparator[] getComparators() {
+ public FieldComparator<?>[] getComparators() {
return comparators;
}
@@ -177,15 +178,15 @@ public abstract class FieldValueHitQueue
return reverseMul;
}
- public void setComparator(int pos, FieldComparator comparator) {
+ public void setComparator(int pos, FieldComparator<?> comparator) {
if (pos==0) firstComparator = comparator;
comparators[pos] = comparator;
}
/** Stores the sort criteria being used. */
protected final SortField[] fields;
- protected final FieldComparator[] comparators; // use setComparator to change this array
- protected FieldComparator firstComparator; // this must always be equal to comparators[0]
+ protected final FieldComparator<?>[] comparators; // use setComparator to change this array
+ protected FieldComparator<?> firstComparator; // this must always be equal to comparators[0]
protected final int[] reverseMul;
@Override
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/FuzzyTermsEnum.java Tue Mar 6 18:13:38 2012
@@ -287,7 +287,7 @@ public final class FuzzyTermsEnum extend
}
@Override
- public Comparator<BytesRef> getComparator() throws IOException {
+ public Comparator<BytesRef> getComparator() {
return actualEnum.getComparator();
}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiPhraseQuery.java Tue Mar 6 18:13:38 2012
@@ -408,16 +408,12 @@ class UnionDocsAndPositionsEnum extends
Iterator<DocsAndPositionsEnum> i = docsEnums.iterator();
while (i.hasNext()) {
DocsAndPositionsEnum postings = i.next();
- if (postings.nextDoc() != DocsAndPositionsEnum.NO_MORE_DOCS) {
+ if (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
add(postings);
}
}
}
- final public DocsEnum peek() {
- return top();
- }
-
@Override
public final boolean lessThan(DocsAndPositionsEnum a, DocsAndPositionsEnum b) {
return a.docID() < b.docID();
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java Tue Mar 6 18:13:38 2012
@@ -60,6 +60,7 @@ public class MultiTermQueryWrapperFilter
}
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
public final boolean equals(final Object o) {
if (o==this) return true;
if (o==null) return false;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java Tue Mar 6 18:13:38 2012
@@ -352,6 +352,7 @@ public final class NumericRangeQuery<T e
}
@Override
+ @SuppressWarnings({"unchecked","rawtypes"})
public final boolean equals(final Object o) {
if (o==this) return true;
if (!super.equals(o))
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/SortField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/SortField.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/SortField.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/SortField.java Tue Mar 6 18:13:38 2012
@@ -376,7 +376,7 @@ public class SortField {
* optimize themselves when they are the primary sort.
* @return {@link FieldComparator} to use when sorting
*/
- public FieldComparator getComparator(final int numHits, final int sortPos) throws IOException {
+ public FieldComparator<?> getComparator(final int numHits, final int sortPos) throws IOException {
switch (type) {
case SCORE:
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java Tue Mar 6 18:13:38 2012
@@ -17,12 +17,12 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import java.io.IOException;
-
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.util.Counter;
import org.apache.lucene.util.ThreadInterruptedException;
+import java.io.IOException;
+
/**
* The {@link TimeLimitingCollector} is used to timeout search requests that
* take longer than the maximum allowed search time limit. After this time is
@@ -60,7 +60,7 @@ public class TimeLimitingCollector exten
private long t0 = Long.MIN_VALUE;
private long timeout = Long.MIN_VALUE;
- private final Collector collector;
+ private Collector collector;
private final Counter clock;
private final long ticksAllowed;
private boolean greedy = false;
@@ -172,6 +172,17 @@ public class TimeLimitingCollector exten
public boolean acceptsDocsOutOfOrder() {
return collector.acceptsDocsOutOfOrder();
}
+
+ /**
+ * This is so the same timer can be used with a multi-phase search process such as grouping.
+ * We don't want to create a new TimeLimitingCollector for each phase because that would
+ * reset the timer for each phase. Once time is up subsequent phases need to timeout quickly.
+ *
+ * @param collector The actual collector performing search functionality
+ */
+ public void setCollector(Collector collector) {
+ this.collector = collector;
+ }
/**
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopDocs.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopDocs.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopDocs.java Tue Mar 6 18:13:38 2012
@@ -116,10 +116,11 @@ public class TopDocs {
}
}
+ @SuppressWarnings({"rawtypes","unchecked"})
private static class MergeSortQueue extends PriorityQueue<ShardRef> {
// These are really FieldDoc instances:
final ScoreDoc[][] shardHits;
- final FieldComparator[] comparators;
+ final FieldComparator<?>[] comparators;
final int[] reverseMul;
public MergeSortQueue(Sort sort, TopDocs[] shardHits) throws IOException {
@@ -155,7 +156,7 @@ public class TopDocs {
}
// Returns true if first is < second
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked","rawtypes"})
public boolean lessThan(ShardRef first, ShardRef second) {
assert first != second;
final FieldDoc firstFD = (FieldDoc) shardHits[first.shardIndex][first.hitIndex];
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java Tue Mar 6 18:13:38 2012
@@ -46,7 +46,7 @@ public abstract class TopFieldCollector
private static class OneComparatorNonScoringCollector extends
TopFieldCollector {
- FieldComparator comparator;
+ FieldComparator<?> comparator;
final int reverseMul;
final FieldValueHitQueue<Entry> queue;
@@ -70,7 +70,7 @@ public abstract class TopFieldCollector
if (queueFull) {
if ((reverseMul * comparator.compareBottom(doc)) <= 0) {
// since docs are visited in doc Id order, if compare is 0, it means
- // this document is largest than anything else in the queue, and
+ // this document is larger than anything else in the queue, and
// therefore not competitive.
return;
}
@@ -382,7 +382,7 @@ public abstract class TopFieldCollector
*/
private static class MultiComparatorNonScoringCollector extends TopFieldCollector {
- final FieldComparator[] comparators;
+ final FieldComparator<?>[] comparators;
final int[] reverseMul;
final FieldValueHitQueue<Entry> queue;
public MultiComparatorNonScoringCollector(FieldValueHitQueue<Entry> queue,
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Tue Mar 6 18:13:38 2012
@@ -135,7 +135,8 @@ public class PayloadSpanUtil {
}
}
- @SuppressWarnings("unchecked") final List<Query>[] disjunctLists = new List[maxPosition + 1];
+ @SuppressWarnings({"rawtypes","unchecked"}) final List<Query>[] disjunctLists =
+ new List[maxPosition + 1];
int distinctPositions = 0;
for (int i = 0; i < termArrays.size(); ++i) {
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java Tue Mar 6 18:13:38 2012
@@ -25,7 +25,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.ComplexExplanation;
-import org.apache.lucene.search.payloads.PayloadNearQuery.PayloadNearSpanScorer;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.search.similarities.Similarity.SloppySimScorer;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/SpanMultiTermQueryWrapper.java Tue Mar 6 18:13:38 2012
@@ -60,6 +60,7 @@ public class SpanMultiTermQueryWrapper<Q
* Be sure to not change the rewrite method on the wrapped query afterwards! Doing so will
* throw {@link UnsupportedOperationException} on rewriting this query!
*/
+ @SuppressWarnings({"rawtypes","unchecked"})
public SpanMultiTermQueryWrapper(Q query) {
this.query = query;
@@ -123,6 +124,7 @@ public class SpanMultiTermQueryWrapper<Q
}
@Override
+ @SuppressWarnings({"rawtypes","unchecked"})
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/search/spans/TermSpans.java Tue Mar 6 18:13:38 2012
@@ -56,7 +56,7 @@ public class TermSpans extends Spans {
return false;
}
doc = postings.nextDoc();
- if (doc == DocsAndPositionsEnum.NO_MORE_DOCS) {
+ if (doc == DocIdSetIterator.NO_MORE_DOCS) {
return false;
}
freq = postings.freq();
@@ -70,7 +70,7 @@ public class TermSpans extends Spans {
@Override
public boolean skipTo(int target) throws IOException {
doc = postings.advance(target);
- if (doc == DocsAndPositionsEnum.NO_MORE_DOCS) {
+ if (doc == DocIdSetIterator.NO_MORE_DOCS) {
return false;
}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRef.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRef.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRef.java Tue Mar 6 18:13:38 2012
@@ -233,13 +233,7 @@ public final class BytesRef implements C
final byte[] bBytes = b.bytes;
int bUpto = b.offset;
- final int aStop;
- if (a.length < b.length) {
- aStop = aUpto + a.length;
- } else {
- aStop = aUpto + b.length;
- }
-
+ final int aStop = aUpto + Math.min(a.length, b.length);
while(aUpto < aStop) {
int aByte = aBytes[aUpto++] & 0xff;
int bByte = bBytes[bUpto++] & 0xff;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/BytesRefIterator.java Tue Mar 6 18:13:38 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.util;
*/
import java.io.IOException;
+import java.util.Comparator;
/**
* A simple iterator interface for {@link BytesRef} iteration
@@ -40,6 +41,14 @@ public interface BytesRefIterator {
*/
public BytesRef next() throws IOException;
+ /**
+ * Return the {@link BytesRef} Comparator used to sort terms provided by the
+ * iterator. This may return null if there are no items or the iterator is not
+ * sorted. Callers may invoke this method many times, so it's best to cache a
+ * single instance & reuse it.
+ */
+ public Comparator<BytesRef> getComparator();
+
public final static class EmptyBytesRefIterator implements BytesRefIterator {
@Override
@@ -47,6 +56,10 @@ public interface BytesRefIterator {
return null;
}
+ public Comparator<BytesRef> getComparator() {
+ return null;
+ }
+
}
}
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java Tue Mar 6 18:13:38 2012
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.CompositeReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.FieldCache;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/IndexableBinaryStringTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/IndexableBinaryStringTools.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/IndexableBinaryStringTools.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/IndexableBinaryStringTools.java Tue Mar 6 18:13:38 2012
@@ -17,8 +17,6 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute; // javadoc
/**
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/ReaderUtil.java Tue Mar 6 18:13:38 2012
@@ -17,13 +17,10 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.CompositeReader;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.IndexReader;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java Tue Mar 6 18:13:38 2012
@@ -430,7 +430,7 @@ public class Automaton implements Clonea
}
}
// map<state, set<state>>
- @SuppressWarnings("unchecked") Set<State> map[] = new Set[states.length];
+ @SuppressWarnings({"rawtypes","unchecked"}) Set<State> map[] = new Set[states.length];
for (int i = 0; i < map.length; i++)
map[i] = new HashSet<State>();
for (State s : states) {
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/MinimizationOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/MinimizationOperations.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/MinimizationOperations.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/automaton/MinimizationOperations.java Tue Mar 6 18:13:38 2012
@@ -74,11 +74,11 @@ final public class MinimizationOperation
final int[] sigma = a.getStartPoints();
final State[] states = a.getNumberedStates();
final int sigmaLen = sigma.length, statesLen = states.length;
- @SuppressWarnings("unchecked") final ArrayList<State>[][] reverse =
+ @SuppressWarnings({"rawtypes","unchecked"}) final ArrayList<State>[][] reverse =
(ArrayList<State>[][]) new ArrayList[statesLen][sigmaLen];
- @SuppressWarnings("unchecked") final HashSet<State>[] partition =
+ @SuppressWarnings({"rawtypes","unchecked"}) final HashSet<State>[] partition =
(HashSet<State>[]) new HashSet[statesLen];
- @SuppressWarnings("unchecked") final ArrayList<State>[] splitblock =
+ @SuppressWarnings({"rawtypes","unchecked"}) final ArrayList<State>[] splitblock =
(ArrayList<State>[]) new ArrayList[statesLen];
final int[] block = new int[statesLen];
final StateList[][] active = new StateList[statesLen][sigmaLen];
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Builder.java Tue Mar 6 18:13:38 2012
@@ -144,7 +144,8 @@ public class Builder<T> {
}
NO_OUTPUT = outputs.getNoOutput();
- @SuppressWarnings("unchecked") final UnCompiledNode<T>[] f = (UnCompiledNode<T>[]) new UnCompiledNode[10];
+ @SuppressWarnings({"rawtypes","unchecked"}) final UnCompiledNode<T>[] f =
+ (UnCompiledNode<T>[]) new UnCompiledNode[10];
frontier = f;
for(int idx=0;idx<frontier.length;idx++) {
frontier[idx] = new UnCompiledNode<T>(this, idx);
@@ -239,7 +240,8 @@ public class Builder<T> {
if (node.inputCount < minSuffixCount2 || (minSuffixCount2 == 1 && node.inputCount == 1 && idx > 1)) {
// drop all arcs
for(int arcIdx=0;arcIdx<node.numArcs;arcIdx++) {
- @SuppressWarnings("unchecked") final UnCompiledNode<T> target = (UnCompiledNode<T>) node.arcs[arcIdx].target;
+ @SuppressWarnings({"rawtypes","unchecked"}) final UnCompiledNode<T> target =
+ (UnCompiledNode<T>) node.arcs[arcIdx].target;
target.clear();
}
node.numArcs = 0;
@@ -356,7 +358,7 @@ public class Builder<T> {
final int prefixLenPlus1 = pos1+1;
if (frontier.length < input.length+1) {
- @SuppressWarnings("unchecked") final UnCompiledNode<T>[] next =
+ @SuppressWarnings({"rawtypes","unchecked"}) final UnCompiledNode<T>[] next =
new UnCompiledNode[ArrayUtil.oversize(input.length+1, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
System.arraycopy(frontier, 0, next, 0, frontier.length);
for(int idx=frontier.length;idx<next.length;idx++) {
@@ -458,7 +460,7 @@ public class Builder<T> {
final Arc<T> arc = node.arcs[arcIdx];
if (!arc.target.isCompiled()) {
// not yet compiled
- @SuppressWarnings("unchecked") final UnCompiledNode<T> n = (UnCompiledNode<T>) arc.target;
+ @SuppressWarnings({"rawtypes","unchecked"}) final UnCompiledNode<T> n = (UnCompiledNode<T>) arc.target;
if (n.numArcs == 0) {
//System.out.println("seg=" + segment + " FORCE final arc=" + (char) arc.label);
arc.isFinal = n.isFinal = true;
@@ -512,7 +514,7 @@ public class Builder<T> {
* LUCENE-2934 (node expansion based on conditions other than the
* fanout size).
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"rawtypes","unchecked"})
public UnCompiledNode(Builder<T> owner, int depth) {
this.owner = owner;
arcs = (Arc<T>[]) new Arc[1];
@@ -545,7 +547,7 @@ public class Builder<T> {
assert label >= 0;
assert numArcs == 0 || label > arcs[numArcs-1].label: "arc[-1].label=" + arcs[numArcs-1].label + " new label=" + label + " numArcs=" + numArcs;
if (numArcs == arcs.length) {
- @SuppressWarnings("unchecked") final Arc<T>[] newArcs =
+ @SuppressWarnings({"rawtypes","unchecked"}) final Arc<T>[] newArcs =
new Arc[ArrayUtil.oversize(numArcs+1, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
System.arraycopy(arcs, 0, newArcs, 0, arcs.length);
for(int arcIdx=numArcs;arcIdx<newArcs.length;arcIdx++) {
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FST.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FST.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FST.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FST.java Tue Mar 6 18:13:38 2012
@@ -376,7 +376,7 @@ public final class FST<T> {
}
// Caches first 128 labels
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"rawtypes","unchecked"})
private void cacheRootArcs() throws IOException {
cachedRootArcs = (Arc<T>[]) new Arc[0x80];
final Arc<T> arc = new Arc<T>();
@@ -840,6 +840,7 @@ public final class FST<T> {
}
public Arc<T> readFirstRealTargetArc(int node, Arc<T> arc, final BytesReader in) throws IOException {
+ assert in.bytes == bytes;
final int address = getNodeAddress(node);
in.pos = address;
//System.out.println(" readFirstRealTargtArc address="
@@ -936,6 +937,7 @@ public final class FST<T> {
/** Never returns null, but you should never call this if
* arc.isLast() is true. */
public Arc<T> readNextRealArc(Arc<T> arc, final BytesReader in) throws IOException {
+ assert in.bytes == bytes;
// TODO: can't assert this because we call from readFirstArc
// assert !flag(arc.flags, BIT_LAST_ARC);
@@ -1019,6 +1021,7 @@ public final class FST<T> {
* This returns null if the arc was not found, else the incoming arc. */
public Arc<T> findTargetArc(int labelToMatch, Arc<T> follow, Arc<T> arc, BytesReader in) throws IOException {
assert cachedRootArcs != null;
+ assert in.bytes == bytes;
if (labelToMatch == END_LABEL) {
if (follow.isFinal()) {
@@ -1225,17 +1228,20 @@ public final class FST<T> {
/** Expert */
public static abstract class BytesReader extends DataInput {
- int pos;
+ protected int pos;
+ protected final byte[] bytes;
+ protected BytesReader(byte[] bytes, int pos) {
+ this.bytes = bytes;
+ this.pos = pos;
+ }
abstract void skip(int byteCount);
abstract void skip(int base, int byteCount);
}
final static class ReverseBytesReader extends BytesReader {
- final byte[] bytes;
public ReverseBytesReader(byte[] bytes, int pos) {
- this.bytes = bytes;
- this.pos = pos;
+ super(bytes, pos);
}
@Override
@@ -1262,11 +1268,9 @@ public final class FST<T> {
// TODO: can we use just ByteArrayDataInput...? need to
// add a .skipBytes to DataInput.. hmm and .setPosition
final static class ForwardBytesReader extends BytesReader {
- final byte[] bytes;
public ForwardBytesReader(byte[] bytes, int pos) {
- this.bytes = bytes;
- this.pos = pos;
+ super(bytes, pos);
}
@Override
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FSTEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FSTEnum.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FSTEnum.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/FSTEnum.java Tue Mar 6 18:13:38 2012
@@ -30,9 +30,9 @@ import java.io.IOException;
abstract class FSTEnum<T> {
protected final FST<T> fst;
- @SuppressWarnings("unchecked") protected FST.Arc<T>[] arcs = new FST.Arc[10];
+ @SuppressWarnings({"rawtypes","unchecked"}) protected FST.Arc<T>[] arcs = new FST.Arc[10];
// outputs are cumulative
- @SuppressWarnings("unchecked") protected T[] output = (T[]) new Object[10];
+ @SuppressWarnings({"rawtypes","unchecked"}) protected T[] output = (T[]) new Object[10];
protected final T NO_OUTPUT;
protected final FST.Arc<T> scratchArc = new FST.Arc<T>();
@@ -462,13 +462,13 @@ abstract class FSTEnum<T> {
upto++;
grow();
if (arcs.length <= upto) {
- @SuppressWarnings("unchecked") final FST.Arc<T>[] newArcs =
+ @SuppressWarnings({"rawtypes","unchecked"}) final FST.Arc<T>[] newArcs =
new FST.Arc[ArrayUtil.oversize(1+upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
System.arraycopy(arcs, 0, newArcs, 0, arcs.length);
arcs = newArcs;
}
if (output.length <= upto) {
- @SuppressWarnings("unchecked") final T[] newOutput =
+ @SuppressWarnings({"rawtypes","unchecked"}) final T[] newOutput =
(T[]) new Object[ArrayUtil.oversize(1+upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
System.arraycopy(output, 0, newOutput, 0, output.length);
output = newOutput;
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Util.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Util.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/fst/Util.java Tue Mar 6 18:13:38 2012
@@ -83,11 +83,6 @@ public final class Util {
}
}
- // TODO: parameterize the FST type <T> and allow passing in a
- // comparator; eg maybe your output is a PairOutput and
- // one of the outputs in the pair is monotonic so you
- // compare by that
-
/** Reverse lookup (lookup by output instead of by input),
* in the special case when your FSTs outputs are
* strictly ascending. This locates the input/output
@@ -133,7 +128,7 @@ public final class Util {
}
}
- if (fst.targetHasArcs(arc)) {
+ if (FST.targetHasArcs(arc)) {
//System.out.println(" targetHasArcs");
if (result.ints.length == upto) {
result.grow(1+upto);
@@ -155,7 +150,7 @@ public final class Util {
final byte flags = in.readByte();
fst.readLabel(in);
final long minArcOutput;
- if ((flags & fst.BIT_ARC_HAS_OUTPUT) != 0) {
+ if ((flags & FST.BIT_ARC_HAS_OUTPUT) != 0) {
final long arcOutput = fst.outputs.read(in);
minArcOutput = output + arcOutput;
} else {
@@ -235,14 +230,16 @@ public final class Util {
}
}
- private static class FSTPath implements Comparable<FSTPath> {
- public FST.Arc<Long> arc;
- public long cost;
+ private static class FSTPath<T> implements Comparable<FSTPath<T>> {
+ public FST.Arc<T> arc;
+ public T cost;
public final IntsRef input = new IntsRef();
+ final Comparator<T> comparator;
- public FSTPath(long cost, FST.Arc<Long> arc) {
- this.arc = new FST.Arc<Long>().copyFrom(arc);
+ public FSTPath(T cost, FST.Arc<T> arc, Comparator<T> comparator) {
+ this.arc = new FST.Arc<T>().copyFrom(arc);
this.cost = cost;
+ this.comparator = comparator;
}
@Override
@@ -251,48 +248,50 @@ public final class Util {
}
@Override
- public int compareTo(FSTPath other) {
- if (cost < other.cost) {
- return -1;
- } else if (cost > other.cost) {
- return 1;
- } else {
+ public int compareTo(FSTPath<T> other) {
+ int cmp = comparator.compare(cost, other.cost);
+ if (cmp == 0) {
return input.compareTo(other.input);
+ } else {
+ return cmp;
}
}
}
- private static class TopNSearcher {
+ private static class TopNSearcher<T> {
- private final FST<Long> fst;
- private final FST.Arc<Long> fromNode;
+ private final FST<T> fst;
+ private final FST.Arc<T> fromNode;
private final int topN;
+
+ final Comparator<T> comparator;
// Set once the queue has filled:
- FSTPath bottom = null;
+ FSTPath<T> bottom = null;
- TreeSet<FSTPath> queue = null;
+ TreeSet<FSTPath<T>> queue = null;
- public TopNSearcher(FST<Long> fst, FST.Arc<Long> fromNode, int topN) {
+ public TopNSearcher(FST<T> fst, FST.Arc<T> fromNode, int topN, Comparator<T> comparator) {
this.fst = fst;
this.topN = topN;
this.fromNode = fromNode;
+ this.comparator = comparator;
}
// If back plus this arc is competitive then add to queue:
- private void addIfCompetitive(FSTPath path) {
+ private void addIfCompetitive(FSTPath<T> path) {
assert queue != null;
- long cost = path.cost + path.arc.output;
+ T cost = fst.outputs.add(path.cost, path.arc.output);
//System.out.println(" addIfCompetitive bottom=" + bottom + " queue.size()=" + queue.size());
if (bottom != null) {
-
- if (cost > bottom.cost) {
+ int comp = comparator.compare(cost, bottom.cost);
+ if (comp > 0) {
// Doesn't compete
return;
- } else if (cost == bottom.cost) {
+ } else if (comp == 0) {
// Tie break by alpha sort on the input:
path.input.grow(path.input.length+1);
path.input.ints[path.input.length++] = path.arc.label;
@@ -309,7 +308,7 @@ public final class Util {
// Queue isn't full yet, so any path we hit competes:
}
- final FSTPath newPath = new FSTPath(cost, path.arc);
+ final FSTPath<T> newPath = new FSTPath<T>(cost, path.arc, comparator);
newPath.input.grow(path.input.length+1);
System.arraycopy(path.input.ints, 0, newPath.input.ints, 0, path.input.length);
@@ -319,7 +318,7 @@ public final class Util {
//System.out.println(" add path=" + newPath);
queue.add(newPath);
if (bottom != null) {
- final FSTPath removed = queue.pollLast();
+ final FSTPath<T> removed = queue.pollLast();
assert removed == bottom;
bottom = queue.last();
//System.out.println(" now re-set bottom: " + bottom + " queue=" + queue);
@@ -330,13 +329,13 @@ public final class Util {
}
}
- public MinResult[] search() throws IOException {
+ public MinResult<T>[] search() throws IOException {
//System.out.println(" search topN=" + topN);
- final FST.Arc<Long> scratchArc = new FST.Arc<Long>();
+ final FST.Arc<T> scratchArc = new FST.Arc<T>();
- final List<MinResult> results = new ArrayList<MinResult>();
+ final List<MinResult<T>> results = new ArrayList<MinResult<T>>();
- final Long NO_OUTPUT = fst.outputs.getNoOutput();
+ final T NO_OUTPUT = fst.outputs.getNoOutput();
// TODO: we could enable FST to sorting arcs by weight
// as it freezes... can easily do this on first pass
@@ -349,7 +348,7 @@ public final class Util {
while (results.size() < topN) {
//System.out.println("\nfind next path");
- FSTPath path;
+ FSTPath<T> path;
if (queue == null) {
@@ -360,20 +359,20 @@ public final class Util {
// First pass (top path): start from original fromNode
if (topN > 1) {
- queue = new TreeSet<FSTPath>();
+ queue = new TreeSet<FSTPath<T>>();
}
- long minArcCost = Long.MAX_VALUE;
- FST.Arc<Long> minArc = null;
+ T minArcCost = null;
+ FST.Arc<T> minArc = null;
- path = new FSTPath(0, fromNode);
+ path = new FSTPath<T>(NO_OUTPUT, fromNode, comparator);
fst.readFirstTargetArc(fromNode, path.arc);
// Bootstrap: find the min starting arc
while (true) {
- long arcScore = path.arc.output;
+ T arcScore = path.arc.output;
//System.out.println(" arc=" + (char) path.arc.label + " cost=" + arcScore);
- if (arcScore < minArcCost) {
+ if (minArcCost == null || comparator.compare(arcScore, minArcCost) < 0) {
minArcCost = arcScore;
minArc = scratchArc.copyFrom(path.arc);
//System.out.println(" **");
@@ -419,7 +418,7 @@ public final class Util {
//System.out.println(" empty string! cost=" + path.cost);
// Empty string!
path.input.length--;
- results.add(new MinResult(path.input, path.cost));
+ results.add(new MinResult<T>(path.input, path.cost, comparator));
continue;
}
@@ -439,15 +438,16 @@ public final class Util {
// For each input letter:
while (true) {
- //System.out.println("\n cycle path: " + path);
-
+ //System.out.println("\n cycle path: " + path);
fst.readFirstTargetArc(path.arc, path.arc);
// For each arc leaving this node:
boolean foundZero = false;
while(true) {
//System.out.println(" arc=" + (char) path.arc.label + " cost=" + path.arc.output);
- if (path.arc.output == NO_OUTPUT) {
+ // tricky: instead of comparing output == 0, we must
+ // express it via the comparator compare(output, 0) == 0
+ if (comparator.compare(NO_OUTPUT, path.arc.output) == 0) {
if (queue == null) {
foundZero = true;
break;
@@ -479,55 +479,53 @@ public final class Util {
if (path.arc.label == FST.END_LABEL) {
// Add final output:
//System.out.println(" done!: " + path);
- results.add(new MinResult(path.input, path.cost + path.arc.output));
+ results.add(new MinResult<T>(path.input, fst.outputs.add(path.cost, path.arc.output), comparator));
break;
} else {
path.input.grow(1+path.input.length);
path.input.ints[path.input.length] = path.arc.label;
path.input.length++;
- path.cost += path.arc.output;
+ path.cost = fst.outputs.add(path.cost, path.arc.output);
}
}
}
- return results.toArray(new MinResult[results.size()]);
+ @SuppressWarnings({"rawtypes","unchecked"}) final MinResult<T>[] arr =
+ (MinResult<T>[]) new MinResult[results.size()];
+ return results.toArray(arr);
}
}
- // TODO: parameterize the FST type <T> and allow passing in a
- // comparator; eg maybe your output is a PairOutput and
- // one of the outputs in the pair is monotonic so you
- // compare by that
-
- public final static class MinResult implements Comparable<MinResult> {
+ public final static class MinResult<T> implements Comparable<MinResult<T>> {
public final IntsRef input;
- public final long output;
- public MinResult(IntsRef input, long output) {
+ public final T output;
+ final Comparator<T> comparator;
+ public MinResult(IntsRef input, T output, Comparator<T> comparator) {
this.input = input;
this.output = output;
+ this.comparator = comparator;
}
@Override
- public int compareTo(MinResult other) {
- if (output < other.output) {
- return -1;
- } else if (output > other.output) {
- return 1;
- } else {
+ public int compareTo(MinResult<T> other) {
+ int cmp = comparator.compare(output, other.output);
+ if (cmp == 0) {
return input.compareTo(other.input);
+ } else {
+ return cmp;
}
}
}
- /** Starting from node, find the top N min cost (Long
- * output) completions to a final node.
+ /** Starting from node, find the top N min cost
+ * completions to a final node.
*
* <p>NOTE: you must share the outputs when you build the
* FST (pass doShare=true to {@link
* PositiveIntOutputs#getSingleton}). */
- public static MinResult[] shortestPaths(FST<Long> fst, FST.Arc<Long> fromNode, int topN) throws IOException {
- return new TopNSearcher(fst, fromNode, topN).search();
+ public static <T> MinResult<T>[] shortestPaths(FST<T> fst, FST.Arc<T> fromNode, Comparator<T> comparator, int topN) throws IOException {
+ return new TopNSearcher<T>(fst, fromNode, topN, comparator).search();
}
/**
@@ -639,7 +637,7 @@ public final class Util {
while (!thisLevelQueue.isEmpty()) {
final FST.Arc<T> arc = thisLevelQueue.remove(thisLevelQueue.size() - 1);
//System.out.println(" pop: " + arc);
- if (fst.targetHasArcs(arc)) {
+ if (FST.targetHasArcs(arc)) {
// scan all target arcs
//System.out.println(" readFirstTarget...");
final int node = arc.target;
@@ -694,7 +692,7 @@ public final class Util {
outs = "";
}
- if (!fst.targetHasArcs(arc) && arc.isFinal() && arc.nextFinalOutput != NO_OUTPUT) {
+ if (!FST.targetHasArcs(arc) && arc.isFinal() && arc.nextFinalOutput != NO_OUTPUT) {
// Tricky special case: sometimes, due to
// pruning, the builder can [sillily] produce
// an FST with an arc into the final end state
Modified: lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java?rev=1297628&r1=1297627&r2=1297628&view=diff
==============================================================================
--- lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java (original)
+++ lucene/dev/branches/solr_3159_jetty8/lucene/core/src/java/org/apache/lucene/util/packed/Direct16.java Tue Mar 6 18:13:38 2012
@@ -69,6 +69,7 @@ class Direct16 extends PackedInts.Reader
}
public long get(final int index) {
+ assert index >= 0 && index < size();
return 0xFFFFL & values[index];
}