Search in sources :

Example 76 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression in project lucene-solr by apache.

the class StreamExpressionToExpessionTest method testUpdateStream.

@Test
public void testUpdateStream() throws Exception {
    StreamExpression expression = StreamExpressionParser.parse("update(" + "collection2, " + "batchSize=5, " + "search(" + "collection1, " + "q=*:*, " + "fl=\"id,a_s,a_i,a_f\", " + "sort=\"a_f asc, a_i asc\"))");
    UpdateStream updateStream = new UpdateStream(expression, factory);
    String expressionString = updateStream.toExpression(factory).toString();
    assertTrue(expressionString.contains("update(collection2"));
    assertTrue(expressionString.contains("batchSize=5"));
    assertTrue(expressionString.contains("search(collection1"));
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) Test(org.junit.Test)

Example 77 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression in project lucene-solr by apache.

the class CartesianProductStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    if (includeStreams) {
        // we know stream is expressible
        expression.addParameter(((Expressible) stream).toExpression(factory));
    } else {
        expression.addParameter("<stream>");
    }
    // selected evaluators
    for (NamedEvaluator evaluator : evaluators) {
        expression.addParameter(String.format(Locale.ROOT, "%s as %s", evaluator.getEvaluator().toExpression(factory), evaluator.getName()));
    }
    expression.addParameter(new StreamExpressionNamedParameter("productSort", orderBy.toExpression(factory)));
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter)

Example 78 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression in project lucene-solr by apache.

the class IntersectStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    if (includeStreams) {
        // streams
        if (streamA instanceof Expressible) {
            expression.addParameter(((Expressible) streamA).toExpression(factory));
        } else {
            throw new IOException("This IntersectStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
        if (originalStreamB instanceof Expressible) {
            expression.addParameter(((Expressible) originalStreamB).toExpression(factory));
        } else {
            throw new IOException("This IntersectStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
        expression.addParameter("<stream>");
    }
    // on
    expression.addParameter(new StreamExpressionNamedParameter("on", eq.toExpression(factory)));
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) IOException(java.io.IOException)

Example 79 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression in project lucene-solr by apache.

the class CommitStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    expression.addParameter(collection);
    expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost));
    expression.addParameter(new StreamExpressionNamedParameter("batchSize", Integer.toString(commitBatchSize)));
    expression.addParameter(new StreamExpressionNamedParameter("waitFlush", Boolean.toString(waitFlush)));
    expression.addParameter(new StreamExpressionNamedParameter("waitSearcher", Boolean.toString(waitSearcher)));
    expression.addParameter(new StreamExpressionNamedParameter("softCommit", Boolean.toString(softCommit)));
    if (includeStreams) {
        if (tupleSource instanceof Expressible) {
            expression.addParameter(((Expressible) tupleSource).toExpression(factory));
        } else {
            throw new IOException("This CommitStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
    }
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) IOException(java.io.IOException)

Example 80 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression in project lucene-solr by apache.

the class DaemonStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    if (includeStreams) {
        // streams
        if (tupleStream instanceof Expressible) {
            expression.addParameter(((Expressible) tupleStream).toExpression(factory));
        } else {
            throw new IOException("This UniqueStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
    }
    expression.addParameter(new StreamExpressionNamedParameter(ID, id));
    expression.addParameter(new StreamExpressionNamedParameter("runInterval", Long.toString(runInterval)));
    expression.addParameter(new StreamExpressionNamedParameter("queueSize", Integer.toString(queueSize)));
    expression.addParameter(new StreamExpressionNamedParameter("terminate", Boolean.toString(terminate)));
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) IOException(java.io.IOException)

Aggregations

StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)82 Test (org.junit.Test)40 StreamExpressionNamedParameter (org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter)37 SolrClientCache (org.apache.solr.client.solrj.io.SolrClientCache)36 Tuple (org.apache.solr.client.solrj.io.Tuple)36 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)36 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)36 IOException (java.io.IOException)22 Expressible (org.apache.solr.client.solrj.io.stream.expr.Expressible)15 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)14 HashMap (java.util.HashMap)7 Map (java.util.Map)5 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)4 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)4 Metric (org.apache.solr.client.solrj.io.stream.metrics.Metric)4 MeanMetric (org.apache.solr.client.solrj.io.stream.metrics.MeanMetric)3 MinMetric (org.apache.solr.client.solrj.io.stream.metrics.MinMetric)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Explanation (org.apache.solr.client.solrj.io.stream.expr.Explanation)2