Class CachingLookupFunction
- All Implemented Interfaces:
Serializable,org.apache.flink.table.functions.FunctionDefinition
This function will check the cache on lookup request and return entries directly on cache hit, otherwise the function will invoke the actual lookup function, and store the entry into the cache after lookup for later use.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCachingLookupFunction(org.apache.flink.table.connector.source.lookup.cache.LookupCache cache, org.apache.flink.table.functions.LookupFunction delegate) Create aCachingLookupFunction. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()org.apache.flink.table.connector.source.lookup.cache.LookupCachegetCache()Collection<org.apache.flink.table.data.RowData>lookup(org.apache.flink.table.data.RowData keyRow) voidopen(org.apache.flink.table.functions.FunctionContext context) Open theCachingLookupFunction.Methods inherited from class org.apache.flink.table.functions.LookupFunction
evalMethods inherited from class org.apache.flink.table.functions.TableFunction
collect, finish, getKind, getParameterTypes, getResultType, getTypeInference, setCollectorMethods inherited from class org.apache.flink.table.functions.UserDefinedFunction
functionIdentifier, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.flink.table.functions.FunctionDefinition
getRequirements, isDeterministic, supportsConstantFolding
-
Field Details
-
LOOKUP_CACHE_METRIC_GROUP_NAME
- See Also:
-
-
Constructor Details
-
CachingLookupFunction
public CachingLookupFunction(org.apache.flink.table.connector.source.lookup.cache.LookupCache cache, @Nullable org.apache.flink.table.functions.LookupFunction delegate) Create aCachingLookupFunction.Please note that the cache may not be the final instance serving in this function. The actual cache instance will be retrieved from the
LookupCacheManagerduringopen(org.apache.flink.table.functions.FunctionContext).
-
-
Method Details
-
open
Open theCachingLookupFunction.In order to reduce the memory usage of the cache,
LookupCacheManageris used to provide a shared cache instance across subtasks of this function. Here we useUserDefinedFunction.functionIdentifier()as the id of the cache, which is generated by MD5 of serialized bytes of this function. As different subtasks of the function will generate the same MD5, this could promise that they will be served with the same cache instance.- Overrides:
openin classorg.apache.flink.table.functions.UserDefinedFunction- Throws:
Exception- See Also:
-
UserDefinedFunction.functionIdentifier()
-
lookup
public Collection<org.apache.flink.table.data.RowData> lookup(org.apache.flink.table.data.RowData keyRow) throws IOException - Specified by:
lookupin classorg.apache.flink.table.functions.LookupFunction- Throws:
IOException
-
close
- Overrides:
closein classorg.apache.flink.table.functions.UserDefinedFunction- Throws:
Exception
-
getCache
@VisibleForTesting public org.apache.flink.table.connector.source.lookup.cache.LookupCache getCache()
-