tibrewalpratik17 commented on code in PR #12037:
URL: https://github.com/apache/pinot/pull/12037#discussion_r1416264208


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/ConcurrentMapPartitionUpsertMetadataManager.java:
##########
@@ -231,13 +233,49 @@ protected void removeSegment(IndexSegment segment, 
MutableRoaringBitmap validDoc
 
   @Override
   public void doRemoveExpiredPrimaryKeys() {
-    double threshold = _largestSeenComparisonValue - _metadataTTL;
+    AtomicInteger numDeletedKeys = new AtomicInteger();
+    long startTime = System.currentTimeMillis();
+    double metadataTTLKeysThreshold;
+    if (_metadataTTL > 0) {
+      metadataTTLKeysThreshold = _largestSeenComparisonValue - _metadataTTL;
+    } else {
+      metadataTTLKeysThreshold = Double.MIN_VALUE;
+    }
+
+    double deletedKeysThreshold;
+
+    if (_deletedKeysTTL > 0) {
+      deletedKeysThreshold = _largestSeenComparisonValue - _deletedKeysTTL;
+    } else {
+      deletedKeysThreshold = Double.MIN_VALUE;
+    }
     _primaryKeyToRecordLocationMap.forEach((primaryKey, recordLocation) -> {
-      if (((Number) recordLocation.getComparisonValue()).doubleValue() < 
threshold) {
+      if (_metadataTTL > 0 && ((Number) 
recordLocation.getComparisonValue()).doubleValue() < metadataTTLKeysThreshold) {
         _primaryKeyToRecordLocationMap.remove(primaryKey, recordLocation);
+        numDeletedKeys.getAndIncrement();
+      } else if (_deletedKeysTTL > 0
+          && ((Number) recordLocation.getComparisonValue()).doubleValue() < 
deletedKeysThreshold) {
+        ThreadSafeMutableRoaringBitmap currentQueryableDocIds = 
recordLocation.getSegment().getQueryableDocIds();
+        // if key not part of queryable doc id, it means it is deleted
+        if (currentQueryableDocIds != null && 
!currentQueryableDocIds.contains(recordLocation.getDocId())) {

Review Comment:
   Will it not throw NPE in 
`!currentQueryableDocIds.contains(recordLocation.getDocId()))` ? 



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