AndrewJSchofield commented on code in PR #22835:
URL: https://github.com/apache/kafka/pull/22835#discussion_r3689754904


##########
server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:
##########
@@ -196,6 +215,8 @@ public abstract class PersisterStateManagerHandler 
implements RequestCompletionH
         private final ExponentialBackoffManager findCoordBackoff;
         private Consumer<ClientResponse> onCompleteCallback;
         protected final SharePartitionKey partitionKey;
+        // Combined-response index shared across handlers; set before 
onComplete, read-and-cleared in lookupPartitionResult (KAFKA-20803).
+        protected Object sharedResultIndex;

Review Comment:
   Hmm. `Object` here is not ideal.



##########
server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:
##########
@@ -1553,10 +1593,14 @@ public Collection<RequestAndCompletionHandler> 
generateRequests() {
                                             oldVal.remove(coordNode);
                                             return oldVal;
                                         });
-                                        // now the combined request has 
completed
-                                        // we need to create responses for 
individual
-                                        // requests which composed the 
combined request
-                                        handlersPerGroup.forEach(handler1 -> 
handler1.onComplete(response));
+                                        // Demux the combined response once 
and share it across handlers (KAFKA-20803).
+                                        Object sharedResultIndex = 
handlersPerGroup.isEmpty()
+                                            ? null
+                                            : 
handlersPerGroup.get(0).buildResultIndex(response);
+                                        handlersPerGroup.forEach(handler1 -> {
+                                            handler1.sharedResultIndex = 
sharedResultIndex;
+                                            handler1.onComplete(response);
+                                        });

Review Comment:
   How about this instead?
   ```
                                           if (!handlersPerGroup.isEmpty()) {
                                               Object sharedResultIndex = 
handlersPerGroup.get(0).buildResultIndex(response);
                                               
handlersPerGroup.forEach(handler1 -> {
                                                   handler1.sharedResultIndex = 
sharedResultIndex;
                                                   
handler1.onComplete(response);
                                               });
                                           }
   
   ```



##########
server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:
##########
@@ -183,6 +185,23 @@ public void setGenerateCallback(Runnable generateCallback) 
{
         this.generateCallback = generateCallback;
     }
 
+    // Groups a combined response's results into topicId -> partition -> 
result for O(1) per-partition lookup.

Review Comment:
   Let's add a brief description of the T and P class variables here for 
readability.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to