This is an automated email from the ASF dual-hosted git repository.

mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f2a18a885 [MINOR] Extended JMLC scoring API for obtaining list objects
8f2a18a885 is described below

commit 8f2a18a8859bb62249f31fb0457e35b12cdfb2a2
Author: Matthias Boehm <mboe...@gmail.com>
AuthorDate: Mon Jul 1 12:53:58 2024 +0200

    [MINOR] Extended JMLC scoring API for obtaining list objects
---
 .../org/apache/sysds/api/jmlc/ResultVariables.java | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/main/java/org/apache/sysds/api/jmlc/ResultVariables.java 
b/src/main/java/org/apache/sysds/api/jmlc/ResultVariables.java
index 393c1bcfac..d33619d8eb 100644
--- a/src/main/java/org/apache/sysds/api/jmlc/ResultVariables.java
+++ b/src/main/java/org/apache/sysds/api/jmlc/ResultVariables.java
@@ -20,6 +20,7 @@
 package org.apache.sysds.api.jmlc;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.sysds.api.DMLException;
@@ -27,6 +28,7 @@ import 
org.apache.sysds.runtime.controlprogram.caching.FrameObject;
 import org.apache.sysds.runtime.controlprogram.caching.MatrixObject;
 import org.apache.sysds.runtime.frame.data.FrameBlock;
 import org.apache.sysds.runtime.instructions.cp.Data;
+import org.apache.sysds.runtime.instructions.cp.ListObject;
 import org.apache.sysds.runtime.instructions.cp.ScalarObject;
 import org.apache.sysds.runtime.matrix.data.MatrixBlock;
 import org.apache.sysds.runtime.util.DataConverter;
@@ -189,6 +191,33 @@ public class ResultVariables
                return (ScalarObject) dat;
        }
        
+       /**
+        * Obtain the list represented by the given output variable.
+        * 
+        * @param varname
+        *            output variable name
+        * @return ListObject
+        */
+       public List<Data> getList(String varname) {
+               return getListObject(varname).getData();
+       }
+       
+       /**
+        * Obtain the ListObject represented by the given output variable.
+        * 
+        * @param varname
+        *            output variable name
+        * @return ListObject
+        */
+       public ListObject getListObject(String varname) {
+               Data dat = _out.get(varname);
+               if( dat == null )
+                       throw new DMLException("Non-existent output variable: " 
+ varname);
+               if (!(dat instanceof ListObject))
+                       throw new DMLException("Expected list result '" + 
varname + "' not a list.");
+               return (ListObject) dat;
+       }
+       
        /**
         * Add the output variable name and generated output data to the 
ResultVariable
         * object. Called during the execution of {@link PreparedScript}'s

Reply via email to