lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject [1/8] lucene-solr:jira/solr-8668: SOLR-10747: Allow /stream handler to execute Stream Evaluators directly
Date Fri, 26 May 2017 09:42:18 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-8668 61f1c6ebd -> 8143752f7


SOLR-10747: Allow /stream handler to execute Stream Evaluators directly


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b3ee2d03
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b3ee2d03
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b3ee2d03

Branch: refs/heads/jira/solr-8668
Commit: b3ee2d03dbeecd5ff1197ae548bd2ce26518c0c0
Parents: 1e4d205
Author: Joel Bernstein <jbernste@apache.org>
Authored: Thu May 25 13:52:04 2017 -0400
Committer: Joel Bernstein <jbernste@apache.org>
Committed: Thu May 25 13:52:42 2017 -0400

----------------------------------------------------------------------
 .../org/apache/solr/handler/StreamHandler.java  | 12 ++++++-
 .../solrj/io/stream/StreamExpressionTest.java   | 36 ++------------------
 2 files changed, 14 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b3ee2d03/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
index b219a2c..a35f0ec 100644
--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
@@ -45,6 +45,9 @@ import org.apache.solr.client.solrj.io.stream.expr.Explanation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
 import org.apache.solr.client.solrj.io.stream.expr.Expressible;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParser;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 import org.apache.solr.client.solrj.io.stream.metrics.CountMetric;
 import org.apache.solr.client.solrj.io.stream.metrics.MaxMetric;
@@ -298,7 +301,14 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
     TupleStream tupleStream;
 
     try {
-      tupleStream = this.streamFactory.constructStream(params.get("expr"));
+      StreamExpression streamExpression = StreamExpressionParser.parse(params.get("expr"));
+      if(this.streamFactory.isEvaluator(streamExpression)) {
+        StreamExpression tupleExpression = new StreamExpression("tuple");
+        tupleExpression.addParameter(new StreamExpressionNamedParameter("out", streamExpression));
+        tupleStream = this.streamFactory.constructStream(tupleExpression);
+      } else {
+        tupleStream = this.streamFactory.constructStream(streamExpression);
+      }
     } catch (Exception e) {
       //Catch exceptions that occur while the stream is being created. This will include
streaming expression parse rules.
       SolrException.log(logger, e);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b3ee2d03/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
index 0dff6fc..a2e8ca3 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
@@ -5207,8 +5207,8 @@ public class StreamExpressionTest extends SolrCloudTestCase {
 
 
   @Test
-  public void testSequence() throws Exception {
-    String expr = "tuple(seq=sequence(20, 0, 1))";
+  public void testEvaluatorOnly() throws Exception {
+    String expr = "sequence(20, 0, 1)";
     ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
     paramsLoc.set("expr", expr);
     paramsLoc.set("qt", "/stream");
@@ -5220,41 +5220,11 @@ public class StreamExpressionTest extends SolrCloudTestCase {
     solrStream.setStreamContext(context);
     List<Tuple> tuples = getTuples(solrStream);
     assertTrue(tuples.size() == 1);
-    List<Number> sequence = (List<Number>)tuples.get(0).get("seq");
+    List<Number> sequence = (List<Number>)tuples.get(0).get("out");
     assertTrue(sequence.size() == 20);
     for(int i=0; i<sequence.size(); i++) {
       assertTrue(sequence.get(i).intValue() == i);
     }
-
-    //Change the size, stride
-    expr = "tuple(seq=sequence(100, 0, 4))";
-    paramsLoc = new ModifiableSolrParams();
-    paramsLoc.set("expr", expr);
-    paramsLoc.set("qt", "/stream");
-
-    solrStream = new SolrStream(url, paramsLoc);
-    tuples = getTuples(solrStream);
-    assertTrue(tuples.size() == 1);
-    sequence = (List<Number>)tuples.get(0).get("seq");
-    assertTrue(sequence.size() == 100);
-    for(int i=0; i<sequence.size(); i++) {
-      assertTrue(sequence.get(i).intValue() == (i*4));
-    }
-
-    //Change the start
-    expr = "tuple(seq=sequence(100, 10, 1))";
-    paramsLoc = new ModifiableSolrParams();
-    paramsLoc.set("expr", expr);
-    paramsLoc.set("qt", "/stream");
-
-    solrStream = new SolrStream(url, paramsLoc);
-    tuples = getTuples(solrStream);
-    assertTrue(tuples.size() == 1);
-    sequence = (List<Number>)tuples.get(0).get("seq");
-    assertTrue(sequence.size() == 100);
-    for(int i=0; i<sequence.size(); i++) {
-      assertTrue(sequence.get(i).intValue() == (i+10));
-    }
   }
 
 


Mime
View raw message