You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2023/01/13 19:58:04 UTC
[GitHub] [kafka] artemlivshits commented on a diff in pull request #12901: KAFKA-14367; Add `TxnOffsetCommit` to the new `GroupCoordinator` interface
artemlivshits commented on code in PR #12901:
URL: https://github.com/apache/kafka/pull/12901#discussion_r1069963790
##########
core/src/main/scala/kafka/coordinator/group/GroupCoordinatorAdapter.scala:
##########
@@ -397,19 +389,24 @@ class GroupCoordinatorAdapter(
request: TxnOffsetCommitRequestData,
bufferSupplier: BufferSupplier
): CompletableFuture[TxnOffsetCommitResponseData] = {
+ val currentTimeMs = time.milliseconds
val future = new CompletableFuture[TxnOffsetCommitResponseData]()
def callback(results: Map[TopicPartition, Errors]): Unit = {
val response = new TxnOffsetCommitResponseData()
- val byTopics = new util.HashMap[String, TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic]()
+ val byTopics = new mutable.HashMap[String, TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic]()
results.forKeyValue { (tp, error) =>
- var topic = byTopics.get(tp.topic)
- if (topic == null) {
- topic = new TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic().setName(tp.topic)
- byTopics.put(tp.topic, topic)
- response.topics.add(topic)
+ val topic = byTopics.get(tp.topic) match {
Review Comment:
The downside is double-lookup (one for get and another for insert).
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org