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 com.google.common.base.Charsets;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
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}.
|
* 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
|
@Override
|
||||||
public int compareTo(Text text) {
|
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
|
@Override
|
||||||
public int compareTo(Text other) {
|
public int compareTo(Text text) {
|
||||||
if (text == null) {
|
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes(), text.bytes());
|
||||||
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes, other.bytes());
|
|
||||||
} else {
|
|
||||||
return text.compareTo(other.string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,6 @@ public class StringText implements Text {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Text text) {
|
public int compareTo(Text text) {
|
||||||
return this.text.compareTo(text.string());
|
return UTF8SortedAsUnicodeComparator.utf8SortedAsUnicodeSortOrder.compare(bytes(), text.bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue