Last active
June 12, 2019 03:59
-
-
Save wuchong/78fa3fa40323543aac8297fbecae09d8 to your computer and use it in GitHub Desktop.
LookupFunctionProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.flink.annotation.Experimental; | |
/** | |
* A {@link TableSource} which supports for lookup accessing via key column(s). | |
* For example, MySQL TableSource can implement this interface to support lookup accessing. | |
* When temporal join this MySQL table, the runtime behavior could be in a lookup fashion. | |
* | |
* @param <T> type of the result | |
*/ | |
@Experimental | |
public interface LookupableTableSource<T> extends TableSource<T> { | |
/** | |
* Gets the {@link LookupFunctionProvider} which is a factory to create a lookup function | |
* instance. | |
* @see LookupFunctionProvider | |
*/ | |
LookupFunctionProvider getLookupFunctionProvider(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.flink.table.functions.AsyncTableFunction; | |
import org.apache.flink.table.functions.TableFunction; | |
/** | |
* A base factory interface to create a lookup function. A lookup function is used to query table | |
* via key column(s). See {@link LookupableTableSource} for more information. | |
* | |
* <p>Currently, a lookup factory can either be {@link TableFunctionProvider} or | |
* {@link AsyncTableFunction}. | |
*/ | |
public interface LookupFunctionProvider { | |
/** | |
* A concrete factory interface of {@link LookupFunctionProvider}. | |
* The {@link TableFunctionProvider} is used to create a {@link TableFunction} instance to | |
* lookup table contents via key columns. | |
* | |
* @param <T> type of the result | |
*/ | |
interface TableFunctionProvider<T> extends LookupFunctionProvider { | |
/** | |
* Creates a {@link TableFunction} instance which supports lookup one key at a time. | |
* @param lookupKeys the chosen field names as lookup keys, it is in the defined order | |
* of schema. | |
*/ | |
TableFunction<T> createLookupFunction(String[] lookupKeys); | |
} | |
/** | |
* A concrete factory interface of {@link LookupFunctionProvider}. | |
* The {@link AsyncTableFunctionProvider} is used to create an {@link AsyncTableFunction} | |
* instance to async lookup table contents via key columns. | |
* | |
* @param <T> type of the result | |
*/ | |
interface AsyncTableFunctionProvider<T> extends LookupFunctionProvider { | |
/** | |
* Creates a {@link AsyncTableFunction} instance which supports async lookup one key | |
* at a time. | |
* @param lookupKeys the chosen field names as lookup keys, it is in the defined order | |
* of schema. | |
*/ | |
AsyncTableFunction<T> createLookupFunction(String[] lookupKeys); | |
} | |
/** | |
* Utility method to create a {@link TableFunctionProvider} from a {@link TableFunction} | |
* instance. | |
*/ | |
static <T> TableFunctionProvider<T> of(TableFunction<T> lookupFunction) { | |
return lookupKeys -> lookupFunction; | |
} | |
/** | |
* Utility method to create a {@link AsyncTableFunctionProvider} from a | |
* {@link AsyncTableFunction} instance. | |
*/ | |
static <T> AsyncTableFunctionProvider<T> of(AsyncTableFunction<T> lookupFunction) { | |
return lookupKeys -> lookupFunction; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment