Skip to content

[MINOR] Improve CollectionUtils helper methods#9088

Merged
xushiyan merged 1 commit intoapache:masterfrom
xushiyan:minor-fix-utils
Jun 29, 2023
Merged

[MINOR] Improve CollectionUtils helper methods#9088
xushiyan merged 1 commit intoapache:masterfrom
xushiyan:minor-fix-utils

Conversation

@xushiyan
Copy link
Member

Change Logs

Remove createImmutableMap(final K key, final V value), which interferes with overloaded method createImmutableMap(final Pair<K,V>... elements). Use Collections.singletonMap() instead.

Impact

Core utils.

Risk level

Low.

Documentation Update

NA

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

Comment on lines -247 to -249
public static <T> Set<T> createSet(final T... elements) {
return Stream.of(elements).collect(Collectors.toSet());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved down

Comment on lines -251 to -253
public static <K,V> Map<K, V> createImmutableMap(final K key, final V value) {
return Collections.unmodifiableMap(Collections.singletonMap(key, value));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. use singletonMap() instead. this overloading interferes with createImmutableMap(final Pair<K, V>... elements when there are 2 Pairs

Comment on lines -260 to -261
public static <K,V> Map<K,V> createImmutableMap(final Map<K,V> map) {
return Collections.unmodifiableMap(map);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved down

Comment on lines -274 to -279
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. not used.

@apache apache deleted a comment from hudi-bot Jun 29, 2023
@xushiyan xushiyan added the priority:high Significant impact; potential bugs label Jun 29, 2023
@hudi-bot
Copy link
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@xushiyan xushiyan merged commit 8def3e6 into apache:master Jun 29, 2023
@xushiyan xushiyan deleted the minor-fix-utils branch June 29, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high Significant impact; potential bugs

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants