Search in sources :

Example 16 with StreamExplanation

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

the class TupStream 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_DECORATOR);
    explanation.setExpression(toExpression(factory, false).toString());
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)

Example 17 with StreamExplanation

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

the class TopicStream 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 1 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 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);
    }
    {
        // child 2 is a place where we store and read checkpoint info from
        StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-checkpoint");
        child.setFunctionName(String.format(Locale.ROOT, "solr (checkpoint store)"));
        child.setImplementingClass("Solr/Lucene");
        child.setExpressionType(ExpressionType.DATASTORE);
        child.setExpression(String.format(Locale.ROOT, "id=%s, collection=%s, checkpointEvery=%d", id, checkpointCollection, checkpointEvery));
        explanation.addChild(child);
    }
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) VERSION_FIELD(org.apache.solr.common.params.CommonParams.VERSION_FIELD) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Tuple(org.apache.solr.client.solrj.io.Tuple) ClusterState(org.apache.solr.common.cloud.ClusterState) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Random(java.util.Random) StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) TreeSet(java.util.TreeSet) SolrParams(org.apache.solr.common.params.SolrParams) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) StreamFactory(org.apache.solr.client.solrj.io.stream.expr.StreamFactory) Builder(org.apache.solr.client.solrj.impl.CloudSolrClient.Builder) ZkCoreNodeProps(org.apache.solr.common.cloud.ZkCoreNodeProps) Locale(java.util.Locale) Map(java.util.Map) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) FieldComparator(org.apache.solr.client.solrj.io.comp.FieldComparator) ExecutorUtil(org.apache.solr.common.util.ExecutorUtil) ExecutorService(java.util.concurrent.ExecutorService) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) SORT(org.apache.solr.common.params.CommonParams.SORT) ZkStateReader(org.apache.solr.common.cloud.ZkStateReader) Slice(org.apache.solr.common.cloud.Slice) Logger(org.slf4j.Logger) ComparatorOrder(org.apache.solr.client.solrj.io.comp.ComparatorOrder) ExpressionType(org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Replica(org.apache.solr.common.cloud.Replica) StreamExpressionValue(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue) SolrDocument(org.apache.solr.common.SolrDocument) List(java.util.List) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) DISTRIB(org.apache.solr.common.params.CommonParams.DISTRIB) UpdateRequest(org.apache.solr.client.solrj.request.UpdateRequest) ID(org.apache.solr.common.params.CommonParams.ID) Entry(java.util.Map.Entry) SolrjNamedThreadFactory(org.apache.solr.common.util.SolrjNamedThreadFactory) Collections(java.util.Collections) SolrInputDocument(org.apache.solr.common.SolrInputDocument) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 18 with StreamExplanation

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

the class UpdateStream method toExplanation.

@Override
public Explanation toExplanation(StreamFactory factory) throws IOException {
    // An update stream is backward wrt the order in the explanation. This stream is the "child"
    // while the collection we're updating is the parent.
    StreamExplanation explanation = new StreamExplanation(getStreamNodeId() + "-datastore");
    explanation.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection));
    explanation.setImplementingClass("Solr/Lucene");
    explanation.setExpressionType(ExpressionType.DATASTORE);
    explanation.setExpression("Update into " + collection);
    // child is a datastore so add it at this point
    StreamExplanation child = new StreamExplanation(getStreamNodeId().toString());
    child.setFunctionName(String.format(Locale.ROOT, factory.getFunctionName(getClass())));
    child.setImplementingClass(getClass().getName());
    child.setExpressionType(ExpressionType.STREAM_DECORATOR);
    child.setExpression(toExpression(factory, false).toString());
    child.addChild(tupleSource.toExplanation(factory));
    explanation.addChild(child);
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)

Example 19 with StreamExplanation

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

the class StreamExpressionToExplanationTest method testReducerStream.

@Test
public void testReducerStream() throws Exception {
    ReducerStream stream;
    String expressionString;
    // Basic test
    stream = new ReducerStream(StreamExpressionParser.parse("reduce(" + "search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_s desc, a_f asc\")," + "by=\"a_s\", group(sort=\"a_i desc\", n=\"5\"))"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("reduce", explanation.getFunctionName());
    Assert.assertEquals(ReducerStream.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)

Example 20 with StreamExplanation

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

the class StreamExpressionToExplanationTest method testJDBCStream.

@Test
public void testJDBCStream() throws Exception {
    JDBCStream stream;
    String expressionString;
    // Basic test
    stream = new JDBCStream(StreamExpressionParser.parse("jdbc(connection=\"jdbc:hsqldb:mem:.\", sql=\"select PEOPLE.ID, PEOPLE.NAME, COUNTRIES.COUNTRY_NAME from PEOPLE inner join COUNTRIES on PEOPLE.COUNTRY_CODE = COUNTRIES.CODE order by PEOPLE.ID\", sort=\"ID asc\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("jdbc", explanation.getFunctionName());
    Assert.assertEquals(JDBCStream.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