JAkutenshi commented on code in PR #4707: URL: https://github.com/apache/ignite-3/pull/4707#discussion_r1846380551
########## modules/core/src/main/java/org/apache/ignite/internal/util/CollectionUtils.java: ########## @@ -171,6 +171,33 @@ public static <T> Set<T> union(@Nullable Set<T> set, @Nullable T... ts) { return unmodifiableSet(res); } + + /** + * Logical union on two probably {@code null} or empty sets. + * + * @param firstSet First operand. + * @param secondSet Second operand. + * @return Result of the union. + */ + public static <T> Set<T> union(@Nullable Set<T> firstSet, @Nullable Set<T> secondSet) { + boolean isFirstSetEmptyOrNull = nullOrEmpty(firstSet); + boolean isSecondSetEmptyOrNull = nullOrEmpty(secondSet); + + if (isFirstSetEmptyOrNull && isSecondSetEmptyOrNull) { + return new HashSet<>(); + } else if (isFirstSetEmptyOrNull) { + return new HashSet<>(secondSet); + } else if (isSecondSetEmptyOrNull) { + return new HashSet<>(firstSet); Review Comment: Because the original set may be used outside separately from the union's result -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org