Search in sources :

Example 26 with StreamExplanation

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

the class StatsStream method toExplanation.

@Override
public Explanation toExplanation(StreamFactory factory) throws IOException {
    StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString());
    explanation.setFunctionName(factory.getFunctionName(this.getClass()));
    explanation.setImplementingClass(this.getClass().getName());
    explanation.setExpressionType(ExpressionType.STREAM_SOURCE);
    explanation.setExpression(toExpression(factory).toString());
    StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore");
    child.setFunctionName(String.format(Locale.ROOT, "solr (worker ? of ?)"));
    // TODO: fix this so we know the # of workers - check with Joel about a Stat's ability to be in a
    // parallel stream.
    child.setImplementingClass("Solr/Lucene");
    child.setExpressionType(ExpressionType.DATASTORE);
    ModifiableSolrParams mParams = new ModifiableSolrParams(params);
    child.setExpression(mParams.getMap().entrySet().stream().map(e -> String.format(Locale.ROOT, "%s=%s", e.getKey(), e.getValue())).collect(Collectors.joining(",")));
    explanation.addChild(child);
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 27 with StreamExplanation

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

the class TimeSeriesStream method toExplanation.

@Override
public Explanation toExplanation(StreamFactory factory) throws IOException {
    StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString());
    explanation.setFunctionName(factory.getFunctionName(this.getClass()));
    explanation.setImplementingClass(this.getClass().getName());
    explanation.setExpressionType(ExpressionType.STREAM_SOURCE);
    explanation.setExpression(toExpression(factory).toString());
    // child is a datastore so add it at this point
    StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore");
    child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection));
    // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in a
    // parallel stream.
    child.setImplementingClass("Solr/Lucene");
    child.setExpressionType(ExpressionType.DATASTORE);
    ModifiableSolrParams tmpParams = new ModifiableSolrParams(SolrParams.toMultiMap(params.toNamedList()));
    child.setExpression(tmpParams.getMap().entrySet().stream().map(e -> String.format(Locale.ROOT, "%s=%s", e.getKey(), e.getValue())).collect(Collectors.joining(",")));
    explanation.addChild(child);
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 28 with StreamExplanation

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

the class StreamExpressionToExplanationTest method testComplementStream.

@Test
public void testComplementStream() throws Exception {
    ComplementStream stream;
    String expressionString;
    // Basic test
    stream = new ComplementStream(StreamExpressionParser.parse("complement(" + "search(collection1, q=\"id:(0 3 4)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "search(collection1, q=\"id:(1 2)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "on=\"a_f, a_s\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("complement", explanation.getFunctionName());
    Assert.assertEquals(ComplementStream.class.getName(), explanation.getImplementingClass());
    Assert.assertEquals(2, ((StreamExplanation) explanation).getChildren().size());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 29 with StreamExplanation

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

the class StreamExpressionToExplanationTest method testMergeStream.

@Test
public void testMergeStream() throws Exception {
    MergeStream stream;
    // Basic test
    stream = new MergeStream(StreamExpressionParser.parse("merge(" + "search(collection1, q=\"id:(0 3 4)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "search(collection1, q=\"id:(1 2)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "on=\"a_f asc, a_s asc\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("merge", explanation.getFunctionName());
    Assert.assertEquals(MergeStream.class.getName(), explanation.getImplementingClass());
    Assert.assertEquals(2, ((StreamExplanation) explanation).getChildren().size());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 30 with StreamExplanation

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

the class StreamExpressionToExplanationTest method testRankStream.

@Test
public void testRankStream() throws Exception {
    RankStream stream;
    String expressionString;
    // Basic test
    stream = new RankStream(StreamExpressionParser.parse("top(" + "n=3," + "search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc,a_i asc\")," + "sort=\"a_f asc, a_i asc\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("top", explanation.getFunctionName());
    Assert.assertEquals(RankStream.class.getName(), explanation.getImplementingClass());
    Assert.assertEquals(1, ((StreamExplanation) explanation).getChildren().size());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Aggregations

StreamExplanation (org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)34 Explanation (org.apache.solr.client.solrj.io.stream.expr.Explanation)10 Test (org.junit.Test)8 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)7 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Tuple (org.apache.solr.client.solrj.io.Tuple)2 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MethodHandles (java.lang.invoke.MethodHandles)1 SQLException (java.sql.SQLException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Entry (java.util.Map.Entry)1 Random (java.util.Random)1