Search in sources :

Example 6 with StreamComparator

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");
        }
    }
}
Also used : MultipleFieldEqualitor(org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor) StreamComparator(org.apache.solr.client.solrj.io.comp.StreamComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) IOException(java.io.IOException)

Aggregations

StreamComparator (org.apache.solr.client.solrj.io.comp.StreamComparator)6 IOException (java.io.IOException)5 MultipleFieldComparator (org.apache.solr.client.solrj.io.comp.MultipleFieldComparator)5 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)4 MultipleFieldEqualitor (org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor)3 FieldEqualitor (org.apache.solr.client.solrj.io.eq.FieldEqualitor)2 StreamEqualitor (org.apache.solr.client.solrj.io.eq.StreamEqualitor)2 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)2 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)2 HashSet (java.util.HashSet)1 AndEvaluator (org.apache.solr.client.solrj.io.eval.AndEvaluator)1 BooleanEvaluator (org.apache.solr.client.solrj.io.eval.BooleanEvaluator)1 GreaterThanEvaluator (org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator)1 NotEvaluator (org.apache.solr.client.solrj.io.eval.NotEvaluator)1 RawValueEvaluator (org.apache.solr.client.solrj.io.eval.RawValueEvaluator)1