wuchong commented on a change in pull request #15267:
URL: https://github.com/apache/flink/pull/15267#discussion_r602306568
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/module/ModuleManager.java
##########
@@ -173,16 +174,21 @@ public void useModules(String... names) {
* @return an optional of {@link FunctionDefinition}
*/
public Optional<FunctionDefinition> getFunctionDefinition(String name) {
- Optional<String> module =
- usedModules.stream()
- .filter(
- n ->
-
loadedModules.get(n).listFunctions().stream()
- .anyMatch(e ->
e.equalsIgnoreCase(name)))
- .findFirst();
- if (module.isPresent()) {
- LOG.debug("Got FunctionDefinition '{}' from '{}' module.", name,
module.get());
- return loadedModules.get(module.get()).getFunctionDefinition(name);
+ AtomicReference<String> moduleName = new AtomicReference<>();
+ usedModules.stream()
+ .anyMatch(
+ n -> {
+ if (loadedModules.get(n).listFunctions().stream()
+ .anyMatch(name::equalsIgnoreCase)) {
+ moduleName.set(n);
+ return true;
+ }
+ return false;
+ });
+
+ if (moduleName.get() != null) {
+ LOG.debug("Got FunctionDefinition '{}' from '{}' module.", name,
moduleName.get());
+ return
loadedModules.get(moduleName.get()).getFunctionDefinition(name);
Review comment:
We don't need use `AtomicReference` here, you can refactor this logic
into while loop and return once the current module contains the requried
function name.
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/module/CoreModule.java
##########
@@ -29,19 +32,28 @@
/** Module of default core metadata in Flink. */
public class CoreModule implements Module {
public static final CoreModule INSTANCE = new CoreModule();
+ private List<BuiltInFunctionDefinition> builtInFunctionDefinitions;
Review comment:
can be `final`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]