use of org.apache.solr.client.solrj.io.comp.StreamComparator 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");
}
}
}
Aggregations