vyatkinv commented on code in PR #4320:
URL: https://github.com/apache/solr/pull/4320#discussion_r3135473934


##########
solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/stream/TupleStream.java:
##########
@@ -213,14 +219,73 @@ public static List<String> getShards(
       }
     } else {
       shards =
-          getReplicas(zkHost, collection, streamContext, 
requestParams).stream()
+          getReplicas(solrCloud, collection, streamContext, 
requestParams).stream()
               .map(Replica::getCoreUrl)
               .collect(Collectors.toList());
     }
 
     return shards;
   }
 
+  public static String getSolrCloud(
+      StreamFactory streamFactory, StreamExpression streamExpression, String 
collectionName)
+      throws IOException {
+    var solrCloudExpression = streamFactory.getNamedOperand(streamExpression, 
"solrCloud");
+    var zkHostExpression = streamFactory.getNamedOperand(streamExpression, 
"zkHost");
+    String solrCloud = null;
+    if (zkHostExpression == null && solrCloudExpression == null) {
+      solrCloud = streamFactory.getCollectionZkHost(collectionName);
+      if (solrCloud == null) {
+        solrCloud = streamFactory.getDefaultZkHost();
+      }
+    } else if (solrCloudExpression != null
+        && solrCloudExpression.getParameter() instanceof StreamExpressionValue 
exprValue) {
+      solrCloud = exprValue.getValue();
+    } else if (zkHostExpression != null
+        && zkHostExpression.getParameter() instanceof StreamExpressionValue 
exprValue) {
+      solrCloud = exprValue.getValue();
+    }
+    if (solrCloud == null) {
+      throw new IOException(
+          String.format(
+              Locale.ROOT,
+              "invalid expression %s - solrCloud or zkHost not found for 
collection '%s'",
+              streamExpression,
+              collectionName));
+    }
+    return solrCloud;
+  }
+
+  public static ModifiableSolrParams getModifiableSolrParamsWithExclusions(
+      List<StreamExpressionNamedParameter> namedParams, String... excluded) {
+    ModifiableSolrParams mParams = new ModifiableSolrParams();
+
+    Set<String> excludedSet = new HashSet<>(Arrays.asList(excluded));
+
+    for (StreamExpressionNamedParameter namedParam : namedParams) {
+      if (!excludedSet.contains(namedParam.getName())) {
+        mParams.add(namedParam.getName(), 
namedParam.getParameter().toString().trim());
+      }
+    }
+
+    return mParams;
+  }
+
+  public static Map<String, String> getMapWithExclusions(

Review Comment:
   `ModifiableSolrParams.getMap()` returns `Map<String, String[]>` but we needs 
`Map<String, String>`
   
   That's why I asked if it was possible to convert all streams to 
`ModifiableSolrParams` :)
   
   but I'll think about it some more, maybe I can use generics or a common 
interface to make a single universal method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to