dsmiley commented on code in PR #4320:
URL: https://github.com/apache/solr/pull/4320#discussion_r3138031093
##########
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:
I specifically referred to `MapSolrParams.getMap()` which returns
`Map<String, String>`
It's also okay to leave both... maybe marking one as deprecated to signify
an older approach.
--
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]