[ 
https://issues.apache.org/jira/browse/KAFKA-10093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18015424#comment-18015424
 ] 

Ksolves India Limited edited comment on KAFKA-10093 at 8/21/25 12:50 PM:
-------------------------------------------------------------------------

Hi [~ijuma] / [~jghoman] 

It looks like recent versions of Kafka have removed the method:
{code:java}
public static <T> Set<T> mkSet(T... elems) {code}
Given that {{mkSortedSet}} does not require predefined sizing, would it make 
sense to simplify the implementation by using {{Collections.addAll(result, 
elems)}} Instead of iterating and adding elements one by one?
{code:java}
public static <T extends Comparable<T>> SortedSet<T> mkSortedSet(T... 
elems){code}


was (Author: JIRAUSER305714):
Hi [~ijuma] / [~jghoman] 

It looks like recent versions of Kafka have removed the method:
public static <T> Set<T> mkSet(T... elems) 
Given that {{mkSortedSet}} does not require predefined sizing, would it make 
sense to simplify the implementation by using {{Collections.addAll(result, 
elems)}} Instead of iterating and adding elements one by one?
public static <T extends Comparable<T>> SortedSet<T> mkSortedSet(T... elems) {

> Replace iteration with call to addAll in Utils
> ----------------------------------------------
>
>                 Key: KAFKA-10093
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10093
>             Project: Kafka
>          Issue Type: Improvement
>          Components: clients
>            Reporter: Jakob Homan
>            Assignee: Ksolves India Limited
>            Priority: Trivial
>              Labels: newbie
>
> n.b. This is a newbie ticket designed to be an introduction to contributing 
> for the assignee.
> In clients/src/main/java/org/apache/kafka/common/utils/Utils.java we're 
> currently using iteration to add all the elements from one collection into 
> another. We can replace this with a call to Arrays.asList() and 
> Collections.addAll().
> {code}/**
>  * Creates a set
>  * @param elems the elements
>  * @param <T> the type of element
>  * @return Set
>  */
>  @SafeVarargs
>  public static <T> Set<T> mkSet(T... elems) {
>  Set<T> result = new HashSet<>((int) (elems.length / 0.75) + 1);
>  for (T elem : elems)
>  result.add(elem);
>  return result;
>  }
> /**
>  * Creates a sorted set
>  * @param elems the elements
>  * @param <T> the type of element, must be comparable
>  * @return SortedSet
>  */
>  @SafeVarargs
>  public static <T extends Comparable<T>> SortedSet<T> mkSortedSet(T... elems) 
> {
>  SortedSet<T> result = new TreeSet<>();
>  for (T elem : elems)
>  result.add(elem);
>  return result;
>  }{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to