lucene 4: text comparator should always work on bytes
This commit is contained in:
parent
65ce3aea57
commit
4b84078f91
|
@ -22,8 +22,6 @@ package org.elasticsearch.common.text;
|
|||
import com.google.common.base.Charsets;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* A {@link BytesReference} representation of the text, will always convert on the fly to a {@link String}.
|
||||
*/
|
||||
|
@ -76,7 +74,6 @@ public class BytesText implements Text {
|
|||
|
||||
@Override
|
||||
public int compareTo(Text text) {
|
||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(text.bytes(), text.bytes());
|
||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes(), text.bytes());
|
||||
}
|
||||
|
||||
}
|
|
@ -99,11 +99,7 @@ public class StringAndBytesText implements Text {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Text other) {
|
||||
if (text == null) {
|
||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes, other.bytes());
|
||||
} else {
|
||||
return text.compareTo(other.string());
|
||||
}
|
||||
public int compareTo(Text text) {
|
||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes(), text.bytes());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,6 @@ public class StringText implements Text {
|
|||
|
||||
@Override
|
||||
public int compareTo(Text text) {
|
||||
return this.text.compareTo(text.string());
|
||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes(), text.bytes());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue