Skip to content

Conversation

@DL1231
Copy link
Contributor

@DL1231 DL1231 commented Oct 25, 2025

see #19876 (comment)
Initialize fetchPartitionStatus as a Map type to reduce unnecessary collection conversions.

@github-actions github-actions bot added triage PRs from the community core Kafka Broker small Small PRs labels Oct 25, 2025
val fetchInfos = fetchPartitionStatus.asScala.map { case (tp, status) =>
tp -> status.fetchInfo
}
}.toSeq
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have duplicate TPs in this "fetch" path?

Copy link
Member

Choose a reason for hiding this comment

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

Also, we are doing two conversions here - you can avoid one by using a view or iterator after asScala and using toBuffer instead of toSeq (the latter can result in a lazy collection being created which can result in problems).


// create a list of (topic, partition) pairs to use as keys for this delayed fetch operation
val delayedFetchKeys = fetchPartitionStatus.map { case (tp, _) => new TopicPartitionOperationKey(tp) }.toList
val delayedFetchKeys = fetchPartitionStatus.asScala.map { case (tp, _) => new TopicPartitionOperationKey(tp) }.toList
Copy link
Member

Choose a reason for hiding this comment

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

Why do we convert to a Scala List if we convert to a Java collection right after? We should probably use Java's Stream here and avoid the Scala collections altogether.

@github-actions github-actions bot removed the triage PRs from the community label Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved core Kafka Broker small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants