Class MapLookupExtractor
- java.lang.Object
-
- org.apache.druid.query.lookup.LookupExtractor
-
- org.apache.druid.query.extraction.MapLookupExtractor
-
public class MapLookupExtractor extends LookupExtractor
-
-
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 stringbooleancanGetKeySet()Returns true if this lookup extractor'sLookupExtractor.keySet()method will return a valid set.booleancanIterate()Returns true if this lookup extractor'sLookupExtractor.iterable()method will return a valid iterator.booleanequals(Object o)longestimateHeapFootprint()Estimated heap footprint of this object.static <K,V>
longestimateHeapFootprint(Map<K,V> map)Estimate the heap footprint of a Map.byte[]getCacheKey()Create a cache key for use in results cachingMap<String,String>getMap()inthashCode()booleanisOneToOne()Iterable<Map.Entry<String,String>>iterable()Returns an Iterable that iterates over the keys and values in this lookup extractor.Set<String>keySet()Returns a Set of all keys in this lookup extractor.List<String>unapply(String value)Provide the reverse mapping from a given value to a list of keys-
Methods inherited from class org.apache.druid.query.lookup.LookupExtractor
applyAll, unapplyAll
-
-
-
-
Method Detail
-
estimateHeapFootprint
public static <K,V> long estimateHeapFootprint(@Nullable Map<K,V> map)
Estimate the heap footprint of a Map. Important note: the implementation accepts any kind of Map, 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 lookup, or null when key is `null` or 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:LookupExtractorProvide the reverse mapping from a given value to a list of keys- Specified by:
unapplyin classLookupExtractor- Parameters:
value- the value to apply the reverse lookup- Returns:
- the list of keys that maps to value or empty list. Note that for the case of a none existing value in the lookup we have to cases either return an empty list OR list with null element. returning an empty list implies that user want to ignore such a lookup value. In the other hand returning a list with the null element implies user want to map the none existing value to the key null. Null value maps to empty list.
-
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
-
canIterate
public boolean canIterate()
Description copied from class:LookupExtractorReturns true if this lookup extractor'sLookupExtractor.iterable()method will return a valid iterator.- Specified by:
canIteratein classLookupExtractor
-
canGetKeySet
public boolean canGetKeySet()
Description copied from class:LookupExtractorReturns true if this lookup extractor'sLookupExtractor.keySet()method will return a valid set.- Specified by:
canGetKeySetin classLookupExtractor
-
iterable
public Iterable<Map.Entry<String,String>> iterable()
Description copied from class:LookupExtractorReturns an Iterable that iterates over the keys and values in this lookup extractor.- Specified by:
iterablein classLookupExtractor
-
keySet
public Set<String> keySet()
Description copied from class:LookupExtractorReturns a Set of all keys in this lookup extractor. The returned Set will not change.- Specified by:
keySetin 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 class,MapLookupExtractor, does have a reasonable implementation. This API is provided for best-effort memory management and monitoring.- Overrides:
estimateHeapFootprintin classLookupExtractor
-
-