tarun11Mavani commented on code in PR #18980:
URL: https://github.com/apache/pinot/pull/18980#discussion_r3576415866


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java:
##########
@@ -388,20 +388,27 @@ protected void doAddSegment(ImmutableSegmentImpl segment) 
{
 
     // Update metrics
     long numPrimaryKeys = getNumPrimaryKeys();
-    updatePrimaryKeyGauge(numPrimaryKeys);
+    updatePrimaryKeyGauge(numPrimaryKeys, getPrimaryKeyMapSizeInBytes());
     _logger.info("Finished adding segment: {} in {}ms, current primary key 
count: {}", segmentName,
         System.currentTimeMillis() - startTimeMs, numPrimaryKeys);
   }
 
   protected abstract long getNumPrimaryKeys();
 
-  protected void updatePrimaryKeyGauge(long numPrimaryKeys) {
+  /**
+   * Returns the estimated size in bytes of the primary-key-to-record-location 
map.
+   */
+  protected abstract long getPrimaryKeyMapSizeInBytes();
+
+  protected void updatePrimaryKeyGauge(long numPrimaryKeys, long 
primaryKeySizeInBytes) {
     _serverMetrics.setValueOfPartitionGauge(_tableNameWithType, _partitionId, 
ServerGauge.UPSERT_PRIMARY_KEYS_COUNT,
         numPrimaryKeys);
+    _serverMetrics.setValueOfPartitionGauge(_tableNameWithType, _partitionId,
+        ServerGauge.UPSERT_PRIMARY_KEY_MAP_SIZE_IN_BYTES, 
primaryKeySizeInBytes);
   }
 
   protected void updatePrimaryKeyGauge() {
-    updatePrimaryKeyGauge(getNumPrimaryKeys());
+    updatePrimaryKeyGauge(getNumPrimaryKeys(), getPrimaryKeyMapSizeInBytes());

Review Comment:
   thanks. 
   split the per-record path onto a count-only overload; segment-lifecycle 
events (add/preload/replace/remove/close) and the periodic TTL eviction path 
still refresh both gauges.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to