use of org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter in project lucene-solr by apache.
the class TopicStream method toExpression.
@Override
public StreamExpression toExpression(StreamFactory factory) throws IOException {
// function name
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
expression.addParameter(checkpointCollection);
// collection
expression.addParameter(collection);
ModifiableSolrParams mParams = new ModifiableSolrParams(params);
for (Entry<String, String[]> param : mParams.getMap().entrySet()) {
String value = String.join(",", param.getValue());
// SOLR-8409: This is a special case where the params contain a " character
// Do note that in any other BASE streams with parameters where a " might come into play
// that this same replacement needs to take place.
value = value.replace("\"", "\\\"");
expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), value));
}
// zkHost
expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost));
expression.addParameter(new StreamExpressionNamedParameter(ID, id));
if (initialCheckpoint > -1) {
expression.addParameter(new StreamExpressionNamedParameter("initialCheckpoint", Long.toString(initialCheckpoint)));
}
expression.addParameter(new StreamExpressionNamedParameter("checkpointEvery", Long.toString(checkpointEvery)));
return expression;
}
use of org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter in project lucene-solr by apache.
the class SqlStream method toExpression.
@Override
public StreamExpression toExpression(StreamFactory factory) throws IOException {
// functionName(collectionName, param1, param2, ..., paramN, sort="comp", [aliases="field=alias,..."])
// function name
StreamExpression expression = new StreamExpression(factory.getFunctionName(getClass()));
// collection
expression.addParameter(collection);
// parameters
ModifiableSolrParams mParams = new ModifiableSolrParams(SolrParams.toMultiMap(params.toNamedList()));
for (Entry<String, String[]> param : mParams.getMap().entrySet()) {
String value = String.join(",", param.getValue());
// SOLR-8409: This is a special case where the params contain a " character
// Do note that in any other BASE streams with parameters where a " might come into play
// that this same replacement needs to take place.
value = value.replace("\"", "\\\"");
expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), value));
}
// zkHost
expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost));
return expression;
}
use of org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter in project lucene-solr by apache.
the class TimeSeriesStream method toExpression.
@Override
public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
// function name
StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
// collection
expression.addParameter(collection);
// parameters
ModifiableSolrParams tmpParams = new ModifiableSolrParams(params);
for (Entry<String, String[]> param : tmpParams.getMap().entrySet()) {
expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), String.join(",", param.getValue())));
}
// metrics
for (Metric metric : metrics) {
expression.addParameter(metric.toExpression(factory));
}
expression.addParameter(new StreamExpressionNamedParameter("start", start));
expression.addParameter(new StreamExpressionNamedParameter("end", end));
expression.addParameter(new StreamExpressionNamedParameter("gap", gap));
expression.addParameter(new StreamExpressionNamedParameter("field", gap));
expression.addParameter(new StreamExpressionNamedParameter("format", format));
// zkHost
expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost));
return expression;
}
use of org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter 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;
}
use of org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter 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;
}
Aggregations