nozjkoitop commented on code in PR #19548:
URL: https://github.com/apache/druid/pull/19548#discussion_r3429067629


##########
processing/src/main/java/org/apache/druid/query/dimension/LookupDimensionSpec.java:
##########
@@ -136,18 +139,51 @@ public String getName()
   @Override
   public ExtractionFn getExtractionFn()
   {
-    final LookupExtractor lookupExtractor;
+    final LookupExtractor lookupExtractor = getLookupExtractor();
+    return makeLookupExtractionFn(lookupExtractor);
+  }
+
+  @Override
+  public ExtractionFn getExtractionFnForMetadata()
+  {
+    return makeLookupExtractionFn(getLookupExtractorForMetadata());
+  }
+
+  private LookupExtractor getLookupExtractor()
+  {
+    if (Strings.isNullOrEmpty(name)) {
+      return this.lookup;
+    }
+
+    final LookupExtractorFactory lookupExtractorFactory = 
getLookupExtractorFactory();
 
+    final Optional<RetainedLookupExtractor> retainedLookupExtractor =
+        lookupExtractorFactory.acquireRetainedLookupExtractor();
+
+    // ExtractionFn has no close hook. The RetainedLookupExtractor cleaner 
releases this reference when the
+    // LookupExtractionFn that owns it becomes unreachable.
+    return retainedLookupExtractor.<LookupExtractor>map(retained -> 
retained).orElseGet(lookupExtractorFactory);

Review Comment:
   that makes sense, I moved the rest of the metadata-only checks to the 
non-retained path and changed TopN so it only retains once, but the other call 
sites should stay on the retiring flow so in-flight queries don’t lose the 
lookup they’re using



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