Class MapLookupExtractor
- java.lang.Object
-
- org.apache.druid.query.lookup.LookupExtractor
-
- org.apache.druid.query.extraction.MapLookupExtractor
-
public class MapLookupExtractor extends LookupExtractor
Lookup extractor backed by any kind of map. When the map is immutable, useImmutableLookupMapinstead.
-
-
Constructor Summary
Constructors Constructor Description MapLookupExtractor(Map<String,String> map, boolean isOneToOne)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringapply(String key)Apply a particular lookup methodology to the input stringMap<String,String>asMap()Returns a Map view of this lookup extractor.booleanequals(Object o)longestimateHeapFootprint()Estimated heap footprint of this object.static <K,V>
longestimateHeapFootprint(Iterable<Map.Entry<K,V>> entries)Estimate the heap footprint of a Map.byte[]getCacheKey()Create a cache key for use in results cachingMap<String,String>getMap()inthashCode()booleanisOneToOne()booleansupportsAsMap()Returns whether this lookup extractor'sLookupExtractor.asMap()will return a valid map.List<String>unapply(String value)Reverse lookup from a given value.Iterator<String>unapplyAll(Set<String> values)Reverse lookup from a given set of values.-
Methods inherited from class org.apache.druid.query.lookup.LookupExtractor
applyAll
-
-
-
-
Method Detail
-
estimateHeapFootprint
public static <K,V> long estimateHeapFootprint(Iterable<Map.Entry<K,V>> entries)
Estimate the heap footprint of a Map. Important note: the implementation accepts any kind of map entries, but estimates zero footprint for keys and values of types other than String.
-
apply
@Nullable public String apply(@Nullable String key)
Description copied from class:LookupExtractorApply a particular lookup methodology to the input string- Specified by:
applyin classLookupExtractor- 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.
-
unapply
public List<String> unapply(@Nullable String value)
Description copied from class:LookupExtractorReverse lookup from a given value. Used by the default implementation ofLookupExtractor.unapplyAll(Set). Otherwise unused. Implementations that overrideLookupExtractor.unapplyAll(Set)may throwUnsupportedOperationExceptionfrom this method.- Specified by:
unapplyin classLookupExtractor- 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
@Nullable public Iterator<String> unapplyAll(Set<String> values)
Description copied from class:LookupExtractorReverse lookup from a given set of values.- Overrides:
unapplyAllin classLookupExtractor- 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.
-
isOneToOne
public boolean isOneToOne()
- Overrides:
isOneToOnein classLookupExtractor
-
getCacheKey
public byte[] getCacheKey()
Description copied from class:LookupExtractorCreate a cache key for use in results caching- Specified by:
getCacheKeyin classLookupExtractor- Returns:
- A byte array that can be used to uniquely identify if results of a prior lookup can use the cached values
-
supportsAsMap
public boolean supportsAsMap()
Description copied from class:LookupExtractorReturns whether this lookup extractor'sLookupExtractor.asMap()will return a valid map.- Specified by:
supportsAsMapin classLookupExtractor
-
asMap
public Map<String,String> asMap()
Description copied from class:LookupExtractorReturns a Map view of this lookup extractor. The map may change along with the underlying lookup data.- Specified by:
asMapin classLookupExtractor
-
estimateHeapFootprint
public long estimateHeapFootprint()
Description copied from class:LookupExtractorEstimated 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.- Overrides:
estimateHeapFootprintin classLookupExtractor
-
-