Repository: systemml
Updated Branches:
  refs/heads/master 2c9418c3e -> 7b1f86999


[MINOR] Extended UDF framework (access to execution context)

This patch makes a minor extension to the UDF function framework to pass
the execution context, which allows access to all registered dml-bodied
or external functions. The default implementation simply forwards to the
existing execute call which means no existing UDF requires changes.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/7b1f8699
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/7b1f8699
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/7b1f8699

Branch: refs/heads/master
Commit: 7b1f869991e70cea99317162453e3215f567c10b
Parents: 2c9418c
Author: Matthias Boehm <mboe...@gmail.com>
Authored: Mon Feb 19 20:33:24 2018 -0800
Committer: Matthias Boehm <mboe...@gmail.com>
Committed: Mon Feb 19 20:33:24 2018 -0800

----------------------------------------------------------------------
 .../sysml/udf/ExternalFunctionInvocationInstruction.java |  2 +-
 src/main/java/org/apache/sysml/udf/PackageFunction.java  | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/7b1f8699/src/main/java/org/apache/sysml/udf/ExternalFunctionInvocationInstruction.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/udf/ExternalFunctionInvocationInstruction.java 
b/src/main/java/org/apache/sysml/udf/ExternalFunctionInvocationInstruction.java
index 196ca37..bfa76ba 100644
--- 
a/src/main/java/org/apache/sysml/udf/ExternalFunctionInvocationInstruction.java
+++ 
b/src/main/java/org/apache/sysml/udf/ExternalFunctionInvocationInstruction.java
@@ -74,7 +74,7 @@ public class ExternalFunctionInvocationInstruction extends 
Instruction
                fun.setFunctionInputs(getInputObjects(inputs, 
ec.getVariables()));
                
                //executes function
-               fun.execute();
+               fun.execute(ec);
                
                // get and verify the outputs
                verifyAndAttachOutputs(ec, fun, outputs);

http://git-wip-us.apache.org/repos/asf/systemml/blob/7b1f8699/src/main/java/org/apache/sysml/udf/PackageFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/udf/PackageFunction.java 
b/src/main/java/org/apache/sysml/udf/PackageFunction.java
index 7d61639..6cdab21 100644
--- a/src/main/java/org/apache/sysml/udf/PackageFunction.java
+++ b/src/main/java/org/apache/sysml/udf/PackageFunction.java
@@ -22,6 +22,7 @@ package org.apache.sysml.udf;
 import java.io.Serializable;
 import java.util.ArrayList;
 
+import org.apache.sysml.runtime.controlprogram.context.ExecutionContext;
 import org.apache.sysml.runtime.controlprogram.parfor.util.IDSequence;
 
 /**
@@ -159,4 +160,14 @@ public abstract class PackageFunction implements 
Serializable
         */
        public abstract void execute();
        
+       /**
+        * Method that will be executed to perform this function. The default
+        * implementation simply forwards this call to execute.
+        * 
+        * @param execution context with access to the program
+        *    e.g., for access to other dml-bodied or external functions.
+        */
+       public void execute(ExecutionContext ec) {
+               execute(); //default impl
+       }
 }

Reply via email to