olabusayoT commented on a change in pull request #273: WIP: Add User Defined 
Functions Capability
URL: https://github.com/apache/incubator-daffodil/pull/273#discussion_r334017318
 
 

 ##########
 File path: 
daffodil-test/src/test/java/org/goodudfs/example/StringFunctions/Compare.java
 ##########
 @@ -0,0 +1,19 @@
+package org.goodudfs.example.StringFunctions;
+
+import java.io.Serializable;
+
+import org.apache.daffodil.udf.FunctionClassInfo;
+
+@FunctionClassInfo(
+               name = "compare",
+               namespace = "http://goodudfs.StringFunctions";
+)
+public class Compare implements Serializable {
 
 Review comment:
   since we won't know the number or types of the params, using an Object array 
as the param seemed the only viable way to do this. This was initially 
considered and decided against, since the UDF code would need to accept an 
object array as the params and cast the types. Under the hood invoke does this 
anyways, so it seemed weird to do this again, and it would make allowing 
overloading more difficult for future devs.
   
   Instead we decided to take it one level higher and introduced the providers. 
So this way if 1 provider is aware of 100 UDFs, we are only concerned about the 
1 UDFP, rather than 100 UDFs. And the UDFPs take the same 2 args so they're 
easier to abstract out. So practically what this would look like is 1 qualified 
name in the META-INF/services file rather than 100.
   
   The flip side of this is there is no way to insist they annotate the UDFs, 
or have an evaluate function, but we provide the documentation and the code 
checks, and leave it up to the users to follow the rules.

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


With regards,
Apache Git Services

Reply via email to