FrankChen021 commented on code in PR #19548:
URL: https://github.com/apache/druid/pull/19548#discussion_r3435737696
##########
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:
I think one wrapper path still needs the same treatment. For a
`ListFilteredDimensionSpec`, `RegexFilteredDimensionSpec`, or
`PrefixFilteredDimensionSpec` around a named `LookupDimensionSpec`,
`BaseFilteredDimensionSpec` inherits the default
`getExtractionFnForMetadata()`, which calls `getExtractionFn()` and therefore
still acquires/discards a retained lookup during the metadata-only checks you
updated. `ListFilteredDimensionSpec.decorate` also calls
`delegate.getExtractionFn() != null` only as an inspection, so that path has
the same no-close behavior.
Can you add a `BaseFilteredDimensionSpec#getExtractionFnForMetadata()`
override that delegates to `delegate.getExtractionFnForMetadata()`, and switch
the `ListFilteredDimensionSpec.decorate` boolean check to the metadata accessor
as well?
Reviewed 36 of 36 changed files.
--
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]