rreddy-22 commented on code in PR #15152: URL: https://github.com/apache/kafka/pull/15152#discussion_r1446780228
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java: ########## @@ -453,19 +454,31 @@ public Group group(String groupId, long committedOffset) throws GroupIdNotFoundE /** * Get the Group List. * - * @param statesFilter The states of the groups we want to list. - * If empty all groups are returned with their state. - * @param committedOffset A specified committed offset corresponding to this shard + * @param statesFilter The states of the groups we want to list. + * If empty, all groups are returned with their state. + * @param typesFilter The types of the groups we want to list. + * If empty, all groups are returned with their type. + * @param committedOffset A specified committed offset corresponding to this shard. * * @return A list containing the ListGroupsResponseData.ListedGroup */ + public List<ListGroupsResponseData.ListedGroup> listGroups( + List<String> statesFilter, + List<String> typesFilter, + long committedOffset + ) { + Predicate<Group> combinedFilter = group -> { + boolean stateCheck = statesFilter.isEmpty() || statesFilter.contains(group.stateAsString(committedOffset)); + boolean typeCheck = typesFilter.isEmpty() || typesFilter.contains(group.type().toString()); + return stateCheck && typeCheck; + }; - public List<ListGroupsResponseData.ListedGroup> listGroups(List<String> statesFilter, long committedOffset) { - Stream<Group> groupStream = groups.values(committedOffset).stream(); - if (!statesFilter.isEmpty()) { - groupStream = groupStream.filter(group -> statesFilter.contains(group.stateAsString(committedOffset))); - } - return groupStream.map(group -> group.asListedGroup(committedOffset)).collect(Collectors.toList()); + Stream<Group> groupStream = groups.values(committedOffset).parallelStream(); Review Comment: thanks for the comment! okay I can make the change :) My understanding was that we want to scale to a large number of groups so I was trying to optimize wherever I could! -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org