You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2013/02/05 09:24:35 UTC
svn commit: r1442497 - in /lucene/dev/trunk/lucene/core/src:
java/org/apache/lucene/search/ java/org/apache/lucene/util/
test/org/apache/lucene/search/
Author: simonw
Date: Tue Feb 5 08:24:35 2013
New Revision: 1442497
URL: http://svn.apache.org/viewvc?rev=1442497&view=rev
Log:
LUCENE-4744: Remove FieldCache.StopFillChacheException
Modified:
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCache.java
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCache.java?rev=1442497&r1=1442496&r2=1442497&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCache.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCache.java Tue Feb 5 08:24:35 2013
@@ -19,7 +19,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.io.PrintStream;
-import java.text.DecimalFormat;
import org.apache.lucene.analysis.NumericTokenStream; // for javadocs
import org.apache.lucene.document.IntField; // for javadocs
@@ -28,6 +27,7 @@ import org.apache.lucene.document.LongFi
import org.apache.lucene.document.DoubleField; // for javadocs
import org.apache.lucene.index.DocTermOrds;
import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -53,20 +53,21 @@ public interface FieldCache {
}
/**
- * Hack: When thrown from a Parser (NUMERIC_UTILS_* ones), this stops
- * processing terms and returns the current FieldCache
- * array.
- * @lucene.internal
- */
- public static final class StopFillCacheException extends RuntimeException {
- }
-
- /**
* Marker interface as super-interface to all parsers. It
* is used to specify a custom parser to {@link
* SortField#SortField(String, FieldCache.Parser)}.
*/
public interface Parser {
+
+ /**
+ * Pulls a {@link TermsEnum} from the given {@link Terms}. This method allows certain parsers
+ * to filter the actual TermsEnum before the field cache is filled.
+ *
+ * @param terms the {@link Terms} instance to create the {@link TermsEnum} from.
+ * @return a possibly filtered {@link TermsEnum} instance, this method must not return <code>null</code>.
+ * @throws IOException if an {@link IOException} occurs
+ */
+ public TermsEnum termsEnum(Terms terms) throws IOException;
}
/** Interface to parse bytes from document fields.
@@ -134,6 +135,10 @@ public interface FieldCache {
public String toString() {
return FieldCache.class.getName()+".DEFAULT_BYTE_PARSER";
}
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
};
/** The default parser for short values, which are encoded by {@link Short#toString(short)} */
@@ -150,6 +155,11 @@ public interface FieldCache {
public String toString() {
return FieldCache.class.getName()+".DEFAULT_SHORT_PARSER";
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
};
/** The default parser for int values, which are encoded by {@link Integer#toString(int)} */
@@ -162,6 +172,12 @@ public interface FieldCache {
// directly from byte[]
return Integer.parseInt(term.utf8ToString());
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
+
@Override
public String toString() {
return FieldCache.class.getName()+".DEFAULT_INT_PARSER";
@@ -178,6 +194,12 @@ public interface FieldCache {
// directly from byte[]
return Float.parseFloat(term.utf8ToString());
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
+
@Override
public String toString() {
return FieldCache.class.getName()+".DEFAULT_FLOAT_PARSER";
@@ -194,6 +216,12 @@ public interface FieldCache {
// directly from byte[]
return Long.parseLong(term.utf8ToString());
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
+
@Override
public String toString() {
return FieldCache.class.getName()+".DEFAULT_LONG_PARSER";
@@ -210,6 +238,12 @@ public interface FieldCache {
// directly from byte[]
return Double.parseDouble(term.utf8ToString());
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
+
@Override
public String toString() {
return FieldCache.class.getName()+".DEFAULT_DOUBLE_PARSER";
@@ -223,10 +257,14 @@ public interface FieldCache {
public static final IntParser NUMERIC_UTILS_INT_PARSER=new IntParser(){
@Override
public int parseInt(BytesRef term) {
- if (NumericUtils.getPrefixCodedIntShift(term) > 0)
- throw new StopFillCacheException();
return NumericUtils.prefixCodedToInt(term);
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return NumericUtils.filterPrefixCodedInts(terms.iterator(null));
+ }
+
@Override
public String toString() {
return FieldCache.class.getName()+".NUMERIC_UTILS_INT_PARSER";
@@ -240,14 +278,17 @@ public interface FieldCache {
public static final FloatParser NUMERIC_UTILS_FLOAT_PARSER=new FloatParser(){
@Override
public float parseFloat(BytesRef term) {
- if (NumericUtils.getPrefixCodedIntShift(term) > 0)
- throw new StopFillCacheException();
return NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(term));
}
@Override
public String toString() {
return FieldCache.class.getName()+".NUMERIC_UTILS_FLOAT_PARSER";
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return NumericUtils.filterPrefixCodedInts(terms.iterator(null));
+ }
};
/**
@@ -257,14 +298,17 @@ public interface FieldCache {
public static final LongParser NUMERIC_UTILS_LONG_PARSER = new LongParser(){
@Override
public long parseLong(BytesRef term) {
- if (NumericUtils.getPrefixCodedLongShift(term) > 0)
- throw new StopFillCacheException();
return NumericUtils.prefixCodedToLong(term);
}
@Override
public String toString() {
return FieldCache.class.getName()+".NUMERIC_UTILS_LONG_PARSER";
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return NumericUtils.filterPrefixCodedLongs(terms.iterator(null));
+ }
};
/**
@@ -274,14 +318,17 @@ public interface FieldCache {
public static final DoubleParser NUMERIC_UTILS_DOUBLE_PARSER = new DoubleParser(){
@Override
public double parseDouble(BytesRef term) {
- if (NumericUtils.getPrefixCodedLongShift(term) > 0)
- throw new StopFillCacheException();
return NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(term));
}
@Override
public String toString() {
return FieldCache.class.getName()+".NUMERIC_UTILS_DOUBLE_PARSER";
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return NumericUtils.filterPrefixCodedLongs(terms.iterator(null));
+ }
};
@@ -652,7 +699,7 @@ public interface FieldCache {
}
}
-
+
/**
* EXPERT: Generates an array of CacheEntry objects representing all items
* currently in the FieldCache.
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=1442497&r1=1442496&r2=1442497&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java Tue Feb 5 08:24:35 2013
@@ -140,13 +140,6 @@ class FieldCacheImpl implements FieldCac
public Object getValue() { return value; }
}
- /**
- * Hack: When thrown from a Parser (NUMERIC_UTILS_* ones), this stops
- * processing terms and returns the current FieldCache
- * array.
- */
- static final class StopFillCacheException extends RuntimeException {
- }
// per-segment fieldcaches don't purge until the shared core closes.
final SegmentReader.CoreClosedListener purgeCore = new SegmentReader.CoreClosedListener() {
@@ -360,32 +353,30 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final byte termval = parser.parseByte(term);
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final byte termval = parser.parseByte(term);
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
if (setDocsWithField) {
@@ -435,32 +426,30 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final short termval = parser.parseShort(term);
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final short termval = parser.parseShort(term);
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
if (setDocsWithField) {
@@ -536,37 +525,35 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final int termval = parser.parseInt(term);
+ if (retArray == null) {
+ // late init so numeric fields don't double allocate
+ retArray = new int[maxDoc];
+ }
+
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final int termval = parser.parseInt(term);
- if (retArray == null) {
- // late init so numeric fields don't double allocate
- retArray = new int[maxDoc];
- }
-
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
@@ -689,37 +676,35 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final float termval = parser.parseFloat(term);
+ if (retArray == null) {
+ // late init so numeric fields don't double allocate
+ retArray = new float[maxDoc];
+ }
+
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final float termval = parser.parseFloat(term);
- if (retArray == null) {
- // late init so numeric fields don't double allocate
- retArray = new float[maxDoc];
- }
-
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
@@ -779,37 +764,35 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final long termval = parser.parseLong(term);
+ if (retArray == null) {
+ // late init so numeric fields don't double allocate
+ retArray = new long[maxDoc];
+ }
+
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final long termval = parser.parseLong(term);
- if (retArray == null) {
- // late init so numeric fields don't double allocate
- retArray = new long[maxDoc];
- }
-
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
@@ -870,37 +853,35 @@ class FieldCacheImpl implements FieldCac
setDocsWithField = false;
}
}
- final TermsEnum termsEnum = terms.iterator(null);
+ final TermsEnum termsEnum = parser.termsEnum(terms);
+ assert termsEnum != null : "TermsEnum must not be null";
DocsEnum docs = null;
- try {
- while(true) {
- final BytesRef term = termsEnum.next();
- if (term == null) {
+ while(true) {
+ final BytesRef term = termsEnum.next();
+ if (term == null) {
+ break;
+ }
+ final double termval = parser.parseDouble(term);
+ if (retArray == null) {
+ // late init so numeric fields don't double allocate
+ retArray = new double[maxDoc];
+ }
+
+ docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
+ while (true) {
+ final int docID = docs.nextDoc();
+ if (docID == DocIdSetIterator.NO_MORE_DOCS) {
break;
}
- final double termval = parser.parseDouble(term);
- if (retArray == null) {
- // late init so numeric fields don't double allocate
- retArray = new double[maxDoc];
- }
-
- docs = termsEnum.docs(null, docs, DocsEnum.FLAG_NONE);
- while (true) {
- final int docID = docs.nextDoc();
- if (docID == DocIdSetIterator.NO_MORE_DOCS) {
- break;
- }
- retArray[docID] = termval;
- if (setDocsWithField) {
- if (docsWithField == null) {
- // Lazy init
- docsWithField = new FixedBitSet(maxDoc);
- }
- docsWithField.set(docID);
+ retArray[docID] = termval;
+ if (setDocsWithField) {
+ if (docsWithField == null) {
+ // Lazy init
+ docsWithField = new FixedBitSet(maxDoc);
}
+ docsWithField.set(docID);
}
}
- } catch (FieldCache.StopFillCacheException stop) {
}
}
if (retArray == null) { // no values
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java?rev=1442497&r1=1442496&r2=1442497&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java Tue Feb 5 08:24:35 2013
@@ -22,6 +22,8 @@ import org.apache.lucene.document.Double
import org.apache.lucene.document.FloatField; // javadocs
import org.apache.lucene.document.IntField; // javadocs
import org.apache.lucene.document.LongField; // javadocs
+import org.apache.lucene.index.FilteredTermsEnum;
+import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.NumericRangeFilter;
import org.apache.lucene.search.NumericRangeQuery; // for javadocs
@@ -456,4 +458,41 @@ public final class NumericUtils {
}
+ /**
+ * Filters the given {@link TermsEnum} by accepting only prefix coded 64 bit
+ * terms with a shift value of <tt>0</tt>.
+ *
+ * @param termsEnum
+ * the terms enum to filter
+ * @return a filtered {@link TermsEnum} that only returns prefix coded 64 bit
+ * terms with a shift value of <tt>0</tt>.
+ */
+ public static TermsEnum filterPrefixCodedLongs(TermsEnum termsEnum) {
+ return new FilteredTermsEnum(termsEnum, false) {
+ @Override
+ protected AcceptStatus accept(BytesRef term) {
+ return NumericUtils.getPrefixCodedLongShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END;
+ }
+ };
+ }
+
+ /**
+ * Filters the given {@link TermsEnum} by accepting only prefix coded 32 bit
+ * terms with a shift value of <tt>0</tt>.
+ *
+ * @param termsEnum
+ * the terms enum to filter
+ * @return a filtered {@link TermsEnum} that only returns prefix coded 32 bit
+ * terms with a shift value of <tt>0</tt>.
+ */
+ public static TermsEnum filterPrefixCodedInts(TermsEnum termsEnum) {
+ return new FilteredTermsEnum(termsEnum, false) {
+
+ @Override
+ protected AcceptStatus accept(BytesRef term) {
+ return NumericUtils.getPrefixCodedIntShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END;
+ }
+ };
+ }
+
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=1442497&r1=1442496&r2=1442497&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java Tue Feb 5 08:24:35 2013
@@ -21,6 +21,8 @@ import java.io.IOException;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.Norm;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -95,6 +97,11 @@ final class JustCompileSearch {
public long parseLong(BytesRef string) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) {
+ throw new UnsupportedOperationException(UNSUPPORTED_MSG);
+ }
}
@@ -104,6 +111,11 @@ final class JustCompileSearch {
public double parseDouble(BytesRef term) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) {
+ throw new UnsupportedOperationException(UNSUPPORTED_MSG);
+ }
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java?rev=1442497&r1=1442496&r2=1442497&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestSort.java Tue Feb 5 08:24:35 2013
@@ -53,6 +53,8 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.StorableField;
import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.FieldValueHitQueue.Entry;
import org.apache.lucene.store.Directory;
@@ -581,6 +583,11 @@ public class TestSort extends LuceneTest
public final int parseInt(final BytesRef term) {
return (term.bytes[term.offset]-'A') * 123456;
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " IntParser");
@@ -591,6 +598,10 @@ public class TestSort extends LuceneTest
public final float parseFloat(final BytesRef term) {
return (float) Math.sqrt( term.bytes[term.offset] );
}
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " FloatParser");
@@ -601,6 +612,11 @@ public class TestSort extends LuceneTest
public final long parseLong(final BytesRef term) {
return (term.bytes[term.offset]-'A') * 1234567890L;
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " LongParser");
@@ -611,6 +627,10 @@ public class TestSort extends LuceneTest
public final double parseDouble(final BytesRef term) {
return Math.pow( term.bytes[term.offset], (term.bytes[term.offset]-'A') );
}
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " DoubleParser");
@@ -621,6 +641,11 @@ public class TestSort extends LuceneTest
public final byte parseByte(final BytesRef term) {
return (byte) (term.bytes[term.offset]-'A');
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " ByteParser");
@@ -631,6 +656,10 @@ public class TestSort extends LuceneTest
public final short parseShort(final BytesRef term) {
return (short) (term.bytes[term.offset]-'A');
}
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
}), SortField.FIELD_DOC );
assertMatches (full, queryA, sort, "JIHGFEDCBA");
assertSaneFieldCaches(getTestName() + " ShortParser");
@@ -708,6 +737,11 @@ public class TestSort extends LuceneTest
public final int parseInt(final BytesRef term) {
return (term.bytes[term.offset]-'A') * 123456;
}
+
+ @Override
+ public TermsEnum termsEnum(Terms terms) throws IOException {
+ return terms.iterator(null);
+ }
};
@Override