Package org.apache.druid.query.lookup
Class LookupExtractor
- java.lang.Object
-
- org.apache.druid.query.lookup.LookupExtractor
-
- Direct Known Subclasses:
MapLookupExtractor
public abstract class LookupExtractor extends Object
-
-
Constructor Summary
Constructors Constructor Description LookupExtractor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
apply(String key)
Apply a particular lookup methodology to the input stringMap<String,String>
applyAll(Iterable<String> keys)
abstract boolean
canGetKeySet()
Returns true if this lookup extractor'skeySet()
method will return a valid set.abstract boolean
canIterate()
Returns true if this lookup extractor'siterable()
method will return a valid iterator.long
estimateHeapFootprint()
Estimated heap footprint of this object.abstract byte[]
getCacheKey()
Create a cache key for use in results cachingboolean
isOneToOne()
abstract Iterable<Map.Entry<String,String>>
iterable()
Returns an Iterable that iterates over the keys and values in this lookup extractor.abstract Set<String>
keySet()
Returns a Set of all keys in this lookup extractor.abstract List<String>
unapply(String value)
Provide the reverse mapping from a given value to a list of keysMap<String,List<String>>
unapplyAll(Iterable<String> values)
-
-
-
Method Detail
-
apply
@Nullable public abstract String apply(@Nullable String key)
Apply a particular lookup methodology to the input string- 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.
-
applyAll
public Map<String,String> applyAll(Iterable<String> keys)
- Parameters:
keys
- set of keys to apply lookup for each element- Returns:
- Returns
Map
whose keys are the contents ofkeys
and whose values are computed on demand using lookup functionunapply(String)
or empty map ifvalues
is `null` User can override this method if there is a better way to perform bulk lookup
-
unapply
public abstract List<String> unapply(@Nullable String value)
Provide the reverse mapping from a given value to a list of keys- 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.
-
unapplyAll
public Map<String,List<String>> unapplyAll(Iterable<String> values)
- Parameters:
values
- Iterable of values for which will perform reverse lookup- Returns:
- Returns
Map
whose keys are the contents ofvalues
and whose values are computed on demand using the reverse lookup functionunapply(String)
or empty map ifvalues
is `null` User can override this method if there is a better way to perform bulk reverse lookup
-
canIterate
public abstract boolean canIterate()
Returns true if this lookup extractor'siterable()
method will return a valid iterator.
-
canGetKeySet
public abstract boolean canGetKeySet()
Returns true if this lookup extractor'skeySet()
method will return a valid set.
-
iterable
public abstract Iterable<Map.Entry<String,String>> iterable()
Returns an Iterable that iterates over the keys and values in this lookup extractor.- Throws:
UnsupportedOperationException
- ifcanIterate()
returns false.
-
keySet
public abstract Set<String> keySet()
Returns a Set of all keys in this lookup extractor. The returned Set will not change.- Throws:
UnsupportedOperationException
- ifcanGetKeySet()
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 class,MapLookupExtractor
, does have a reasonable implementation. This API is provided for best-effort memory management and monitoring.
-
-