Search in sources :

Example 16 with StreamExpressionNamedParameter

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

the class UpdateStream method extractBatchSize.

private int extractBatchSize(StreamExpression expression, StreamFactory factory) throws IOException {
    StreamExpressionNamedParameter batchSizeParam = factory.getNamedOperand(expression, "batchSize");
    if (null == batchSizeParam || null == batchSizeParam.getParameter() || !(batchSizeParam.getParameter() instanceof StreamExpressionValue)) {
        throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - expecting a 'batchSize' parameter of type positive integer but didn't find one", expression));
    }
    String batchSizeStr = ((StreamExpressionValue) batchSizeParam.getParameter()).getValue();
    return parseBatchSize(batchSizeStr, expression);
}
Also used : StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) StreamExpressionValue(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue) IOException(java.io.IOException)

Example 17 with StreamExpressionNamedParameter

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

the class UpdateStream 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(updateBatchSize)));
    if (includeStreams) {
        if (tupleSource instanceof Expressible) {
            expression.addParameter(((Expressible) tupleSource).toExpression(factory));
        } else {
            throw new IOException("This ParallelStream 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 18 with StreamExpressionNamedParameter

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

the class GroupOperation method toExpression.

public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    // n
    expression.addParameter(new StreamExpressionNamedParameter("n", Integer.toString(size)));
    // sort
    expression.addParameter(new StreamExpressionNamedParameter(SORT, streamComparator.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 19 with StreamExpressionNamedParameter

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

the class ReplaceWithFieldOperation method toExpression.

@Override
public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    if (wasBuiltWithFieldName) {
        expression.addParameter(originalFieldName);
    }
    expression.addParameter(null == originalValue ? "null" : originalValue.toString());
    expression.addParameter(new StreamExpressionNamedParameter("withField", replacementFieldName));
    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 20 with StreamExpressionNamedParameter

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

the class ExecutorStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    expression.addParameter(new StreamExpressionNamedParameter("threads", Integer.toString(threads)));
    // stream
    if (includeStreams) {
        if (stream instanceof Expressible) {
            expression.addParameter(((Expressible) stream).toExpression(factory));
        } else {
            throw new IOException("The ExecuteStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    }
    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)

Aggregations

StreamExpressionNamedParameter (org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter)38 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)37 IOException (java.io.IOException)17 Expressible (org.apache.solr.client.solrj.io.stream.expr.Expressible)15 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)8 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Metric (org.apache.solr.client.solrj.io.stream.metrics.Metric)4 StreamExpressionValue (org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue)2 Bucket (org.apache.solr.client.solrj.io.stream.metrics.Bucket)2 LinkedHashMap (java.util.LinkedHashMap)1 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)1 MultipleFieldComparator (org.apache.solr.client.solrj.io.comp.MultipleFieldComparator)1 SolrException (org.apache.solr.common.SolrException)1 SolrParams (org.apache.solr.common.params.SolrParams)1 Test (org.junit.Test)1