public class CachingAsyncLookupFunction extends AsyncLookupFunction
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 |
---|
CachingAsyncLookupFunction(LookupCache cache,
AsyncLookupFunction delegate) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Collection<RowData>> |
asyncLookup(RowData keyRow)
Asynchronously lookup rows matching the lookup keys.
|
void |
close()
Tear-down method for user-defined function.
|
LookupCache |
getCache() |
void |
open(FunctionContext context)
Setup method for user-defined function.
|
eval
getKind, getTypeInference
functionIdentifier, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRequirements, isDeterministic, supportsConstantFolding
public static final String LOOKUP_CACHE_METRIC_GROUP_NAME
public CachingAsyncLookupFunction(LookupCache cache, AsyncLookupFunction delegate)
public void open(FunctionContext context) throws Exception
UserDefinedFunction
open
in class UserDefinedFunction
Exception
public CompletableFuture<Collection<RowData>> asyncLookup(RowData keyRow)
AsyncLookupFunction
Please note that the returning collection of RowData shouldn't be reused across invocations.
asyncLookup
in class AsyncLookupFunction
keyRow
- - A RowData
that wraps lookup keys.public void close() throws Exception
UserDefinedFunction
close
in class UserDefinedFunction
Exception
@VisibleForTesting public LookupCache getCache()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.