[ 
https://issues.apache.org/jira/browse/GOBBLIN-955?focusedWorklogId=341376&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-341376
 ]

ASF GitHub Bot logged work on GOBBLIN-955:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Nov/19 16:48
            Start Date: 11/Nov/19 16:48
    Worklog Time Spent: 10m 
      Work Description: htran1 commented on pull request #2804: GOBBLIN-955: 
Expose a method to get average record size in KafkaExtra…
URL: https://github.com/apache/incubator-gobblin/pull/2804#discussion_r344804136
 
 

 ##########
 File path: 
gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaExtractorStatsTracker.java
 ##########
 @@ -295,6 +299,30 @@ public void emitTrackingEvents(MetricContext context, 
MultiLongWatermark lowWate
     }
   }
 
+  /**
+   *
+   * @param partitionIdx the index of Kafka partition
+   * @return the average record size of records for a given {@link 
KafkaPartition}
+   */
+  public long getAvgRecordSize(int partitionIdx) {
+    ExtractorStats stats = 
this.statsMap.getOrDefault(this.partitions.get(partitionIdx), null);
+    if (stats != null) {
+      if (stats.getAvgRecordSize() != 0) {
+        //Average record size already computed.
+        return stats.getAvgRecordSize();
+      } else {
+        //Compute average record size
+        if (stats.getProcessedRecordCount() != 0) {
+          return stats.getPartitionTotalSize() / 
stats.getProcessedRecordCount();
+        } else {
 
 Review comment:
   How about removing this else and the outermost else and replacing with a 
return 0 at the end?
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 341376)
    Time Spent: 20m  (was: 10m)

> Expose a method to get average record size in KafkaExtractorStatsTracker
> ------------------------------------------------------------------------
>
>                 Key: GOBBLIN-955
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-955
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-kafka
>    Affects Versions: 0.15.0
>            Reporter: Sudarshan Vasudevan
>            Assignee: Shirshanka Das
>            Priority: Major
>             Fix For: 0.15.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> The method returns the average record size based on the accumulated stats.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to