mirror of https://github.com/apache/lucene.git
Remove generics for Comparable in FieldDoc again, because we have no type and <?> makes more problems than it helps
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@829319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ce4dd93a94
commit
519095db6e
|
@ -45,7 +45,7 @@ public class FieldDoc extends ScoreDoc {
|
||||||
* @see Sort
|
* @see Sort
|
||||||
* @see Searcher#search(Query,Filter,int,Sort)
|
* @see Searcher#search(Query,Filter,int,Sort)
|
||||||
*/
|
*/
|
||||||
public Comparable<?>[] fields;
|
public Comparable[] fields;
|
||||||
|
|
||||||
/** Expert: Creates one of these objects with empty sort information. */
|
/** Expert: Creates one of these objects with empty sort information. */
|
||||||
public FieldDoc (int doc, float score) {
|
public FieldDoc (int doc, float score) {
|
||||||
|
@ -53,7 +53,7 @@ public class FieldDoc extends ScoreDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Expert: Creates one of these objects with the given sort information. */
|
/** Expert: Creates one of these objects with the given sort information. */
|
||||||
public FieldDoc (int doc, float score, Comparable<?>[] fields) {
|
public FieldDoc (int doc, float score, Comparable[] fields) {
|
||||||
super (doc, score);
|
super (doc, score);
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,8 @@ class FieldDocSortedHitQueue extends PriorityQueue<FieldDoc> {
|
||||||
* @param b ScoreDoc
|
* @param b ScoreDoc
|
||||||
* @return <code>true</code> if document <code>a</code> should be sorted after document <code>b</code>.
|
* @return <code>true</code> if document <code>a</code> should be sorted after document <code>b</code>.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked") @Override
|
||||||
protected final boolean lessThan (final FieldDoc docA, final FieldDoc docB) {
|
protected final boolean lessThan(final FieldDoc docA, final FieldDoc docB) {
|
||||||
final int n = fields.length;
|
final int n = fields.length;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (int i=0; i<n && c==0; ++i) {
|
for (int i=0; i<n && c==0; ++i) {
|
||||||
|
@ -106,17 +106,17 @@ class FieldDocSortedHitQueue extends PriorityQueue<FieldDoc> {
|
||||||
// null values need to be sorted first, because of how FieldCache.getStringIndex()
|
// null values need to be sorted first, because of how FieldCache.getStringIndex()
|
||||||
// works - in that routine, any documents without a value in the given field are
|
// works - in that routine, any documents without a value in the given field are
|
||||||
// put first. If both are null, the next SortField is used
|
// put first. If both are null, the next SortField is used
|
||||||
if (s1 == null) c = (s2==null) ? 0 : -1;
|
if (s1 == null) {
|
||||||
else if (s2 == null) c = 1; //
|
c = (s2 == null) ? 0 : -1;
|
||||||
else if (fields[i].getLocale() == null) {
|
} else if (s2 == null) {
|
||||||
|
c = 1;
|
||||||
|
} else if (fields[i].getLocale() == null) {
|
||||||
c = s1.compareTo(s2);
|
c = s1.compareTo(s2);
|
||||||
} else {
|
} else {
|
||||||
c = collators[i].compare(s1, s2);
|
c = collators[i].compare(s1, s2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the casts are a no-ops, its only there to make the
|
c = docA.fields[i].compareTo(docB.fields[i]);
|
||||||
// compiler happy because of unbounded generics:
|
|
||||||
c = ((Comparable) docA.fields[i]).compareTo((Comparable) docB.fields[i]);
|
|
||||||
if (type == SortField.SCORE) {
|
if (type == SortField.SCORE) {
|
||||||
c = -c;
|
c = -c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue