Search in sources :

Example 6 with MultipleFieldComparator

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");
        }
    }
}
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)

Example 7 with MultipleFieldComparator

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());
    }
}
Also used : MultipleFieldEqualitor(org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor) FieldEqualitor(org.apache.solr.client.solrj.io.eq.FieldEqualitor) MultipleFieldEqualitor(org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor) 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) StreamEqualitor(org.apache.solr.client.solrj.io.eq.StreamEqualitor)

Example 8 with MultipleFieldComparator

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);
    }
}
Also used : FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) ComparatorOrder(org.apache.solr.client.solrj.io.comp.ComparatorOrder)

Example 9 with MultipleFieldComparator

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);
    }
}
Also used : FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) ComparatorOrder(org.apache.solr.client.solrj.io.comp.ComparatorOrder)

Example 10 with MultipleFieldComparator

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);
    }
}
Also used : FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) MultipleFieldComparator(org.apache.solr.client.solrj.io.comp.MultipleFieldComparator) ComparatorOrder(org.apache.solr.client.solrj.io.comp.ComparatorOrder)

Aggregations

MultipleFieldComparator (org.apache.solr.client.solrj.io.comp.MultipleFieldComparator)10 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)9 StreamComparator (org.apache.solr.client.solrj.io.comp.StreamComparator)5 IOException (java.io.IOException)4 MultipleFieldEqualitor (org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor)4 ComparatorOrder (org.apache.solr.client.solrj.io.comp.ComparatorOrder)3 FieldEqualitor (org.apache.solr.client.solrj.io.eq.FieldEqualitor)3 StreamEqualitor (org.apache.solr.client.solrj.io.eq.StreamEqualitor)3 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)2 HashSet (java.util.HashSet)1 SolrClientCache (org.apache.solr.client.solrj.io.SolrClientCache)1 Tuple (org.apache.solr.client.solrj.io.Tuple)1 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)1 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)1 SolrParams (org.apache.solr.common.params.SolrParams)1 Test (org.junit.Test)1