You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/06/01 09:56:59 UTC

[GitHub] [pulsar] cbornet commented on a diff in pull request #15693: [improve][function] Get function class name from the NAR when using built-in functions

cbornet commented on code in PR #15693:
URL: https://github.com/apache/pulsar/pull/15693#discussion_r886618763


##########
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functions/FunctionUtils.java:
##########
@@ -98,24 +95,29 @@ public static Functions searchForFunctions(String functionsDirectory, boolean al
         try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, "*.nar")) {
             for (Path archive : stream) {
                 try {
-                    FunctionDefinition cntDef = FunctionUtils.getFunctionDefinition(archive.toString());
+
+                    NarClassLoader ncl = NarClassLoaderBuilder.builder()
+                            .narFile(new File(archive.toString()))
+                            .build();
+
+                    FunctionArchive.FunctionArchiveBuilder functionArchiveBuilder = FunctionArchive.builder();
+                    FunctionDefinition cntDef = FunctionUtils.getFunctionDefinition(ncl);
                     log.info("Found function {} from {}", cntDef, archive);
-                    log.error(cntDef.getName());
-                    log.error(cntDef.getFunctionClass());
+
+                    functionArchiveBuilder.archivePath(archive);
+
+                    functionArchiveBuilder.classLoader(ncl);
+                    functionArchiveBuilder.functionDefinition(cntDef);
+
                     if (alwaysPopulatePath || !StringUtils.isEmpty(cntDef.getFunctionClass())) {
-                        functions.functions.put(cntDef.getName(), archive);
+                        functions.put(cntDef.getName(), functionArchiveBuilder.build());

Review Comment:
   The logic didn't change here (the condition is untouched). And there are already tests covering this. Or am I missing something ?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org