diff --git a/src/java/org/apache/lucene/index/Term.java b/src/java/org/apache/lucene/index/Term.java index b0a1e23c89c..c56483d124e 100644 --- a/src/java/org/apache/lucene/index/Term.java +++ b/src/java/org/apache/lucene/index/Term.java @@ -27,7 +27,7 @@ import org.apache.lucene.util.StringHelper; Note that terms may represent more than words from text fields, but also things like dates, email addresses, urls, etc. */ -public final class Term implements Comparable, java.io.Serializable { +public final class Term implements Comparable, java.io.Serializable { String field; String text; @@ -74,7 +74,7 @@ public final class Term implements Comparable, java.io.Serializable { return new Term(field,text,false); } - //@Override + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -96,7 +96,7 @@ public final class Term implements Comparable, java.io.Serializable { return true; } - //@Override + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -105,10 +105,6 @@ public final class Term implements Comparable, java.io.Serializable { return result; } - public int compareTo(Object other) { - return compareTo((Term)other); - } - /** Compares two terms, returning a negative integer if this term belongs before the argument, zero if this term is equal to the argument, and a positive integer if this term belongs after the argument. @@ -127,6 +123,7 @@ public final class Term implements Comparable, java.io.Serializable { text = txt; } + @Override public final String toString() { return field + ":" + text; } private void readObject(java.io.ObjectInputStream in) diff --git a/src/java/org/apache/lucene/search/DocIdSet.java b/src/java/org/apache/lucene/search/DocIdSet.java index c6a9b6d7347..26d71dcbdc0 100644 --- a/src/java/org/apache/lucene/search/DocIdSet.java +++ b/src/java/org/apache/lucene/search/DocIdSet.java @@ -34,10 +34,12 @@ public abstract class DocIdSet { public int nextDoc() throws IOException { return NO_MORE_DOCS; } }; + @Override public DocIdSetIterator iterator() { return iterator; } + @Override public boolean isCacheable() { return true; } diff --git a/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java b/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java index 8b1985fd102..fc0bee8eee0 100644 --- a/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java +++ b/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java @@ -478,10 +478,12 @@ public abstract class FieldCacheRangeFilter extends Filter { abstract boolean matchDoc(int doc) throws ArrayIndexOutOfBoundsException; /** this DocIdSet is cacheable, if it works solely with FieldCache and no TermDocs */ + @Override public boolean isCacheable() { return !(mayUseTermDocs && reader.hasDeletions()); } + @Override public DocIdSetIterator iterator() throws IOException { // Synchronization needed because deleted docs BitVector // can change after call to hasDeletions until TermDocs creation. diff --git a/src/java/org/apache/lucene/search/FieldCacheTermsFilter.java b/src/java/org/apache/lucene/search/FieldCacheTermsFilter.java index b536383c5e6..bc403ee8ff9 100644 --- a/src/java/org/apache/lucene/search/FieldCacheTermsFilter.java +++ b/src/java/org/apache/lucene/search/FieldCacheTermsFilter.java @@ -126,11 +126,13 @@ public class FieldCacheTermsFilter extends Filter { } } + @Override public DocIdSetIterator iterator() { return new FieldCacheTermsFilterDocIdSetIterator(); } /** This DocIdSet implementation is cacheable. */ + @Override public boolean isCacheable() { return true; } diff --git a/src/java/org/apache/lucene/search/FilteredDocIdSet.java b/src/java/org/apache/lucene/search/FilteredDocIdSet.java index ded83a81ea3..99e301c2fc8 100644 --- a/src/java/org/apache/lucene/search/FilteredDocIdSet.java +++ b/src/java/org/apache/lucene/search/FilteredDocIdSet.java @@ -50,6 +50,7 @@ public abstract class FilteredDocIdSet extends DocIdSet { } /** This DocIdSet implementation is cacheable if the inner set is cacheable. */ + @Override public boolean isCacheable() { return _innerSet.isCacheable(); } @@ -66,7 +67,7 @@ public abstract class FilteredDocIdSet extends DocIdSet { * @see DocIdSetIterator * @see FilteredDocIdSetIterator */ - // @Override + @Override public DocIdSetIterator iterator() throws IOException { return new FilteredDocIdSetIterator(_innerSet.iterator()) { protected boolean match(int docid) throws IOException { diff --git a/src/java/org/apache/lucene/search/QueryWrapperFilter.java b/src/java/org/apache/lucene/search/QueryWrapperFilter.java index b5562b488be..b45a3737596 100644 --- a/src/java/org/apache/lucene/search/QueryWrapperFilter.java +++ b/src/java/org/apache/lucene/search/QueryWrapperFilter.java @@ -44,26 +44,32 @@ public class QueryWrapperFilter extends Filter { this.query = query; } + @Override public DocIdSet getDocIdSet(final IndexReader reader) throws IOException { final Weight weight = query.weight(new IndexSearcher(reader)); return new DocIdSet() { + @Override public DocIdSetIterator iterator() throws IOException { return weight.scorer(reader, true, false); } + @Override public boolean isCacheable() { return false; } }; } + @Override public String toString() { return "QueryWrapperFilter(" + query + ")"; } + @Override public boolean equals(Object o) { if (!(o instanceof QueryWrapperFilter)) return false; return this.query.equals(((QueryWrapperFilter)o).query); } + @Override public int hashCode() { return query.hashCode() ^ 0x923F64B9; } diff --git a/src/java/org/apache/lucene/search/Similarity.java b/src/java/org/apache/lucene/search/Similarity.java index f146fb03453..8fe60443b57 100644 --- a/src/java/org/apache/lucene/search/Similarity.java +++ b/src/java/org/apache/lucene/search/Similarity.java @@ -752,11 +752,11 @@ public abstract class Similarity implements Serializable { if(supportedMethods.overridesTermIDF) { final float idf = idf(term, searcher); return new IDFExplanation() { - //@Override + @Override public float getIdf() { return idf; } - //@Override + @Override public String explain() { return "Inexplicable"; } @@ -766,12 +766,12 @@ public abstract class Similarity implements Serializable { final int max = searcher.maxDoc(); final float idf = idf(df, max); return new IDFExplanation() { - //@Override + @Override public String explain() { return "idf(docFreq=" + df + ", maxDocs=" + max + ")"; } - //@Override + @Override public float getIdf() { return idf; }}; @@ -814,11 +814,11 @@ public abstract class Similarity implements Serializable { if(supportedMethods.overridesCollectionIDF) { final float idf = idf(terms, searcher); return new IDFExplanation() { - //@Override + @Override public float getIdf() { return idf; } - //@Override + @Override public String explain() { return "Inexplicable"; } @@ -839,11 +839,11 @@ public abstract class Similarity implements Serializable { } final float fIdf = idf; return new IDFExplanation() { - //@Override + @Override public float getIdf() { return fIdf; } - //@Override + @Override public String explain() { return exp.toString(); } diff --git a/src/java/org/apache/lucene/search/TermRangeQuery.java b/src/java/org/apache/lucene/search/TermRangeQuery.java index f6bc5e3a08b..383883dac08 100644 --- a/src/java/org/apache/lucene/search/TermRangeQuery.java +++ b/src/java/org/apache/lucene/search/TermRangeQuery.java @@ -130,12 +130,14 @@ public class TermRangeQuery extends MultiTermQuery { /** Returns the collator used to determine range inclusion, if any. */ public Collator getCollator() { return collator; } + @Override protected FilteredTermEnum getEnum(IndexReader reader) throws IOException { return new TermRangeTermEnum(reader, field, lowerTerm, upperTerm, includeLower, includeUpper, collator); } /** Prints a user-readable version of this query. */ + @Override public String toString(String field) { StringBuilder buffer = new StringBuilder(); if (!getField().equals(field)) { @@ -151,7 +153,7 @@ public class TermRangeQuery extends MultiTermQuery { return buffer.toString(); } - //@Override + @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); @@ -164,7 +166,7 @@ public class TermRangeQuery extends MultiTermQuery { return result; } - //@Override + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java b/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java index b0c74e860c1..3161e42dbe8 100644 --- a/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java +++ b/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java @@ -66,10 +66,12 @@ public class PayloadNearQuery extends SpanNearQuery { this.function = function; } + @Override public Weight createWeight(Searcher searcher) throws IOException { return new PayloadNearSpanWeight(this, searcher); } + @Override public Object clone() { int sz = clauses.size(); SpanQuery[] newClauses = new SpanQuery[sz]; @@ -84,6 +86,7 @@ public class PayloadNearQuery extends SpanNearQuery { return boostingNearQuery; } + @Override public String toString(String field) { StringBuilder buffer = new StringBuilder(); buffer.append("payloadNear(["); @@ -104,7 +107,7 @@ public class PayloadNearQuery extends SpanNearQuery { return buffer.toString(); } - // @Override + @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); @@ -113,7 +116,7 @@ public class PayloadNearQuery extends SpanNearQuery { return result; } - // @Override + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -146,6 +149,7 @@ public class PayloadNearQuery extends SpanNearQuery { similarity, reader.norms(query.getField())); } + @Override public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException { return new PayloadNearSpanScorer(query.getSpans(reader), this, @@ -215,12 +219,14 @@ public class PayloadNearQuery extends SpanNearQuery { return super.setFreqCurrentDoc(); } + @Override public float score() throws IOException { return super.score() * function.docScore(doc, fieldName, payloadsSeen, payloadScore); } + @Override public Explanation explain(int doc) throws IOException { Explanation result = new Explanation(); Explanation nonPayloadExpl = super.explain(doc); diff --git a/src/java/org/apache/lucene/util/OpenBitSet.java b/src/java/org/apache/lucene/util/OpenBitSet.java index 46eb0237f6a..f0ae300b25a 100644 --- a/src/java/org/apache/lucene/util/OpenBitSet.java +++ b/src/java/org/apache/lucene/util/OpenBitSet.java @@ -112,11 +112,13 @@ public class OpenBitSet extends DocIdSet implements Cloneable, Serializable { this.wlen = numWords; } + @Override public DocIdSetIterator iterator() { return new OpenBitSetIterator(bits, wlen); } /** This DocIdSet implementation is cacheable. */ + @Override public boolean isCacheable() { return true; } diff --git a/src/java/org/apache/lucene/util/SimpleStringInterner.java b/src/java/org/apache/lucene/util/SimpleStringInterner.java index 29200824d11..94b45c8e3ab 100755 --- a/src/java/org/apache/lucene/util/SimpleStringInterner.java +++ b/src/java/org/apache/lucene/util/SimpleStringInterner.java @@ -46,7 +46,7 @@ public class SimpleStringInterner extends StringInterner { this.maxChainLength = Math.max(2,maxChainLength); } - // @Override + @Override public String intern(String s) { int h = s.hashCode(); // In the future, it may be worth augmenting the string hash diff --git a/src/java/org/apache/lucene/util/SortedVIntList.java b/src/java/org/apache/lucene/util/SortedVIntList.java index 659ed403401..13f1e0b6bdf 100644 --- a/src/java/org/apache/lucene/util/SortedVIntList.java +++ b/src/java/org/apache/lucene/util/SortedVIntList.java @@ -181,6 +181,7 @@ public class SortedVIntList extends DocIdSet { } /** This DocIdSet implementation is cacheable. */ + @Override public boolean isCacheable() { return true; } @@ -188,6 +189,7 @@ public class SortedVIntList extends DocIdSet { /** * @return An iterator over the sorted integers. */ + @Override public DocIdSetIterator iterator() { return new DocIdSetIterator() { int bytePos = 0; diff --git a/src/test/org/apache/lucene/search/TestDocIdSet.java b/src/test/org/apache/lucene/search/TestDocIdSet.java index abd6261cc43..89123bbda0c 100644 --- a/src/test/org/apache/lucene/search/TestDocIdSet.java +++ b/src/test/org/apache/lucene/search/TestDocIdSet.java @@ -42,7 +42,7 @@ public class TestDocIdSet extends LuceneTestCase { final int maxdoc=10; final DocIdSet innerSet = new DocIdSet() { - // @Override + @Override public DocIdSetIterator iterator() { return new DocIdSetIterator() { @@ -52,13 +52,13 @@ public class TestDocIdSet extends LuceneTestCase { return docid; } - //@Override + @Override public int nextDoc() throws IOException { docid++; return docid < maxdoc ? docid : (docid = NO_MORE_DOCS); } - //@Override + @Override public int advance(int target) throws IOException { while (nextDoc() < target) {} return docid; @@ -69,7 +69,7 @@ public class TestDocIdSet extends LuceneTestCase { DocIdSet filteredSet = new FilteredDocIdSet(innerSet){ - // @Override + @Override protected boolean match(int docid) { return docid%2 == 0; //validate only even docids } diff --git a/src/test/org/apache/lucene/util/LocalizedTestCase.java b/src/test/org/apache/lucene/util/LocalizedTestCase.java index 712e9ae3872..54f84de5fa0 100644 --- a/src/test/org/apache/lucene/util/LocalizedTestCase.java +++ b/src/test/org/apache/lucene/util/LocalizedTestCase.java @@ -65,19 +65,19 @@ public abstract class LocalizedTestCase extends LuceneTestCase { this.testWithDifferentLocales = testWithDifferentLocales; } - // @Override + @Override protected void setUp() throws Exception { super.setUp(); Locale.setDefault(locale); } - // @Override + @Override protected void tearDown() throws Exception { Locale.setDefault(defaultLocale); super.tearDown(); } - // @Override + @Override public void runBare() throws Throwable { // Do the test with the default Locale (default) try { diff --git a/src/test/org/apache/lucene/util/LuceneTestCase.java b/src/test/org/apache/lucene/util/LuceneTestCase.java index b937e99aa32..b21ff83750e 100644 --- a/src/test/org/apache/lucene/util/LuceneTestCase.java +++ b/src/test/org/apache/lucene/util/LuceneTestCase.java @@ -199,7 +199,7 @@ public abstract class LuceneTestCase extends TestCase { return new Random(seed); } - // @Override + @Override public void runBare() throws Throwable { try { seed = null; diff --git a/src/test/org/apache/lucene/util/TestNumericUtils.java b/src/test/org/apache/lucene/util/TestNumericUtils.java index f9e8ca6d3bf..6a85a1d887e 100644 --- a/src/test/org/apache/lucene/util/TestNumericUtils.java +++ b/src/test/org/apache/lucene/util/TestNumericUtils.java @@ -179,7 +179,7 @@ public class TestNumericUtils extends LuceneTestCase { final OpenBitSet bits=useBitSet ? new OpenBitSet(upper-lower+1) : null; NumericUtils.splitLongRange(new NumericUtils.LongRangeBuilder() { - //@Override + @Override public void addRange(long min, long max, int shift) { assertTrue("min, max should be inside bounds", min>=lower && min<=upper && max>=lower && max<=upper); if (useBitSet) for (long l=min; l<=max; l++) { @@ -261,7 +261,7 @@ public class TestNumericUtils extends LuceneTestCase { final OpenBitSet bits=useBitSet ? new OpenBitSet(upper-lower+1) : null; NumericUtils.splitIntRange(new NumericUtils.IntRangeBuilder() { - //@Override + @Override public void addRange(int min, int max, int shift) { assertTrue("min, max should be inside bounds", min>=lower && min<=upper && max>=lower && max<=upper); if (useBitSet) for (int i=min; i<=max; i++) {