dsmiley commented on code in PR #1501:
URL: https://github.com/apache/solr/pull/1501#discussion_r1155050465
##########
solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java:
##########
@@ -363,4 +366,16 @@ public static String formatString(String pattern,
Object... args) {
public static boolean isNullOrEmpty(String string) {
return string == null || string.isEmpty();
}
+
+ public static String stringFromReader(Reader inReader) throws IOException {
+ try (Reader reader = new BufferedReader(inReader)) {
+ char[] arr = new char[8 * 1024];
+ StringBuilder buffer = new StringBuilder();
Review Comment:
triple buffering?!
##########
solr/core/src/java/org/apache/solr/cluster/placement/plugins/MinimizeCoresPlacementFactory.java:
##########
@@ -123,20 +123,23 @@ public List<PlacementPlan> computePlacements(
// replicas on nodes with less cores first. We only need
totalReplicasPerShard nodes given
// that's the number of replicas to place. We assign based on the
passed
// nodeEntriesToAssign list so the right nodes get replicas.
- ArrayList<Map.Entry<Integer, Node>> nodeEntriesToAssign =
+ List<Map.Entry<Integer, Node>> nodeEntriesToAssign =
new ArrayList<>(totalReplicasPerShard);
- Iterator<Map.Entry<Integer, Node>> treeIterator =
nodesByCores.entries().iterator();
+ Iterator<Map.Entry<Integer, Node>> treeIterator =
+ nodesByCores.entrySet().stream()
+ .flatMap(e -> e.getValue().stream().map(n ->
Map.entry(e.getKey(), n)))
+ .iterator();
for (int i = 0; i < totalReplicasPerShard; i++) {
Review Comment:
Since you are adding the use of streams above, you might as well remove the
need for an iterator and for loop as well. use
`Stream.limit(totalReplicasPerShard).collect(Collectors.toList())` and then the
whole concoction becomes rather satisfying IMO.
##########
solr/solrj/src/java/org/apache/solr/common/util/StrUtils.java:
##########
@@ -363,4 +366,16 @@ public static String formatString(String pattern,
Object... args) {
public static boolean isNullOrEmpty(String string) {
return string == null || string.isEmpty();
}
+
+ public static String stringFromReader(Reader inReader) throws IOException {
+ try (Reader reader = new BufferedReader(inReader)) {
+ char[] arr = new char[8 * 1024];
+ StringBuilder buffer = new StringBuilder();
Review Comment:
instead I recommend inReader.transferTo(StringWriter)
--
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]