Search in sources :

Example 41 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression 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 42 with StreamExpression

use of org.apache.solr.client.solrj.io.stream.expr.StreamExpression 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)

Example 43 with StreamExpression

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

the class GetStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    expression.addParameter(name);
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression)

Example 44 with StreamExpression

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

the class HashJoinStream 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 (hashStream instanceof Expressible && fullStream instanceof Expressible) {
            expression.addParameter(((Expressible) fullStream).toExpression(factory));
            expression.addParameter(new StreamExpressionNamedParameter("hashed", ((Expressible) hashStream).toExpression(factory)));
        } else {
            throw new IOException("This HashJoinStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
        expression.addParameter("hashed=<stream>");
    }
    // on
    StringBuilder sb = new StringBuilder();
    for (int idx = 0; idx < leftHashOn.size(); ++idx) {
        if (sb.length() > 0) {
            sb.append(",");
        }
        // we know that left and right hashOns are the same size
        String left = leftHashOn.get(idx);
        String right = rightHashOn.get(idx);
        if (left.equals(right)) {
            sb.append(left);
        } else {
            sb.append(left);
            sb.append("=");
            sb.append(right);
        }
    }
    expression.addParameter(new StreamExpressionNamedParameter("on", sb.toString()));
    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 45 with StreamExpression

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

the class JDBCStream method toExpression.

@Override
public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
    // functionName(collectionName, param1, param2, ..., paramN, sort="comp", [aliases="field=alias,..."])
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    // connection url
    expression.addParameter(new StreamExpressionNamedParameter("connection", connectionUrl));
    // sql
    expression.addParameter(new StreamExpressionNamedParameter("sql", sqlQuery));
    // sort
    expression.addParameter(new StreamExpressionNamedParameter(SORT, definedSort.toExpression(factory)));
    // driver class
    if (null != driverClassName) {
        expression.addParameter(new StreamExpressionNamedParameter("driver", driverClassName));
    }
    // connection properties
    if (null != connectionProperties) {
        for (String propertyName : connectionProperties.stringPropertyNames()) {
            expression.addParameter(new StreamExpressionNamedParameter(propertyName, connectionProperties.getProperty(propertyName)));
        }
    }
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter)

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