thelabdude commented on a change in pull request #2067: URL: https://github.com/apache/lucene-solr/pull/2067#discussion_r527028199
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java ########## @@ -334,88 +330,76 @@ private StreamComparator parseComp(String sort, String fl) throws IOException { public static Slice[] getSlices(String collectionName, ZkStateReader zkStateReader, boolean checkAlias) throws IOException { ClusterState clusterState = zkStateReader.getClusterState(); - Map<String, DocCollection> collectionsMap = clusterState.getCollectionsMap(); - - //TODO we should probably split collection by comma to query more than one - // which is something already supported in other parts of Solr - // check for alias or collection List<String> allCollections = new ArrayList<>(); String[] collectionNames = collectionName.split(","); + Aliases aliases = checkAlias ? zkStateReader.getAliases() : null; + for(String col : collectionNames) { - List<String> collections = checkAlias - ? zkStateReader.getAliases().resolveAliases(col) // if not an alias, returns collectionName + List<String> collections = (aliases != null) + ? aliases.resolveAliases(col) // if not an alias, returns collectionName : Collections.singletonList(collectionName); allCollections.addAll(collections); } // Lookup all actives slices for these collections List<Slice> slices = allCollections.stream() - .map(collectionsMap::get) + .map(c -> clusterState.getCollectionOrNull(c, true)) .filter(Objects::nonNull) .flatMap(docCol -> Arrays.stream(docCol.getActiveSlicesArr())) .collect(Collectors.toList()); if (!slices.isEmpty()) { - return slices.toArray(new Slice[slices.size()]); - } - - // Check collection case insensitive - for(Entry<String, DocCollection> entry : collectionsMap.entrySet()) { - if(entry.getKey().equalsIgnoreCase(collectionName)) { - return entry.getValue().getActiveSlicesArr(); - } + return slices.toArray(new Slice[0]); } throw new IOException("Slices not found for " + collectionName); } protected void constructStreams() throws IOException { + final ModifiableSolrParams mParams = adjustParams(new ModifiableSolrParams(params)); + mParams.set(DISTRIB, "false"); // We are the aggregator. try { + final Stream<SolrStream> streamOfSolrStream; + if (streamContext != null && streamContext.get("shards") != null) { + // stream of shard url with core + streamOfSolrStream = getShards(this.zkHost, this.collection, this.streamContext, mParams).stream() + .map(s -> new SolrStream(s, mParams)); + } else { + // stream of replicas to reuse the same SolrHttpClient per baseUrl + // avoids re-parsing data we already have in the replicas + streamOfSolrStream = getReplicas(this.zkHost, this.collection, this.streamContext, mParams).stream() Review comment: Here we're keeping the Replica so we have direct access to its baseUrl and core name instead of parsing those out of the shardUrl ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org