asereda-gs commented on a change in pull request #1447: Calcite-3335: Getting 
new parameter from model to set it in HTTP host…
URL: https://github.com/apache/calcite/pull/1447#discussion_r322849668
 
 

 ##########
 File path: 
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchemaFactory.java
 ##########
 @@ -56,15 +58,30 @@ public ElasticsearchSchemaFactory() {
 
     try {
       final String coordinatesString = (String) map.get("coordinates");
-      Preconditions.checkState(coordinatesString != null,
-          "'coordinates' is missing in configuration");
 
-      final Map<String, Integer> coordinates = 
mapper.readValue(coordinatesString,
-          new TypeReference<Map<String, Integer>>() { });
+      final String hostsString = (String) map.get("hosts");
 
-      // create client
-      final RestClient client = connect(coordinates);
+      final Set<HttpHost> hostSet = new LinkedHashSet<>();
+
+      if (coordinatesString != null) {
+        final Map<String, Integer> coordinates = 
mapper.readValue(coordinatesString,
+                new TypeReference<Map<String, Integer>>() { });
+
+        coordinates.forEach((hostName, port) ->  hostSet.add(new 
HttpHost(hostName, port)));
 
 Review comment:
   instead of modifying the state (`hosts`) variable (using `forEach`) can you 
use streams ? 
   ```java
   hosts = coordinates.entrySet()
   .stream(entry -> new HttpHost(entry.getKey(), 
entry.getValue())).collect(Collectors.toList());
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to