@Internal
public class CachingLookupFunction
extends org.apache.flink.table.functions.LookupFunction
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.
| Modifier and Type | Field and Description |
|---|---|
static String |
LOOKUP_CACHE_METRIC_GROUP_NAME |
| Constructor and Description |
|---|
CachingLookupFunction(org.apache.flink.table.connector.source.lookup.cache.LookupCache cache,
org.apache.flink.table.functions.LookupFunction delegate)
Create a
CachingLookupFunction. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
org.apache.flink.table.connector.source.lookup.cache.LookupCache |
getCache() |
Collection<org.apache.flink.table.data.RowData> |
lookup(org.apache.flink.table.data.RowData keyRow) |
void |
open(org.apache.flink.table.functions.FunctionContext context)
Open the
CachingLookupFunction. |
collect, finish, getKind, getParameterTypes, getResultType, getTypeInference, setCollectorfunctionIdentifier, toStringpublic static final String LOOKUP_CACHE_METRIC_GROUP_NAME
public CachingLookupFunction(org.apache.flink.table.connector.source.lookup.cache.LookupCache cache,
@Nullable
org.apache.flink.table.functions.LookupFunction delegate)
CachingLookupFunction.
Please note that the cache may not be the final instance serving in this function. The
actual cache instance will be retrieved from the LookupCacheManager during open(org.apache.flink.table.functions.FunctionContext).
public void open(org.apache.flink.table.functions.FunctionContext context)
throws Exception
CachingLookupFunction.
In order to reduce the memory usage of the cache, LookupCacheManager is used to
provide a shared cache instance across subtasks of this function. Here we use UserDefinedFunction.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.
open in class org.apache.flink.table.functions.UserDefinedFunctionExceptionUserDefinedFunction.functionIdentifier()public Collection<org.apache.flink.table.data.RowData> lookup(org.apache.flink.table.data.RowData keyRow) throws IOException
lookup in class org.apache.flink.table.functions.LookupFunctionIOExceptionpublic void close()
throws Exception
close in class org.apache.flink.table.functions.UserDefinedFunctionException@VisibleForTesting public org.apache.flink.table.connector.source.lookup.cache.LookupCache getCache()
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.