Package org.apache.druid.query.lookup
Class LookupExtractor
java.lang.Object
org.apache.druid.query.lookup.LookupExtractor
- Direct Known Subclasses:
ImmutableLookupMap.ImmutableLookupExtractor,MapLookupExtractor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringApply a particular lookup methodology to the input stringasMap()Returns a Map view of this lookup extractor.longEstimated heap footprint of this object.abstract byte[]Create a cache key for use in results cachingbooleanabstract booleanReturns whether this lookup extractor'sasMap()will return a valid map.Reverse lookup from a given value.unapplyAll(Set<String> values) Reverse lookup from a given set of values.
-
Constructor Details
-
LookupExtractor
public LookupExtractor()
-
-
Method Details
-
apply
Apply a particular lookup methodology to the input string- Parameters:
key- The value to apply the lookup to.- Returns:
- The value for this key, or null when key is `null` or when key cannot have the lookup applied to it and should be treated as missing.
-
applyAll
- Parameters:
keys- set of keys to apply lookup for each element- Returns:
- Returns
Mapwhose keys are the contents ofkeysand whose values are computed on demand using lookup functionunapply(String)or empty map ifvaluesis `null` User can override this method if there is a better way to perform bulk lookup
-
unapply
Reverse lookup from a given value. Used by the default implementation ofunapplyAll(Set). Otherwise unused. Implementations that overrideunapplyAll(Set)may throwUnsupportedOperationExceptionfrom this method.- Parameters:
value- the value to apply the reverse lookup.- Returns:
- the list of keys that maps to the provided value. In SQL-compatible null handling mode, null keys are omitted.
-
unapplyAll
Reverse lookup from a given set of values.- Parameters:
values- set of values to reverse lookup.- Returns:
- iterator of keys that map to to the provided set of values. May contain duplicate keys. Returns null if this lookup instance does not support reverse lookups. In SQL-compatible null handling mode, null keys are omitted.
-
supportsAsMap
public abstract boolean supportsAsMap()Returns whether this lookup extractor'sasMap()will return a valid map. -
asMap
Returns a Map view of this lookup extractor. The map may change along with the underlying lookup data.- Throws:
UnsupportedOperationException- ifsupportsAsMap()returns false.
-
getCacheKey
public abstract byte[] getCacheKey()Create a cache key for use in results caching- Returns:
- A byte array that can be used to uniquely identify if results of a prior lookup can use the cached values
-
isOneToOne
public boolean isOneToOne() -
estimateHeapFootprint
public long estimateHeapFootprint()Estimated heap footprint of this object. Not guaranteed to be accurate. For example, some implementations return zero even though they do use on-heap structures. However, the most common classes,MapLookupExtractorandImmutableLookupMap, do have reasonable implementations. This API is provided for best-effort memory management and monitoring.
-