You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by GitBox <gi...@apache.org> on 2020/04/20 13:31:11 UTC

[GitHub] [kafka] ijuma commented on a change in pull request #8417: KAFKA-8955: Add an AbstractResponse#errorCounts(Stream) and tidy

ijuma commented on a change in pull request #8417:
URL: https://github.com/apache/kafka/pull/8417#discussion_r411378332



##########
File path: clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java
##########
@@ -57,6 +59,10 @@ public ByteBuffer serialize(ApiKeys apiKey, short version, int correlationId) {
         return Collections.singletonMap(error, 1);
     }
 
+    protected Map<Errors, Integer> errorCounts(Stream<Errors> errors) {
+        return errors.collect(Collectors.groupingBy(e -> e, Collectors.summingInt(e -> 1)));
+    }
+
     protected Map<Errors, Integer> errorCounts(Collection<Errors> errors) {

Review comment:
       @tombentley Have we done any testing to verify that this way of doing things is no slower than the old way?

##########
File path: clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java
##########
@@ -57,6 +59,10 @@ public ByteBuffer serialize(ApiKeys apiKey, short version, int correlationId) {
         return Collections.singletonMap(error, 1);
     }
 
+    protected Map<Errors, Integer> errorCounts(Stream<Errors> errors) {
+        return errors.collect(Collectors.groupingBy(e -> e, Collectors.summingInt(e -> 1)));
+    }
+
     protected Map<Errors, Integer> errorCounts(Collection<Errors> errors) {

Review comment:
       @tombentley Have we done any testing to verify that this way of doing things is no slower than the old way?

##########
File path: clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java
##########
@@ -57,6 +59,10 @@ public ByteBuffer serialize(ApiKeys apiKey, short version, int correlationId) {
         return Collections.singletonMap(error, 1);
     }
 
+    protected Map<Errors, Integer> errorCounts(Stream<Errors> errors) {
+        return errors.collect(Collectors.groupingBy(e -> e, Collectors.summingInt(e -> 1)));

Review comment:
       @tombentley Have we done any testing to verify that this way of doing things is no slower than the old way?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org