hsyuan commented on a change in pull request #1408: [CALCITE-3288] linq4j: 
support Set literals
URL: https://github.com/apache/calcite/pull/1408#discussion_r317378271
 
 

 ##########
 File path: 
linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java
 ##########
 @@ -245,6 +249,31 @@ private static ExpressionWriter map(ExpressionWriter 
writer, Map map,
     return writer.append(end);
   }
 
+  private static ExpressionWriter writeSet(ExpressionWriter writer, Set set) {
+    writer.append("com.google.common.collect.ImmutableSet.");
+    if (set.isEmpty()) {
+      return writer.append("of()");
+    }
+    if (set.size() < 5) {
+      return set(writer, set, "of(", ",", ")");
+    }
+    return set(writer, set, "builder().add(", ")\n.add(", ").build()");
 
 Review comment:
   Can we use this method?
   ```
   public Builder<E> add(E... elements)
   ```
   So that L257~L260 can be merged.
   And the `set` method is not needed, you can replace it with `String.join` or 
`Stream` with `StringJoiner`.

----------------------------------------------------------------
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