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 String
apply(String key)
Apply a particular lookup methodology to the input stringboolean
canGetKeySet()
Returns true if this lookup extractor'sLookupExtractor.keySet()
method will return a valid set.boolean
canIterate()
Returns true if this lookup extractor'sLookupExtractor.iterable()
method will return a valid iterator.boolean
equals(Object o)
long
estimateHeapFootprint()
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()
int
hashCode()
boolean
isOneToOne()
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:LookupExtractor
Apply a particular lookup methodology to the input string- Specified by:
apply
in 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:LookupExtractor
Provide the reverse mapping from a given value to a list of keys- Specified by:
unapply
in 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:
isOneToOne
in classLookupExtractor
-
getCacheKey
public byte[] getCacheKey()
Description copied from class:LookupExtractor
Create a cache key for use in results caching- Specified by:
getCacheKey
in 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:LookupExtractor
Returns true if this lookup extractor'sLookupExtractor.iterable()
method will return a valid iterator.- Specified by:
canIterate
in classLookupExtractor
-
canGetKeySet
public boolean canGetKeySet()
Description copied from class:LookupExtractor
Returns true if this lookup extractor'sLookupExtractor.keySet()
method will return a valid set.- Specified by:
canGetKeySet
in classLookupExtractor
-
iterable
public Iterable<Map.Entry<String,String>> iterable()
Description copied from class:LookupExtractor
Returns an Iterable that iterates over the keys and values in this lookup extractor.- Specified by:
iterable
in classLookupExtractor
-
keySet
public Set<String> keySet()
Description copied from class:LookupExtractor
Returns a Set of all keys in this lookup extractor. The returned Set will not change.- Specified by:
keySet
in classLookupExtractor
-
estimateHeapFootprint
public long estimateHeapFootprint()
Description copied from class:LookupExtractor
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 class,MapLookupExtractor
, does have a reasonable implementation. This API is provided for best-effort memory management and monitoring.- Overrides:
estimateHeapFootprint
in classLookupExtractor
-
-