use of org.apache.solr.client.solrj.io.comp.MultipleFieldComparator in project lucene-solr by apache.
the class BiJoinStream method createSideComparator.
private StreamComparator createSideComparator(StreamEqualitor eq, StreamComparator comp) throws IOException {
if (eq instanceof MultipleFieldEqualitor && comp instanceof MultipleFieldComparator) {
// we know the comp is at least as long as the eq because we've already validated the tuple order
StreamComparator[] compoundComps = new StreamComparator[((MultipleFieldEqualitor) eq).getEqs().length];
for (int idx = 0; idx < compoundComps.length; ++idx) {
StreamComparator sourceComparator = ((MultipleFieldComparator) comp).getComps()[idx];
if (sourceComparator instanceof FieldComparator) {
FieldComparator fieldComparator = (FieldComparator) sourceComparator;
compoundComps[idx] = new FieldComparator(fieldComparator.getLeftFieldName(), fieldComparator.getRightFieldName(), fieldComparator.getOrder());
} else {
throw new IOException("Failed to create an side comparator");
}
}
return new MultipleFieldComparator(compoundComps);
} else if (comp instanceof MultipleFieldComparator) {
StreamComparator sourceComparator = ((MultipleFieldComparator) comp).getComps()[0];
if (sourceComparator instanceof FieldComparator) {
FieldComparator fieldComparator = (FieldComparator) sourceComparator;
return new FieldComparator(fieldComparator.getLeftFieldName(), fieldComparator.getRightFieldName(), fieldComparator.getOrder());
} else {
throw new IOException("Failed to create an side comparator");
}
} else {
StreamComparator sourceComparator = comp;
if (sourceComparator instanceof FieldComparator) {
FieldComparator fieldComparator = (FieldComparator) sourceComparator;
return new FieldComparator(fieldComparator.getLeftFieldName(), fieldComparator.getRightFieldName(), fieldComparator.getOrder());
} else {
throw new IOException("Failed to create an side comparator");
}
}
}
use of org.apache.solr.client.solrj.io.comp.MultipleFieldComparator in project lucene-solr by apache.
the class ReducerStream method convertToEqualitor.
private StreamEqualitor convertToEqualitor(StreamComparator comp) {
if (comp instanceof MultipleFieldComparator) {
MultipleFieldComparator mComp = (MultipleFieldComparator) comp;
StreamEqualitor[] eqs = new StreamEqualitor[mComp.getComps().length];
for (int idx = 0; idx < mComp.getComps().length; ++idx) {
eqs[idx] = convertToEqualitor(mComp.getComps()[idx]);
}
return new MultipleFieldEqualitor(eqs);
} else {
FieldComparator fComp = (FieldComparator) comp;
return new FieldEqualitor(fComp.getLeftFieldName(), fComp.getRightFieldName());
}
}
use of org.apache.solr.client.solrj.io.comp.MultipleFieldComparator in project lucene-solr by apache.
the class SolrTable method getComp.
private StreamComparator getComp(List<? extends Map.Entry<String, String>> orders) {
FieldComparator[] comps = new FieldComparator[orders.size()];
for (int i = 0; i < orders.size(); i++) {
Map.Entry<String, String> order = orders.get(i);
String direction = getSortDirection(order);
ComparatorOrder comparatorOrder = ComparatorOrder.fromString(direction);
String sortKey = order.getKey();
comps[i] = new FieldComparator(sortKey, comparatorOrder);
}
if (comps.length == 1) {
return comps[0];
} else {
return new MultipleFieldComparator(comps);
}
}
use of org.apache.solr.client.solrj.io.comp.MultipleFieldComparator in project lucene-solr by apache.
the class SolrTable method bucketSortComp.
private static StreamComparator bucketSortComp(List<Bucket> buckets, Map<String, String> dirs) {
FieldComparator[] comps = new FieldComparator[buckets.size()];
for (int i = 0; i < buckets.size(); i++) {
ComparatorOrder comparatorOrder = ComparatorOrder.fromString(dirs.get(buckets.get(i).toString()));
String sortKey = buckets.get(i).toString();
comps[i] = new FieldComparator(sortKey, comparatorOrder);
}
if (comps.length == 1) {
return comps[0];
} else {
return new MultipleFieldComparator(comps);
}
}
use of org.apache.solr.client.solrj.io.comp.MultipleFieldComparator in project lucene-solr by apache.
the class SolrTable method bucketSortComp.
private static StreamComparator bucketSortComp(Bucket[] buckets, String dir) {
FieldComparator[] comps = new FieldComparator[buckets.length];
for (int i = 0; i < buckets.length; i++) {
ComparatorOrder comparatorOrder = ascDescComp(dir);
String sortKey = buckets[i].toString();
comps[i] = new FieldComparator(sortKey, comparatorOrder);
}
if (comps.length == 1) {
return comps[0];
} else {
return new MultipleFieldComparator(comps);
}
}
Aggregations