You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jb...@apache.org on 2018/08/12 17:02:36 UTC

[03/13] lucene-solr:branch_7x: SOLR-11947: Rollback inadvertent code change during documentation updates.

SOLR-11947: Rollback inadvertent code change during documentation updates.


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

Branch: refs/heads/branch_7x
Commit: fd8f40924de88e63681b67948570cee467f27fd4
Parents: 20dfd12
Author: Joel Bernstein <jb...@apache.org>
Authored: Mon Mar 26 14:48:33 2018 -0400
Committer: Joel Bernstein <jb...@apache.org>
Committed: Sun Aug 12 12:38:06 2018 -0400

----------------------------------------------------------------------
 .../solrj/io/eval/FieldValueEvaluator.java      | 36 +++++++++-----------
 1 file changed, 17 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fd8f4092/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldValueEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldValueEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldValueEvaluator.java
index a12a74e..3086fb4 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldValueEvaluator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldValueEvaluator.java
@@ -29,27 +29,21 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
 public class FieldValueEvaluator extends SourceEvaluator {
   private static final long serialVersionUID = 1L;
-  
+
   private String fieldName;
-  private boolean literal;
-  
+
   public FieldValueEvaluator(String fieldName) {
-    if(fieldName.startsWith("\"") && fieldName.endsWith("\"") && fieldName.length() > 1){
+    if(fieldName.startsWith("'") && fieldName.endsWith("'") && fieldName.length() > 1){
       fieldName = fieldName.substring(1, fieldName.length() - 1);
-      literal = true;
     }
-    
+
     this.fieldName = fieldName;
   }
-  
+
   @Override
   public Object evaluate(Tuple tuple) throws IOException {
-    if(literal) {
-      return fieldName;
-    }
-
     Object value = tuple.get(fieldName);
-    
+
     // This is somewhat radical.
     // Here, we allow for the use of the context to provide alternative values
     // when they are not available in the provided tuple. This means that all
@@ -57,14 +51,14 @@ public class FieldValueEvaluator extends SourceEvaluator {
     // can even evaluate over fields from both of them in the same evaluation
     if(null == value && null != getStreamContext()){
       value = getStreamContext().getLets().get(fieldName);
-      
+
       // If what's contained in the context is itself an evaluator then
       // we need to evaluate it
       if(value instanceof StreamEvaluator){
         value = ((StreamEvaluator)value).evaluate(tuple);
       }
     }
-    
+
     // if we have an array then convert to an ArrayList
     // if we have an iterable that is not a list then convert to ArrayList
     // lists are good to go
@@ -90,9 +84,13 @@ public class FieldValueEvaluator extends SourceEvaluator {
       }
     }
 
+    if(value == null) {
+      return fieldName;
+    }
+
     return value;
   }
-  
+
   @Override
   public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
     return new StreamExpressionValue(fieldName);
@@ -101,9 +99,9 @@ public class FieldValueEvaluator extends SourceEvaluator {
   @Override
   public Explanation toExplanation(StreamFactory factory) throws IOException {
     return new Explanation(nodeId.toString())
-      .withExpressionType(ExpressionType.EVALUATOR)
-      .withImplementingClass(getClass().getName())
-      .withExpression(toExpression(factory).toString());
+        .withExpressionType(ExpressionType.EVALUATOR)
+        .withImplementingClass(getClass().getName())
+        .withExpression(toExpression(factory).toString());
   }
 
-}
+}
\ No newline at end of file