[Swift-commit] r2374 - in trunk: libexec resources src/org/griphyn/vdl/karajan/lib
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Mon Dec 15 17:55:15 CST 2008
Author: benc
Date: 2008-12-15 17:55:12 -0600 (Mon, 15 Dec 2008)
New Revision: 2374
Added:
trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
Modified:
trunk/libexec/vdl-lib.xml
trunk/resources/Karajan.stg
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
Log:
separate out arrayiterator construction from getting a field value
Modified: trunk/libexec/vdl-lib.xml
===================================================================
--- trunk/libexec/vdl-lib.xml 2008-12-14 21:22:30 UTC (rev 2373)
+++ trunk/libexec/vdl-lib.xml 2008-12-15 23:55:12 UTC (rev 2374)
@@ -45,6 +45,7 @@
<export name="setFieldValue"><elementDef classname="org.griphyn.vdl.karajan.lib.SetFieldValue"/></export>
<export name="getFieldValue"><elementDef classname="org.griphyn.vdl.karajan.lib.GetFieldValue"/></export>
<export name="waitFieldValue"><elementDef classname="org.griphyn.vdl.karajan.lib.WaitFieldValue"/></export>
+ <export name="getArrayIterator"><elementDef classname="org.griphyn.vdl.karajan.lib.GetArrayIterator"/></export>
<export name="isFileBound"><elementDef classname="org.griphyn.vdl.karajan.lib.IsFileBound"/></export>
<export name="isRestartable"><elementDef classname="org.griphyn.vdl.karajan.lib.IsRestartable"/></export>
<export name="fringePaths"><elementDef classname="org.griphyn.vdl.karajan.lib.FringePaths"/></export>
Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg 2008-12-14 21:22:30 UTC (rev 2373)
+++ trunk/resources/Karajan.stg 2008-12-15 23:55:12 UTC (rev 2374)
@@ -201,7 +201,7 @@
foreach(var,in,indexVar,declarations,statements) ::= <<
<parallelFor name="\$">
- <getfieldvalue>$in$</getfieldvalue>
+ <getarrayiterator>$in$</getarrayiterator>
<set names="\$\$, $var$">
<each items="{\$}"/>
</set>
Added: trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java 2008-12-15 23:55:12 UTC (rev 2374)
@@ -0,0 +1,57 @@
+package org.griphyn.vdl.karajan.lib;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.globus.cog.karajan.arguments.Arg;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.HandleOpenException;
+import org.griphyn.vdl.mapping.InvalidPathException;
+import org.griphyn.vdl.mapping.Path;
+
+public class GetArrayIterator extends VDLFunction {
+ public static final Logger logger = Logger.getLogger(GetArrayIterator.class);
+
+ static {
+ setArguments(GetArrayIterator.class, new Arg[] { PA_VAR, OA_PATH });
+ }
+
+ /**
+ * Takes a supplied variable and path, and returns an array iterator.
+ */
+ public Object function(VariableStack stack) throws ExecutionException {
+ Object var1 = PA_VAR.getValue(stack);
+ if (!(var1 instanceof DSHandle)) {
+ return var1;
+ }
+ DSHandle var = (DSHandle) var1;
+ try {
+ Path path = parsePath(OA_PATH.getValue(stack), stack);
+ if (path.hasWildcards()) {
+ throw new RuntimeException("Wildcards not supported");
+ }
+ else {
+ var = var.getField(path);
+ if (var.getType().isArray()) {
+ Map value = var.getArrayValue();
+ if (var.isClosed()) {
+ return new PairIterator(value);
+ }
+ else {
+ return addFutureListListener(stack, var, value);
+ }
+ } else {
+ throw new RuntimeException("Cannot get array iterator for non-array");
+ }
+ }
+ }
+ catch (InvalidPathException e) {
+ throw new ExecutionException(e);
+ }
+ }
+
+}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2008-12-14 21:22:30 UTC (rev 2373)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2008-12-15 23:55:12 UTC (rev 2374)
@@ -10,7 +10,6 @@
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.karajan.PairIterator;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.InvalidPathException;
@@ -49,14 +48,7 @@
else {
var = var.getField(path);
if (var.getType().isArray()) {
- // this bit from GetArrayFieldValue
- Map value = var.getArrayValue();
- if (var.isClosed()) {
- return new PairIterator(value);
- }
- else {
- return addFutureListListener(stack, var, value);
- }
+ throw new RuntimeException("Getting value for array "+var+" which is not permitted.");
}
synchronized (var) {
if (!var.isClosed()) {
More information about the Swift-commit
mailing list