return new DocComparatorSource() {
@Override
public DocComparator getComparator(IndexReader reader, int docbase)
throws IOException {
final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
return new DocComparator() {
@Override
public Comparable<Integer> value(ScoreDoc doc) {
return indexes[doc.doc] != -1 ? intArray[indexes[doc.doc]] : 0;
}
@Override
public int compare(ScoreDoc doc1, ScoreDoc doc2) {
int val1 = indexes[doc1.doc] != -1 ? intArray[indexes[doc1.doc]] : 0;
int val2 = indexes[doc2.doc] != -1 ? intArray[indexes[doc2.doc]] : 0;
return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
}
};
}
};
if (longArray != null)
return new DocComparatorSource() {
@Override
public DocComparator getComparator(IndexReader reader, int docbase)
throws IOException {
final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
return new DocComparator() {
@Override
public Comparable<Long> value(ScoreDoc doc) {
return indexes[doc.doc] != -1 ? longArray[indexes[doc.doc]] : 0;
}
@Override
public int compare(ScoreDoc doc1, ScoreDoc doc2) {
long val1 = indexes[doc1.doc] != -1 ? longArray[indexes[doc1.doc]] : 0;
long val2 = indexes[doc2.doc] != -1 ? longArray[indexes[doc2.doc]] : 0;
return (val1<val2 ? -1 : (val1==val2 ? 0 : 1));
}
};
}
};
return new DocComparatorSource() {
@Override
public DocComparator getComparator(IndexReader reader, int docbase)
throws IOException {
final int[] indexes = (int[]) ((BoboIndexReader) reader).getFacetData(_name);
return new DocComparator() {
@Override
public Comparable<Float> value(ScoreDoc doc) {
return indexes[doc.doc] != -1 ? floatArray[indexes[doc.doc]] : 0;
}