lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [2/2] lucene-solr:branch_6x: SOLR-8467: CloudSolrStream and FacetStream should take a SolrParams object rather than a Map<String, String> to allow more complex Solr queries to be specified
Date Mon, 09 May 2016 20:37:28 GMT
SOLR-8467: CloudSolrStream and FacetStream should take a SolrParams object rather than a Map<String, String> to allow more complex Solr queries to be specified


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

Branch: refs/heads/branch_6x
Commit: 73b4defc0751bd0cd2ad999e3a4e6c593fd0fb1c
Parents: 75a84b7
Author: Erick Erickson <erick@apache.org>
Authored: Mon May 9 12:37:32 2016 -0700
Committer: Erick Erickson <erick@apache.org>
Committed: Mon May 9 12:48:49 2016 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |   3 +
 .../org/apache/solr/handler/SQLHandler.java     |  53 +-
 .../org/apache/solr/handler/TestSQLHandler.java | 551 ++++++++-----------
 .../solrj/io/graph/GatherNodesStream.java       |  21 +-
 .../solrj/io/graph/ShortestPathStream.java      |  57 +-
 .../solr/client/solrj/io/sql/StatementImpl.java |  11 +-
 .../client/solrj/io/stream/CloudSolrStream.java |  89 ++-
 .../client/solrj/io/stream/FacetStream.java     |  64 ++-
 .../client/solrj/io/stream/ParallelStream.java  |  23 +-
 .../solr/client/solrj/io/stream/SolrStream.java |  33 +-
 .../client/solrj/io/stream/StatsStream.java     |  58 +-
 .../client/solrj/io/stream/TopicStream.java     |  80 ++-
 .../solrj/io/graph/GraphExpressionTest.java     |   1 -
 .../solr/client/solrj/io/graph/GraphTest.java   |  23 +-
 .../solrj/io/stream/StreamExpressionTest.java   |  70 ++-
 .../client/solrj/io/stream/StreamingTest.java   | 250 +++++----
 16 files changed, 717 insertions(+), 670 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ea009ea..c88e359 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -239,6 +239,9 @@ Other Changes
 
 * SOLR-8458: Add Streaming Expressions tests for parameter substitution (Joel Bernstein, Cao Manh Dat, Dennis Gove, Kevin Risden)
 
+* SOLR-8467: CloudSolrStream and FacetStream should take a SolrParams object rather than a 
+  Map<String, String> to allow more complex Solr queries to be specified. (Erick Erickson)
+
 ==================  6.0.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SQLHandler.java b/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
index b8df7f2..bc46a78 100644
--- a/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
@@ -144,9 +144,8 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
   }
 
   private SolrParams adjustParams(SolrParams params) {
-    ModifiableSolrParams adjustedParams = new ModifiableSolrParams();
-    adjustedParams.add(params);
-    adjustedParams.add(CommonParams.OMIT_HEADER, "true");
+    ModifiableSolrParams adjustedParams = new ModifiableSolrParams(params);
+    adjustedParams.set(CommonParams.OMIT_HEADER, "true");
     return adjustedParams;
   }
 
@@ -230,18 +229,18 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
 
     String zkHost = tableSpec.zkHost;
     String collection = tableSpec.collection;
-    Map<String, String> params = new HashMap();
+    ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.put(CommonParams.FL, fl);
-    params.put(CommonParams.Q, sqlVisitor.query);
+    params.set(CommonParams.FL, fl);
+    params.set(CommonParams.Q, sqlVisitor.query);
     //Always use the /export handler for Group By Queries because it requires exporting full result sets.
-    params.put(CommonParams.QT, "/export");
+    params.set(CommonParams.QT, "/export");
 
     if(numWorkers > 1) {
-      params.put("partitionKeys", getPartitionKeys(buckets));
+      params.set("partitionKeys", getPartitionKeys(buckets));
     }
 
-    params.put("sort", sort);
+    params.set("sort", sort);
 
     TupleStream tupleStream = null;
 
@@ -370,18 +369,18 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
 
     String zkHost = tableSpec.zkHost;
     String collection = tableSpec.collection;
-    Map<String, String> params = new HashMap();
+    ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.put(CommonParams.FL, fl);
-    params.put(CommonParams.Q, sqlVisitor.query);
+    params.set(CommonParams.FL, fl);
+    params.set(CommonParams.Q, sqlVisitor.query);
     //Always use the /export handler for Distinct Queries because it requires exporting full result sets.
-    params.put(CommonParams.QT, "/export");
+    params.set(CommonParams.QT, "/export");
 
     if(numWorkers > 1) {
-      params.put("partitionKeys", getPartitionKeys(buckets));
+      params.set("partitionKeys", getPartitionKeys(buckets));
     }
 
-    params.put("sort", sort);
+    params.set("sort", sort);
 
     TupleStream tupleStream = null;
 
@@ -463,9 +462,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
 
     String zkHost = tableSpec.zkHost;
     String collection = tableSpec.collection;
-    Map<String, String> params = new HashMap();
+    ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.put(CommonParams.Q, sqlVisitor.query);
+    params.set(CommonParams.Q, sqlVisitor.query);
 
     int limit = sqlVisitor.limit > 0 ? sqlVisitor.limit : 100;
 
@@ -512,9 +511,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
 
     String zkHost = tableSpec.zkHost;
     String collection = tableSpec.collection;
-    Map<String, String> params = new HashMap();
+    ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.put(CommonParams.Q, sqlVisitor.query);
+    params.set(CommonParams.Q, sqlVisitor.query);
 
     int limit = sqlVisitor.limit > 0 ? sqlVisitor.limit : 100;
 
@@ -628,22 +627,22 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
       }
     }
 
-    Map<String, String> params = new HashMap();
-    params.put("fl", fl.toString());
-    params.put("q", sqlVisitor.query);
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.set("fl", fl.toString());
+    params.set("q", sqlVisitor.query);
 
     if(siBuf.length() > 0) {
-      params.put("sort", siBuf.toString());
+      params.set("sort", siBuf.toString());
     }
 
     TupleStream tupleStream;
 
     if(sqlVisitor.limit > -1) {
-      params.put("rows", Integer.toString(sqlVisitor.limit));
+      params.set("rows", Integer.toString(sqlVisitor.limit));
       tupleStream = new LimitStream(new CloudSolrStream(zkHost, collection, params), sqlVisitor.limit);
     } else {
       //Only use the export handler when no limit is specified.
-      params.put(CommonParams.QT, "/export");
+      params.set(CommonParams.QT, "/export");
       tupleStream = new CloudSolrStream(zkHost, collection, params);
     }
 
@@ -681,9 +680,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , Pe
 
     String zkHost = tableSpec.zkHost;
     String collection = tableSpec.collection;
-    Map<String, String> params = new HashMap();
+    ModifiableSolrParams params = new ModifiableSolrParams();
 
-    params.put(CommonParams.Q, sqlVisitor.query);
+    params.set(CommonParams.Q, sqlVisitor.query);
 
     TupleStream tupleStream = new StatsStream(zkHost,
                                               collection,

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
index 1a7d287..6876b26 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
@@ -19,9 +19,7 @@ package org.apache.solr.handler;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import com.facebook.presto.sql.parser.SqlParser;
 import com.facebook.presto.sql.tree.Statement;
@@ -30,9 +28,11 @@ import org.apache.solr.client.solrj.io.stream.ExceptionStream;
 import org.apache.solr.client.solrj.io.stream.SolrStream;
 import org.apache.solr.client.solrj.io.stream.TupleStream;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
-import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -235,11 +235,11 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexDoc(sdoc("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50"));
       indexDoc(sdoc("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60"));
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX' order by field_i desc");
+      
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", 
+          "stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX' order by field_i desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       assert(tuples.size() == 8);
@@ -286,14 +286,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("field_i") == 7);
       assert(tuple.get("str_s").equals("a"));
 
-
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-
       //Test unlimited unsorted result. Should sort on _version_ desc
-      params.put("stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX'");
+      sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX'");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 8);
@@ -339,11 +335,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.get("str_s").equals("a"));
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc limit 1");
+      sParams = mapParams(CommonParams.QT, "/sql", 
+          "stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc limit 1");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 1);
@@ -353,11 +348,9 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("field_i") == 60);
       assert(tuple.get("str_s").equals("c"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select id, field_i, str_s from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 3);
@@ -377,11 +370,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("field_i") == 7);
       assert(tuple.get("str_s").equals("a"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by myInt desc");
+      sParams = mapParams(CommonParams.QT, "/sql", 
+          "stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by myInt desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 3);
@@ -402,11 +394,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.get("myString").equals("a"));
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 3);
@@ -433,11 +424,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       boolean wasReloaded = reloadCollection(leader, "collection1");
       assertTrue(wasReloaded);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 3);
@@ -481,11 +471,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexDoc(sdoc("id", "7", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "50"));
       indexDoc(sdoc("id", "8", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "60"));
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id, Field_i, Str_s from Collection1 where Text_t='XXXX' order by Field_i desc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select id, Field_i, Str_s from Collection1 where Text_t='XXXX' order by Field_i desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       assert(tuples.size() == 8);
@@ -532,11 +521,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("Field_i") == 7);
       assert(tuple.get("Str_s").equals("a"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by Str_s having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
+      sParams = mapParams(CommonParams.QT, "/sql", 
+          "stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by Str_s having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -549,11 +537,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.get("Str_s").equals("a"));
       assert(tuple.getDouble("sum(Field_i)") == 7);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by 'Str_s' having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by 'Str_s' having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -591,55 +578,50 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexDoc(sdoc("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60"));
       commit();
 
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_iff desc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_iff desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       Tuple tuple = getTuple(new ExceptionStream(solrStream));
       assert(tuple.EOF);
       assert(tuple.EXCEPTION);
       //A parse exception detected before being sent to the search engine
       assert(tuple.getException().contains("Fields in the sort spec must be included in the field list"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select id, field_iff, str_s from collection1 where text='XXXX' order by field_iff desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select id, field_iff, str_s from collection1 where text='XXXX' order by field_iff desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuple = getTuple(new ExceptionStream(solrStream));
       assert(tuple.EOF);
       assert(tuple.EXCEPTION);
       //An exception not detected by the parser thrown from the /select handler
       assert(tuple.getException().contains("sort param field can't be found:"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuple = getTuple(new ExceptionStream(solrStream));
       assert(tuple.EOF);
       assert(tuple.EXCEPTION);
       //An exception not detected by the parser thrown from the /export handler
       assert(tuple.getException().contains("undefined field:"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuple = getTuple(new ExceptionStream(solrStream));
       assert(tuple.EOF);
       assert(tuple.EXCEPTION);
       //An exception not detected by the parser thrown from the /export handler
       assert(tuple.getException().contains("Invalid function: blah"));
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s from collection1 where text='XXXX' group by str_s");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s from collection1 where text='XXXX' group by str_s");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuple = getTuple(new ExceptionStream(solrStream));
       assert(tuple.EOF);
       assert(tuple.EXCEPTION);
@@ -668,11 +650,11 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, 'count(*)', sum('field_i'), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
+      
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select str_s, 'count(*)', sum('field_i'), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -697,10 +679,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s as myString, 'count(*)', sum('field_i') as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by sum asc limit 2");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s as myString, 'count(*)', sum('field_i') as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by sum asc limit 2");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -723,11 +705,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -760,11 +741,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s as myString, count(*) as count, sum(field_i) as sum, min(field_i) as min, max(field_i) as max, avg(field_i) as avg from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s as myString, count(*) as count, sum(field_i) as sum, min(field_i) as min, max(field_i) as max, avg(field_i) as avg from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -798,11 +778,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 1);
@@ -815,11 +794,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -833,11 +811,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -852,11 +829,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 0);
@@ -886,12 +862,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -924,12 +898,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //reverse the sort
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -962,12 +934,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //reverse the sort
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct str_s as myString, field_i as myInt from collection1 order by str_s desc, myInt desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct str_s as myString, field_i as myInt from collection1 order by str_s desc, myInt desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -999,12 +969,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("myInt") == 1);
 
       //test with limit
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1020,12 +988,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test without a sort. Sort should be asc by default.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct str_s, field_i from collection1");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct str_s, field_i from collection1");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1057,12 +1023,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test with a predicate.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1100,11 +1064,11 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
+      
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1137,11 +1101,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //reverse the sort
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1173,11 +1136,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("field_i") == 1);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct str_s as myString, field_i from collection1 order by myString desc, field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct str_s as myString, field_i from collection1 order by myString desc, field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1210,11 +1172,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //test with limit
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1230,11 +1191,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test without a sort. Sort should be asc by default.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct str_s, field_i from collection1");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct str_s, field_i from collection1");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1265,11 +1225,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test with a predicate.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1306,12 +1265,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1344,12 +1301,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //reverse the sort
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1382,12 +1337,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //reverse the sort
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s as myString, field_i from collection1 order by myString desc, field_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s as myString, field_i from collection1 order by myString desc, field_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1420,12 +1373,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
       //test with limit
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1441,12 +1392,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test without a sort. Sort should be asc by default.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s, field_i from collection1");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s, field_i from collection1");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 6);
@@ -1477,12 +1426,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
       // Test with a predicate.
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 2);
@@ -1520,12 +1467,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select 'str_s', 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+      "stmt", "select 'str_s', 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1549,12 +1494,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 20);
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -1586,12 +1529,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 20);
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by myString order by myString desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by myString order by myString desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -1626,12 +1567,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having 'sum(field_i)' = 19");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having 'sum(field_i)' = 19");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 1);
@@ -1644,12 +1583,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having (('sum(field_i)' = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having (('sum(field_i)' = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1664,12 +1601,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1683,12 +1618,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 0);
@@ -1721,12 +1654,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
       indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1750,14 +1681,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 20);
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum asc limit 2");
 
-
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum asc limit 2");
-
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1780,12 +1707,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by str_s desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by str_s desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -1818,12 +1743,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s as myString, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString order by myString desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",                           
+        "stmt", "select str_s as myString, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString order by myString desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@ -1856,12 +1779,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("avg(field_i)") == 13.5D);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1883,12 +1804,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -1902,12 +1821,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("max(field_i)") == 11);
       assert(tuple.getDouble("avg(field_i)") == 9.5D);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", "2");
-      params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       assert(tuples.size() == 0);
@@ -1939,11 +1856,9 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
     commit();
 
-    Map params = new HashMap();
-    params.put(CommonParams.QT, "/sql");
-    params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
+    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
 
-    SolrStream solrStream = new SolrStream(jetty.url, params);
+    SolrStream solrStream = new SolrStream(jetty.url, sParams);
 
 
     List<Tuple> tuples = getTuples(solrStream);
@@ -1976,12 +1891,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
 
 
-    params = new HashMap();
-    params.put(CommonParams.QT, "/sql");
-    params.put("stmt", "select count(*) as count, sum(a_i) as sum, min(a_i) as min, max(a_i) as max, avg(a_i) as avg, sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
-
-    solrStream = new SolrStream(jetty.url, params);
+    sParams = mapParams(CommonParams.QT, "/sql",
+      "stmt", "select count(*) as count, sum(a_i) as sum, min(a_i) as min, max(a_i) as max, avg(a_i) as avg, sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
 
+    solrStream = new SolrStream(jetty.url, sParams);
 
     tuples = getTuples(solrStream);
 
@@ -2016,11 +1929,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
     // Test where clause hits
 
-    params = new HashMap();
-    params.put(CommonParams.QT, "/sql");
-    params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
+    sParams = mapParams(CommonParams.QT, "/sql",
+      "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
 
-    solrStream = new SolrStream(jetty.url, params);
+    solrStream = new SolrStream(jetty.url, sParams);
 
     tuples = getTuples(solrStream);
 
@@ -2051,11 +1963,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
 
     // Test zero hits
 
-    params = new HashMap();
-    params.put(CommonParams.QT, "/sql");
-    params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
+    sParams = mapParams(CommonParams.QT, "/sql",
+      "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
 
-    solrStream = new SolrStream(jetty.url, params);
+    solrStream = new SolrStream(jetty.url, sParams);
 
     tuples = getTuples(solrStream);
 
@@ -2109,11 +2020,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "8", "year_i", "2014", "month_i", "4",  "day_i", "2", "item_i", "1");
 
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2129,9 +2039,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("year_i") == 2014);
       assert(tuple.getDouble("sum(item_i)") == 7);
 
-      params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+          "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2154,11 +2065,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("month_i") == 4);
       assert(tuple.getDouble("sum(item_i)") == 7);
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql",
+        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2227,12 +2137,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "8", "year_i", "2014", "month_i", "4", "day_i", "2", "item_i", "1");
 
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2249,12 +2157,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("sum(item_i)") == 7);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2276,12 +2182,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("sum(item_i)") == 7);
 
 
-      params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("aggregationMode", "facet");
-      params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2346,12 +2250,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       indexr("id", "8", "year_i", "2014", "month_i", "4", "day_i", "2", "item_i", "1");
 
       commit();
-      Map params = new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", 2);
-      params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+      SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2", 
+          "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
 
-      SolrStream solrStream = new SolrStream(jetty.url, params);
+      SolrStream solrStream = new SolrStream(jetty.url, sParams);
       List<Tuple> tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2368,12 +2270,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getLong("year_i") == 2014);
       assert(tuple.getDouble("sum(item_i)") == 7);
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", 2);
-      params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2399,12 +2299,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
       assert(tuple.getDouble("sum(item_i)") == 7);
 
 
-      new HashMap();
-      params.put(CommonParams.QT, "/sql");
-      params.put("numWorkers", 2);
-      params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
+      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
 
-      solrStream = new SolrStream(jetty.url, params);
+      solrStream = new SolrStream(jetty.url, sParams);
       tuples = getTuples(solrStream);
 
       //Only two results because of the limit.
@@ -2456,12 +2354,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
   private void testCatalogStream() throws Exception {
     CloudJettyRunner jetty = this.cloudJettys.get(0);
 
-    Map<String, Object> params = new HashMap<>();
-    params.put(CommonParams.QT, "/sql");
-    params.put("numWorkers", 2);
-    params.put("stmt", "select TABLE_CAT from _CATALOGS_");
+    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+      "stmt", "select TABLE_CAT from _CATALOGS_");
 
-    SolrStream solrStream = new SolrStream(jetty.url, params);
+    SolrStream solrStream = new SolrStream(jetty.url, sParams);
     List<Tuple> tuples = getTuples(solrStream);
 
     assertEquals(tuples.size(), 1);
@@ -2471,12 +2367,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
   private void testSchemasStream() throws Exception {
     CloudJettyRunner jetty = this.cloudJettys.get(0);
 
-    Map<String, Object> params = new HashMap<>();
-    params.put(CommonParams.QT, "/sql");
-    params.put("numWorkers", 2);
-    params.put("stmt", "select TABLE_SCHEM, TABLE_CATALOG from _SCHEMAS_");
+    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+      "stmt", "select TABLE_SCHEM, TABLE_CATALOG from _SCHEMAS_");
 
-    SolrStream solrStream = new SolrStream(jetty.url, params);
+    SolrStream solrStream = new SolrStream(jetty.url, sParams);
     List<Tuple> tuples = getTuples(solrStream);
 
     assertEquals(tuples.size(), 0);
@@ -2485,12 +2379,10 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
   private void testTablesStream() throws Exception {
     CloudJettyRunner jetty = this.cloudJettys.get(0);
 
-    Map<String, Object> params = new HashMap<>();
-    params.put(CommonParams.QT, "/sql");
-    params.put("numWorkers", 2);
-    params.put("stmt", "select TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, REMARKS from _TABLES_");
+    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
+      "stmt", "select TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, REMARKS from _TABLES_");
 
-    SolrStream solrStream = new SolrStream(jetty.url, params);
+    SolrStream solrStream = new SolrStream(jetty.url, sParams);
     List<Tuple> tuples = getTuples(solrStream);
 
     assertEquals(2, tuples.size());
@@ -2542,4 +2434,15 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
     tupleStream.close();
     return t;
   }
+
+  public static SolrParams mapParams(String... vals) {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    assertEquals("Parameters passed in here must be in pairs!", 0, (vals.length % 2));
+    for (int idx = 0; idx < vals.length; idx += 2) {
+      params.add(vals[idx], vals[idx + 1]);
+    }
+
+    return params;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java
index 90ac1cb..10bd634 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java
@@ -45,7 +45,10 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParamete
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SolrjNamedThreadFactory;
 
 public class GatherNodesStream extends TupleStream implements Expressible {
@@ -404,7 +407,7 @@ public class GatherNodesStream extends TupleStream implements Expressible {
 
     public List<Tuple> call() {
 
-      Map joinParams = new HashMap();
+
       Set<String> flSet = new HashSet();
       flSet.add(gather);
       flSet.add(traverseTo);
@@ -435,11 +438,11 @@ public class GatherNodesStream extends TupleStream implements Expressible {
           buf.append(",");
         }
       }
-
-      joinParams.putAll(queryParams);
-      joinParams.put("fl", buf.toString());
-      joinParams.put("qt", "/export");
-      joinParams.put("sort", gather + " asc,"+traverseTo +" asc");
+      
+      ModifiableSolrParams joinSParams = new ModifiableSolrParams(SolrParams.toMultiMap(new NamedList(queryParams)));
+      joinSParams.set("fl", buf.toString());
+      joinSParams.set("qt", "/export");
+      joinSParams.set("sort", gather + " asc,"+traverseTo +" asc");
 
       StringBuffer nodeQuery = new StringBuffer();
 
@@ -454,14 +457,14 @@ public class GatherNodesStream extends TupleStream implements Expressible {
 
       if(maxDocFreq > -1) {
         String docFreqParam = " maxDocFreq="+maxDocFreq;
-        joinParams.put("q", "{!graphTerms f=" + traverseTo + docFreqParam + "}" + nodeQuery.toString());
+        joinSParams.set("q", "{!graphTerms f=" + traverseTo + docFreqParam + "}" + nodeQuery.toString());
       } else {
-        joinParams.put("q", "{!terms f=" + traverseTo+"}" + nodeQuery.toString());
+        joinSParams.set("q", "{!terms f=" + traverseTo+"}" + nodeQuery.toString());
       }
 
       TupleStream stream = null;
       try {
-        stream = new UniqueStream(new CloudSolrStream(zkHost, collection, joinParams), new MultipleFieldEqualitor(new FieldEqualitor(gather), new FieldEqualitor(traverseTo)));
+        stream = new UniqueStream(new CloudSolrStream(zkHost, collection, joinSParams), new MultipleFieldEqualitor(new FieldEqualitor(gather), new FieldEqualitor(traverseTo)));
         stream.setStreamContext(streamContext);
         stream.open();
         BATCH:

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java
index 7418e0f..6d7b32a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java
@@ -46,6 +46,9 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
+import org.apache.solr.common.params.MapSolrParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.SolrjNamedThreadFactory;
 
@@ -65,8 +68,9 @@ public class ShortestPathStream extends TupleStream implements Expressible {
   private boolean found;
   private StreamContext streamContext;
   private int threads;
-  private Map<String,String> queryParams;
+  private SolrParams queryParams;
 
+  @Deprecated
   public ShortestPathStream(String zkHost,
                             String collection,
                             String fromNode,
@@ -84,6 +88,29 @@ public class ShortestPathStream extends TupleStream implements Expressible {
         toNode,
         fromField,
         toField,
+        new MapSolrParams(queryParams),
+        joinBatchSize,
+        threads,
+        maxDepth);
+  }
+
+  public ShortestPathStream(String zkHost,
+                            String collection,
+                            String fromNode,
+                            String toNode,
+                            String fromField,
+                            String toField,
+                            SolrParams queryParams,
+                            int joinBatchSize,
+                            int threads,
+                            int maxDepth) {
+
+    init(zkHost,
+        collection,
+        fromNode,
+        toNode,
+        fromField,
+        toField,
         queryParams,
         joinBatchSize,
         threads,
@@ -162,7 +189,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
       maxDepth = Integer.parseInt(((StreamExpressionValue) depthExpression.getParameter()).getValue());
     }
 
-    Map<String,String> params = new HashMap<String,String>();
+    ModifiableSolrParams params = new ModifiableSolrParams();
     for(StreamExpressionNamedParameter namedParam : namedParams){
       if(!namedParam.getName().equals("zkHost") &&
           !namedParam.getName().equals("to") &&
@@ -172,7 +199,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
           !namedParam.getName().equals("threads") &&
           !namedParam.getName().equals("partitionSize"))
       {
-        params.put(namedParam.getName(), namedParam.getParameter().toString().trim());
+        params.set(namedParam.getName(), namedParam.getParameter().toString().trim());
       }
     }
 
@@ -201,7 +228,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
                     String toNode,
                     String fromField,
                     String toField,
-                    Map queryParams,
+                    SolrParams queryParams,
                     int joinBatchSize,
                     int threads,
                     int maxDepth) {
@@ -225,10 +252,10 @@ public class ShortestPathStream extends TupleStream implements Expressible {
     // collection
     expression.addParameter(collection);
 
-    Set<Map.Entry<String,String>> entries =  queryParams.entrySet();
     // parameters
-    for(Map.Entry param : entries){
-      String value = param.getValue().toString();
+    ModifiableSolrParams mParams = new ModifiableSolrParams(queryParams);
+    for(Map.Entry<String, String[]> param : mParams.getMap().entrySet()){
+      String value = String.join(",", param.getValue());
 
       // SOLR-8409: This is a special case where the params contain a " character
       // Do note that in any other BASE streams with parameters where a " might come into play
@@ -262,8 +289,9 @@ public class ShortestPathStream extends TupleStream implements Expressible {
     StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore");
     child.setFunctionName("solr (graph)");
     child.setImplementingClass("Solr/Lucene");
-    child.setExpressionType(ExpressionType.DATASTORE);    
-    child.setExpression(queryParams.entrySet().stream().map(e -> String.format(Locale.ROOT, "%s=%s", e.getKey(), e.getValue())).collect(Collectors.joining(",")));    
+    child.setExpressionType(ExpressionType.DATASTORE);
+    ModifiableSolrParams mParams = new ModifiableSolrParams(queryParams);
+    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;
@@ -417,13 +445,12 @@ public class ShortestPathStream extends TupleStream implements Expressible {
 
     public List<Edge> call() {
 
-      Map joinParams = new HashMap();
+      ModifiableSolrParams joinParams = new ModifiableSolrParams(queryParams);
       String fl = fromField + "," + toField;
 
-      joinParams.putAll(queryParams);
-      joinParams.put("fl", fl);
-      joinParams.put("qt", "/export");
-      joinParams.put("sort", toField + " asc,"+fromField +" asc");
+      joinParams.set("fl", fl);
+      joinParams.set("qt", "/export");
+      joinParams.set("sort", toField + " asc,"+fromField +" asc");
 
       StringBuffer nodeQuery = new StringBuffer();
 
@@ -433,7 +460,7 @@ public class ShortestPathStream extends TupleStream implements Expressible {
 
       String q = fromField + ":(" + nodeQuery.toString().trim() + ")";
 
-      joinParams.put("q", q);
+      joinParams.set("q", q);
       TupleStream stream = null;
       try {
         stream = new UniqueStream(new CloudSolrStream(zkHost, collection, joinParams), new MultipleFieldEqualitor(new FieldEqualitor(toField), new FieldEqualitor(fromField)));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b4defc/solr/solrj/src/java/org/apache/solr/client/solrj/io/sql/StatementImpl.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/sql/StatementImpl.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/sql/StatementImpl.java
index 1b1200d..c05028d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/sql/StatementImpl.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/sql/StatementImpl.java
@@ -26,8 +26,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Random;
 
 import org.apache.solr.client.solrj.io.stream.SolrStream;
@@ -37,6 +35,7 @@ import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkCoreNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
 
 class StatementImpl implements Statement {
 
@@ -96,11 +95,11 @@ class StatementImpl implements Statement {
 
       Collections.shuffle(shuffler, new Random());
 
-      Map<String, String> params = new HashMap<>();
-      params.put(CommonParams.QT, "/sql");
-      params.put("stmt", sql);
+      ModifiableSolrParams params = new ModifiableSolrParams();
+      params.set(CommonParams.QT, "/sql");
+      params.set("stmt", sql);
       for(String propertyName : this.connection.getProperties().stringPropertyNames()) {
-        params.put(propertyName, this.connection.getProperties().getProperty(propertyName));
+        params.set(propertyName, this.connection.getProperties().getProperty(propertyName));
       }
 
       Replica rep = shuffler.get(0);


Mime
View raw message