@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.
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
LOOKUP_CACHE_METRIC_GROUP_NAME |
| 构造器和说明 |
|---|
CachingLookupFunction(org.apache.flink.table.connector.source.lookup.cache.LookupCache cache,
org.apache.flink.table.functions.LookupFunction delegate)
Create a
CachingLookupFunction. |
| 限定符和类型 | 方法和说明 |
|---|---|
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, setCollectorpublic 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 在类中 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 在类中 org.apache.flink.table.functions.LookupFunctionIOExceptionpublic void close()
throws Exception
close 在类中 org.apache.flink.table.functions.UserDefinedFunctionException@VisibleForTesting public org.apache.flink.table.connector.source.lookup.cache.LookupCache getCache()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.