lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject lucene-solr:master: SOLR-11075: Refactor handling of params in CloudSolrStream and FacetStream
Date Sun, 16 Jul 2017 16:05:37 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master bab1731b2 -> b17ec1445


SOLR-11075: Refactor handling of params in CloudSolrStream and FacetStream


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

Branch: refs/heads/master
Commit: b17ec1445dd58a8e13c7718d17d1ee6467cde799
Parents: bab1731
Author: Erick <erick@apache.org>
Authored: Sun Jul 16 09:05:07 2017 -0700
Committer: Erick <erick@apache.org>
Committed: Sun Jul 16 09:05:07 2017 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  1 +
 .../client/solrj/io/stream/CloudSolrStream.java | 22 ++++++--------------
 .../client/solrj/io/stream/FacetStream.java     | 12 +++++------
 3 files changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b17ec144/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e2c77b7..e6996dc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -87,6 +87,7 @@ Other Changes
 
 * SOLR-10964: Reduce SolrIndexSearcher casting in LTRRescorer. (Christine Poerschke)
 
+* SOLR-11075: Refactor handling of params in CloudSolrStream and FacetStream (Erick Erickson)
 ==================  7.0.0 ==================
 
 Versions of Major Components

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b17ec144/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java
index 7fe98a3..73bceb0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java
@@ -73,7 +73,7 @@ public class CloudSolrStream extends TupleStream implements Expressible
{
 
   protected String zkHost;
   protected String collection;
-  protected SolrParams params;
+  protected ModifiableSolrParams params;
   protected Map<String, String> fieldMappings;
   protected StreamComparator comp;
   private boolean trace;
@@ -172,23 +172,13 @@ public class CloudSolrStream extends TupleStream implements Expressible
{
     // collection
     expression.addParameter(collection);
     
-    ModifiableSolrParams mParams = new ModifiableSolrParams(SolrParams.toMultiMap(params.toNamedList()));
-    for (Entry<String, String[]> param : mParams.getMap().entrySet()) {
-
-      if(param.getKey().equals("fq")) {
-        for(String fqParam : param.getValue()) {
-          // See comment below for params containg a " character
-          expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), 
-              fqParam.replace("\"", "\\\"")));
-        }
-       } else {
-        String value = String.join(",", param.getValue());
-
-        // SOLR-8409: This is a special case where the params contain a " character
+    for (Entry<String, String[]> param : params.getMap().entrySet()) {
+      for (String val : param.getValue()) {
+        // SOLR-8409: Escaping the " is a special case.
         // 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));
+        expression.addParameter(new StreamExpressionNamedParameter(param.getKey(),
+            val.replace("\"", "\\\"")));
       }
     }
     

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b17ec144/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
index fb53e84..e11bf02 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
@@ -66,7 +66,7 @@ public class FacetStream extends TupleStream implements Expressible  {
   private List<Tuple> tuples = new ArrayList<Tuple>();
   private int index;
   private String zkHost;
-  private SolrParams params;
+  private ModifiableSolrParams params;
   private String collection;
   protected transient SolrClientCache cache;
   protected transient CloudSolrClient cloudSolrClient;
@@ -216,7 +216,7 @@ public class FacetStream extends TupleStream implements Expressible  {
 
   private void init(String collection, SolrParams params, Bucket[] buckets, FieldComparator[]
bucketSorts, Metric[] metrics, int bucketSizeLimit, String zkHost) throws IOException {
     this.zkHost  = zkHost;
-    this.params = params;
+    this.params = new ModifiableSolrParams(params);
     this.buckets = buckets;
     this.metrics = metrics;
     this.bucketSizeLimit   = bucketSizeLimit;
@@ -242,11 +242,11 @@ public class FacetStream extends TupleStream implements Expressible
 {
     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())));
+    for (Entry<String, String[]> param : params.getMap().entrySet()) {
+      for (String val : param.getValue()) {
+        expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), val));
+      }
     }
     
     // buckets


Mime
View raw message