lucene 4: text comparator should always work on bytes

This commit is contained in:
Shay Banon 2012-10-26 14:11:11 +02:00
parent 65ce3aea57
commit 4b84078f91
3 changed files with 4 additions and 11 deletions

View File

@ -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());
} }
} }

View File

@ -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());
}
} }
} }

View File

@ -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());
} }
} }