xushiyan commented on code in PR #9088:
URL: https://github.com/apache/hudi/pull/9088#discussion_r1246084784
##########
hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java:
##########
@@ -243,40 +243,31 @@ public static boolean elementsEqual(Iterator<?>
iterator1, Iterator<?> iterator2
return !iterator2.hasNext();
}
- @SafeVarargs
- public static <T> Set<T> createSet(final T... elements) {
- return Stream.of(elements).collect(Collectors.toSet());
- }
Review Comment:
moved down
##########
hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java:
##########
@@ -243,40 +243,31 @@ public static boolean elementsEqual(Iterator<?>
iterator1, Iterator<?> iterator2
return !iterator2.hasNext();
}
- @SafeVarargs
- public static <T> Set<T> createSet(final T... elements) {
- return Stream.of(elements).collect(Collectors.toSet());
- }
-
- public static <K,V> Map<K, V> createImmutableMap(final K key, final V value)
{
- return Collections.unmodifiableMap(Collections.singletonMap(key, value));
- }
-
@SafeVarargs
public static <T> List<T> createImmutableList(final T... elements) {
return
Collections.unmodifiableList(Stream.of(elements).collect(Collectors.toList()));
}
- public static <K,V> Map<K,V> createImmutableMap(final Map<K,V> map) {
- return Collections.unmodifiableMap(map);
Review Comment:
moved down
##########
hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java:
##########
@@ -243,40 +243,31 @@ public static boolean elementsEqual(Iterator<?>
iterator1, Iterator<?> iterator2
return !iterator2.hasNext();
}
- @SafeVarargs
- public static <T> Set<T> createSet(final T... elements) {
- return Stream.of(elements).collect(Collectors.toSet());
- }
-
- public static <K,V> Map<K, V> createImmutableMap(final K key, final V value)
{
- return Collections.unmodifiableMap(Collections.singletonMap(key, value));
- }
-
@SafeVarargs
public static <T> List<T> createImmutableList(final T... elements) {
return
Collections.unmodifiableList(Stream.of(elements).collect(Collectors.toList()));
}
- public static <K,V> Map<K,V> createImmutableMap(final Map<K,V> map) {
- return Collections.unmodifiableMap(map);
+ public static <T> List<T> createImmutableList(final List<T> list) {
+ return Collections.unmodifiableList(list);
}
@SafeVarargs
- public static <K,V> Map<K,V> createImmutableMap(final Pair<K,V>... elements)
{
- Map<K,V> map = new HashMap<>();
- for (Pair<K,V> pair: elements) {
+ public static <K, V> Map<K, V> createImmutableMap(final Pair<K, V>...
elements) {
+ Map<K, V> map = new HashMap<>();
+ for (Pair<K, V> pair : elements) {
map.put(pair.getLeft(), pair.getRight());
}
return Collections.unmodifiableMap(map);
}
+ public static <K, V> Map<K, V> createImmutableMap(final Map<K, V> map) {
+ return Collections.unmodifiableMap(map);
+ }
+
@SafeVarargs
- public static <K,V> HashMap<K, V> createHashMap(final Pair<K, V>...
elements) {
- HashMap<K,V> map = new HashMap<>();
- for (Pair<K,V> pair: elements) {
- map.put(pair.getLeft(), pair.getRight());
- }
- return map;
Review Comment:
removed. not used.
##########
hudi-common/src/main/java/org/apache/hudi/common/util/CollectionUtils.java:
##########
@@ -243,40 +243,31 @@ public static boolean elementsEqual(Iterator<?>
iterator1, Iterator<?> iterator2
return !iterator2.hasNext();
}
- @SafeVarargs
- public static <T> Set<T> createSet(final T... elements) {
- return Stream.of(elements).collect(Collectors.toSet());
- }
-
- public static <K,V> Map<K, V> createImmutableMap(final K key, final V value)
{
- return Collections.unmodifiableMap(Collections.singletonMap(key, value));
- }
Review Comment:
removed. use singletonMap() instead. this overloading interferes with
`createImmutableMap(final Pair<K, V>... elements` when there are 2 `Pair`s
--
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]