[Swift-commit] r7843 - in trunk/src/org/griphyn/vdl/karajan/lib: . swiftscript
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Thu May 8 23:56:39 CDT 2014
Author: hategan
Date: 2014-05-08 23:56:39 -0500 (Thu, 08 May 2014)
New Revision: 7843
Added:
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldConst.java
trunk/src/org/griphyn/vdl/karajan/lib/StringCache.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java
Modified:
trunk/src/org/griphyn/vdl/karajan/lib/AppendArray.java
trunk/src/org/griphyn/vdl/karajan/lib/CleanDataset.java
trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java
trunk/src/org/griphyn/vdl/karajan/lib/Execute.java
trunk/src/org/griphyn/vdl/karajan/lib/ExpandArguments.java
trunk/src/org/griphyn/vdl/karajan/lib/FileName.java
trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/GetStagingInfo.java
trunk/src/org/griphyn/vdl/karajan/lib/IsFileBound.java
trunk/src/org/griphyn/vdl/karajan/lib/Mark.java
trunk/src/org/griphyn/vdl/karajan/lib/New.java
trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
trunk/src/org/griphyn/vdl/karajan/lib/ProcessStageouts.java
trunk/src/org/griphyn/vdl/karajan/lib/Range.java
trunk/src/org/griphyn/vdl/karajan/lib/RemoteFileNames.java
trunk/src/org/griphyn/vdl/karajan/lib/SetDatasetValues.java
trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java
trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java
trunk/src/org/griphyn/vdl/karajan/lib/SwiftBinaryOp.java
trunk/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java
trunk/src/org/griphyn/vdl/karajan/lib/SwiftUnaryOp.java
trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java
trunk/src/org/griphyn/vdl/karajan/lib/Tracer.java
trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java
trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/While.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
Log:
interned fields; data type reorganization; propagation of lazy failures in internal functions
Modified: trunk/src/org/griphyn/vdl/karajan/lib/AppendArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/AppendArray.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/AppendArray.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -21,8 +21,8 @@
import k.rt.Stack;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class AppendArray extends SetFieldValue {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/CleanDataset.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/CleanDataset.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/CleanDataset.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -24,8 +24,8 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.file.FileGarbageCollector;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class CleanDataset extends SwiftFunction {
private ArgRef<AbstractDataNode> var;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -26,10 +26,10 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class CloseDataset extends SwiftFunction {
public static final Logger logger = Logger.getLogger(CloseDataset.class);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -27,10 +27,10 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.futures.FutureFault;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
import org.griphyn.vdl.mapping.RootHandle;
import org.griphyn.vdl.mapping.file.ConcurrentMapper;
+import org.griphyn.vdl.mapping.nodes.RootClosedArrayDataNode;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
public class CreateArray extends SetFieldValue {
@@ -53,43 +53,18 @@
Type type = checkTypes((List<?>) value);
- RootHandle handle = new RootArrayDataNode("arrayexpr", type.arrayType());
- if (type.hasNonPrimitiveComponents()) {
+ RootHandle handle = new RootClosedArrayDataNode(Field.Factory.getImmutableField("arrayexpr", type.arrayType()),
+ (List<?>) value, null);
+ if (type.hasMappedComponents()) {
handle.init(new ConcurrentMapper());
}
else {
handle.init(null);
}
-
- if (logger.isInfoEnabled()) {
- logger.info("CREATEARRAY START array=" + handle.getIdentifier());
- }
-
- int index = 0;
- for (Object o : (List<?>) value) {
- // TODO check type consistency of elements with
- // the type of the array
- DSHandle n = (DSHandle) o;
- // we know this DSHandle cast will work because we checked
- // it in the previous scan of the array contents
- Path p = Path.EMPTY_PATH.addLast(index, true);
-
- DSHandle dst = handle.getField(p);
-
- deepCopy(dst, n, stack);
-
- if (logger.isInfoEnabled()) {
- logger.info("CREATEARRAY MEMBER array=" + handle.getIdentifier()
- + " index=" + index + " member=" + n.getIdentifier());
- }
- index++;
- }
- handle.closeShallow();
-
if (logger.isInfoEnabled()) {
- logger.info("CREATEARRAY COMPLETED array=" + handle.getIdentifier());
- }
+ logger.info("CREATEARRAY array=" + handle.getIdentifier());
+ }
return handle;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Execute.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Execute.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Execute.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -20,6 +20,12 @@
*/
package org.griphyn.vdl.karajan.lib;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
import k.rt.Abort;
import k.rt.Channel;
import k.rt.ConditionalYield;
@@ -32,6 +38,7 @@
import org.globus.cog.abstraction.interfaces.Status;
import org.globus.cog.abstraction.interfaces.Task;
import org.globus.cog.karajan.analyzer.ArgRef;
+import org.globus.cog.karajan.analyzer.CompilationException;
import org.globus.cog.karajan.analyzer.Param;
import org.globus.cog.karajan.analyzer.Scope;
import org.globus.cog.karajan.analyzer.Signature;
@@ -59,14 +66,35 @@
@Override
protected Signature getSignature() {
Signature sig = super.getSignature();
- sig.getParams().add(0, new Param("progress", Param.Type.POSITIONAL));
- sig.getParams().add(optional("replicationGroup", null));
- sig.getParams().add(optional("replicationChannel", null));
- sig.getParams().add(optional("jobid", null));
+ List<Param> params = sig.getParams();
+ params.add(0, new Param("progress", Param.Type.POSITIONAL));
+ params.add(optional("replicationGroup", null));
+ params.add(optional("replicationChannel", null));
+ params.add(optional("jobid", null));
+ removeParams(params, "stdout", "stderr", "stdoutLocation", "stderrLocation",
+ "stdin", "provider", "securityContext", "nativespec",
+ "delegation", "batch");
return sig;
}
- @Override
+ private void removeParams(List<Param> params, String... names) {
+ Set<String> snames = new HashSet<String>(Arrays.asList(names));
+ Iterator<Param> i = params.iterator();
+ while (i.hasNext()) {
+ Param p = i.next();
+ if (snames.contains(p.name)) {
+ try {
+ setArg(null, p, new ArgRef.Static<Object>(p.value));
+ }
+ catch (CompilationException e) {
+ throw new RuntimeException("Failed to remove parameter " + p.name, e);
+ }
+ i.remove();
+ }
+ }
+ }
+
+ @Override
protected void addLocals(Scope scope) {
super.addLocals(scope);
context = scope.getVarRef("#context");
Modified: trunk/src/org/griphyn/vdl/karajan/lib/ExpandArguments.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/ExpandArguments.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/ExpandArguments.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -29,9 +29,10 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.PathElementComparator;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.ArrayHandle;
public class ExpandArguments extends SwiftFunction {
public static final Logger logger = Logger.getLogger(ExpandArguments.class);
@@ -58,15 +59,17 @@
private Object expandArrays(Channel<Object> items) {
ArrayList<DSHandle> l = new ArrayList<DSHandle>();
for (Object item : items) {
- if (item instanceof ArrayDataNode) {
- ArrayDataNode array = (ArrayDataNode) item;
+ AbstractDataNode h = (AbstractDataNode) item;
+ h.waitFor(this);
+ if (item instanceof ArrayHandle) {
+ ArrayHandle array = (ArrayHandle) item;
Map<Comparable<?>, DSHandle> m = array.getArrayValue();
SortedMap<Comparable<?>, DSHandle> sorted = new TreeMap<Comparable<?>, DSHandle>(new PathElementComparator());
sorted.putAll(m);
l.addAll(m.values());
}
else {
- l.add((DSHandle) item);
+ l.add(h);
}
// TODO this does not correctly handle structs or
// externals - at the moment, probably neither of
@@ -85,7 +88,7 @@
throw new ExecutionException(this, "Cannot handle argument implemented by " + item.getClass());
}
- if (item instanceof ArrayDataNode) {
+ if (item instanceof ArrayHandle) {
arraySeen = true;
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/FileName.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/FileName.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/FileName.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -38,6 +38,7 @@
@Override
public Object function(Stack stack) {
- return argList(filename(var.getValue(stack)), true);
+ DSHandle var = this.var.getValue(stack);
+ return var.map(var.getPathFromRoot());
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -24,10 +24,10 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.PairSet;
-import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.ArrayHandle;
public class GetArrayIterator extends SwiftFunction {
public static final Logger logger = Logger.getLogger(GetArrayIterator.class);
@@ -67,7 +67,7 @@
if (logger.isDebugEnabled()) {
logger.debug("Using future iterator for " + var);
}
- return ((ArrayDataNode) var).entryList();
+ return ((ArrayHandle) var).entryList();
}
}
}
Added: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldConst.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldConst.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldConst.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 University of Chicago
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/*
+ * Created on Dec 26, 2006
+ */
+package org.griphyn.vdl.karajan.lib;
+
+import k.rt.ExecutionException;
+import k.rt.Stack;
+
+import org.globus.cog.karajan.analyzer.ArgRef;
+import org.globus.cog.karajan.analyzer.Param;
+import org.globus.cog.karajan.compiled.nodes.functions.AbstractSingleValuedFunction;
+import org.griphyn.vdl.type.Field;
+import org.griphyn.vdl.type.NoSuchTypeException;
+import org.griphyn.vdl.type.Types;
+
+public class GetFieldConst extends AbstractSingleValuedFunction {
+ private ArgRef<String> name;
+ private ArgRef<String> type;
+
+
+ @Override
+ protected Param[] getParams() {
+ return params("name", "type");
+ }
+
+
+ @Override
+ public Object function(Stack stack) {
+ String name = this.name.getValue(stack);
+ String type = this.type.getValue(stack);
+ try {
+ return Field.Factory.getImmutableField(name, Types.getType(type));
+ }
+ catch (NoSuchTypeException e) {
+ throw new ExecutionException("No such type: " + name, e);
+ }
+ }
+}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -22,12 +22,12 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.OOBYield;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class GetFieldSubscript extends SwiftFunction {
private ArgRef<DSHandle> var;
@@ -48,7 +48,7 @@
indexh.waitFor();
Object index = indexh.getValue();
if ("*".equals(index)) {
- return var.getFields(Path.CHILDREN);
+ return var.getAllFields();
}
else {
return var.getField(Path.EMPTY_PATH.addFirst((Comparable<?>) index, true));
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -27,8 +27,8 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.futures.FutureFault;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class GetFieldValue extends SwiftFunction {
public static final Logger logger = Logger.getLogger(GetFieldValue.class);
@@ -52,7 +52,8 @@
try {
Path path = parsePath(this.path.getValue(stack));
if (path.hasWildcards()) {
- return var.getFields(path).toArray();
+ // TODO we should clarify whether we allow generic selectors
+ return var.getField(path.butLast()).getAllFields().toArray();
}
else {
var = (AbstractDataNode) var.getField(path);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetStagingInfo.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetStagingInfo.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetStagingInfo.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -85,6 +85,9 @@
private void addPaths(Info info, Collection<DSHandle> vars, boolean out) throws HandleOpenException {
for (DSHandle var : vars) {
+ if (!var.getType().hasMappedComponents()) {
+ continue;
+ }
Mapper m = getMapper(var);
if (out && !m.isStatic() && var.getType().hasArrayComponents()) {
Collection<AbsFile> patterns = m.getPattern(var.getPathFromRoot(), var.getType());
Modified: trunk/src/org/griphyn/vdl/karajan/lib/IsFileBound.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/IsFileBound.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/IsFileBound.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -24,8 +24,8 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class IsFileBound extends SwiftFunction {
private ArgRef<DSHandle> var;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Mark.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Mark.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Mark.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,10 +28,10 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.DataDependentException;
import org.griphyn.vdl.mapping.MappingDependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class Mark extends SwiftFunction {
private ArgRef<Channel<AbstractDataNode>> restarts;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/New.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/New.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/New.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -20,7 +20,7 @@
*/
package org.griphyn.vdl.karajan.lib;
-import java.util.Iterator;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -37,17 +37,23 @@
import org.globus.cog.karajan.analyzer.VarRef;
import org.globus.cog.karajan.compiled.nodes.Node;
import org.globus.cog.karajan.parser.WrapperNode;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.DuplicateMappingChecker;
-import org.griphyn.vdl.mapping.ExternalDataNode;
import org.griphyn.vdl.mapping.InvalidMapperException;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.MapperFactory;
import org.griphyn.vdl.mapping.NullMapper;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
-import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.mapping.RootHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.ExternalDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.mapping.nodes.RootClosedArrayDataNode;
+import org.griphyn.vdl.mapping.nodes.RootClosedPrimitiveDataNode;
+import org.griphyn.vdl.mapping.nodes.RootFutureArrayDataNode;
+import org.griphyn.vdl.mapping.nodes.RootFutureMappedSingleDataNode;
+import org.griphyn.vdl.mapping.nodes.RootFuturePrimitiveDataNode;
+import org.griphyn.vdl.mapping.nodes.RootFutureStructDataNode;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.NoSuchTypeException;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -57,10 +63,9 @@
private static final Mapper NULL_MAPPER = new NullMapper();
- private ArgRef<String> type;
+ private ArgRef<Field> field;
private ArgRef<Map<String, Object>> mapping;
private ArgRef<Object> value;
- private ArgRef<String> dbgname;
private ArgRef<Number> waitCount;
private ArgRef<Boolean> input;
private ArgRef<Integer> _defline;
@@ -70,8 +75,8 @@
@Override
protected Signature getSignature() {
- return new Signature(params("type", optional("mapping", null), optional("value", null),
- optional("dbgname", null), optional("waitCount", null), optional("input", Boolean.FALSE), optional("_defline", null)));
+ return new Signature(params("field", optional("mapping", null), optional("value", null),
+ optional("waitCount", null), optional("input", Boolean.FALSE), optional("_defline", null)));
}
private Tracer tracer;
@@ -96,22 +101,22 @@
@Override
public Object function(Stack stack) {
- String typename = this.type.getValue(stack);
+ Field field = this.field.getValue(stack);
Object value = this.value.getValue(stack);
Map<String, Object> mapping = this.mapping.getValue(stack);
- String dbgname = this.dbgname.getValue(stack);
Number waitCount = this.waitCount.getValue(stack);
boolean input = this.input.getValue(stack);
Integer line = this._defline.getValue(stack);
- if (typename == null && value == null) {
- throw new ExecutionException("You must specify either a type or a value");
+ if (field == null && value == null) {
+ throw new ExecutionException("You must specify either a field or a value");
}
Mapper mapper;
+ Type type = field.getType();
+ String dbgname = (String) field.getId();
- Type type = getType(typename);
- if (type.hasNonPrimitiveComponents()) {
+ if (type.hasMappedComponents()) {
String desc = (String) mapping.remove("swift#descriptor");
try {
mapper = MapperFactory.getMapper(desc);
@@ -143,32 +148,36 @@
try {
DSHandle handle;
- if (typename.equals("external")) {
+ if (Types.EXTERNAL.equals(type)) {
if (tracer.isEnabled()) {
tracer.trace(thread, dbgname + " = external");
}
- handle = initHandle(new ExternalDataNode(dbgname), mapper, thread, line, input);
+ handle = initHandle(new ExternalDataNode(field), mapper, thread, line, input);
}
else if (type.isArray()) {
// dealing with array variable
if (value != null) {
- if (value instanceof RootArrayDataNode) {
+ if (value instanceof RootHandle) {
+ handle = (RootHandle) value;
if (tracer.isEnabled()) {
- tracer.trace(thread, dbgname + " = " + Tracer.getVarName((RootDataNode) value));
+ tracer.trace(thread, dbgname + " = " + Tracer.getVarName(handle));
}
- handle = (RootArrayDataNode) value;
+ handle.closeShallow();
}
else {
- handle = initHandle(createArrayFromList(stack, thread, dbgname, type),
+ handle = initHandle(createArrayFromList(stack, thread, field, value),
mapper, thread, line, input);
}
- handle.closeShallow();
}
+ else if (input && !type.hasMappedComponents()) {
+ handle = initHandle(createArrayFromList(stack, thread, field, Collections.emptyList()),
+ mapper, thread, line, input);
+ }
else {
if (tracer.isEnabled()) {
tracer.trace(thread, dbgname);
}
- handle = initHandle(createEmptyArray(stack, thread, dbgname, type),
+ handle = initHandle(createEmptyArray(stack, thread, field),
mapper, thread, line, input);
}
}
@@ -180,19 +189,25 @@
handle = (DSHandle) value;
}
else {
- handle = initHandle(new RootDataNode(dbgname, type, getDMChecker(stack)),
- mapper, thread, line, input);
- if (value != null) {
- if (tracer.isEnabled()) {
- tracer.trace(thread, dbgname + " = " + value);
- }
- handle.setValue(internalValue(type, value));
- }
- else {
- if (tracer.isEnabled()) {
+ if (value == null) {
+ handle = initHandle(NodeFactory.newOpenRoot(field, getDMChecker(stack)),
+ mapper, thread, line, input);
+ if (tracer.isEnabled()) {
tracer.trace(thread, dbgname + " " + mapper);
}
- }
+ }
+ else {
+ if (type.isPrimitive()) {
+ handle = initHandle(new RootClosedPrimitiveDataNode(field, internalValue(type, value)),
+ mapper, thread, line, input);
+ }
+ else {
+ throw new ExecutionException("Cannot create non-primitive data node with value '" + value + "'");
+ }
+ if (tracer.isEnabled()) {
+ tracer.trace(thread, dbgname + " = " + value);
+ }
+ }
}
if (AbstractDataNode.provenance && logger.isDebugEnabled()) {
@@ -211,41 +226,27 @@
if (line != null) {
handle.setLine(line);
}
- handle.setInput(input);
+ if (mapper != NULL_MAPPER) {
+ handle.setInput(input);
+ }
handle.init(mapper);
return handle;
}
- private RootHandle createArrayFromList(Stack stack, LWThread thread, String dbgname, Type type)
+ private RootHandle createArrayFromList(Stack stack, LWThread thread, Field field, Object value)
throws NoSuchFieldException {
- RootHandle handle = new RootArrayDataNode(dbgname, type, getDMChecker(stack));
if (!(value instanceof List)) {
throw new ExecutionException("An array variable can only be initialized with a list of values");
}
if (tracer.isEnabled()) {
- tracer.trace(thread, dbgname + " = " + formatList((List<?>) value));
+ tracer.trace(thread, field.getId() + " = " + formatList((List<?>) value));
}
- int index = 0;
- Iterator<?> i = ((List<?>) value).iterator();
- while (i.hasNext()) {
- // TODO check type consistency of elements with
- // the type of the array
- Object n = i.next();
- if (n instanceof DSHandle) {
- handle.getField(index).set((DSHandle) n);
- }
- else {
- throw new RuntimeException(
- "An array variable can only be initialized by a list of DSHandle values");
- }
- index++;
- }
- return handle;
+ return new RootClosedArrayDataNode(field, (List<?>) value, getDMChecker(stack));
}
- private RootHandle createEmptyArray(Stack stack, LWThread thread, String dbgname, Type type)
+ private RootHandle createEmptyArray(Stack stack, LWThread thread, Field field)
throws NoSuchFieldException {
- return new RootArrayDataNode(dbgname, type, getDMChecker(stack));
+ return new RootFutureArrayDataNode(field, getDMChecker(stack));
}
private Type getType(String typename) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Operators.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Operators.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -21,9 +21,11 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.compiled.nodes.Node;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.VDL2Config;
@@ -101,17 +103,22 @@
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
Type t = type(v1, v2);
DSHandle r;
- if (t == Types.STRING) {
- r = new RootDataNode(Types.STRING, (String.valueOf(v1.getValue()) + String.valueOf(v2.getValue())));
+ try {
+ if (t == Types.STRING) {
+ r = NodeFactory.newRoot(Field.GENERIC_STRING, StringCache.get((String.valueOf(v1.getValue()) + String.valueOf(v2.getValue()))));
+ }
+ else if (t == Types.INT) {
+ r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v1) + getInt(this, v2));
+ }
+ else {
+ r = NodeFactory.newRoot(Field.GENERIC_FLOAT, getFloat(this, v1) + getFloat(this, v2));
+ }
+ logBinaryProvenance("sum", v1, v2, r);
+ return r;
}
- else if (t == Types.INT) {
- r = new RootDataNode(Types.INT, getInt(this, v1) + getInt(this, v2));
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.Factory.getImmutableField("?", t), e);
}
- else {
- r = new RootDataNode(Types.FLOAT, getFloat(this, v1) + getFloat(this, v2));
- }
- logBinaryProvenance("sum", v1, v2, r);
- return r;
}
}
@@ -120,14 +127,19 @@
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
Type t = type(v1, v2);
DSHandle r;
- if (t == Types.INT) {
- r = new RootDataNode(Types.INT, getInt(this, v1) - getInt(this, v2));
+ try {
+ if (t == Types.INT) {
+ r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v1) - getInt(this, v2));
+ }
+ else {
+ r = NodeFactory.newRoot(Field.GENERIC_FLOAT, getFloat(this, v1) - getFloat(this, v2));
+ }
+ logBinaryProvenance("difference", v1, v2, r);
+ return r;
}
- else {
- r = new RootDataNode(Types.FLOAT, getFloat(this, v1) - getFloat(this, v2));
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.Factory.getImmutableField("?", t), e);
}
- logBinaryProvenance("difference", v1, v2, r);
- return r;
}
}
@@ -136,21 +148,26 @@
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
Type t = type(v1, v2);
DSHandle r;
- if (t == Types.INT) {
- r = new RootDataNode(Types.INT, getInt(this, v1) * getInt(this, v2));
+ try {
+ if (t == Types.INT) {
+ r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v1) * getInt(this, v2));
+ }
+ else {
+ r = NodeFactory.newRoot(Field.GENERIC_FLOAT, getFloat(this, v1) * getFloat(this, v2));
+ }
+ logBinaryProvenance("product", v1, v2, r);
+ return r;
}
- else {
- r = new RootDataNode(Types.FLOAT, getFloat(this, v1) * getFloat(this, v2));
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.Factory.getImmutableField("?", t), e);
}
- logBinaryProvenance("product", v1, v2, r);
- return r;
}
}
public static class FQuotient extends SwiftBinaryOp {
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.FLOAT, getFloat(this, v1) / getFloat(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_FLOAT, getFloat(this, v1) / getFloat(this, v2));
logBinaryProvenance("fquotient", v1, v2, r);
return r;
}
@@ -162,7 +179,7 @@
public static class IQuotient extends SwiftBinaryOp {
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.INT, getInt(this, v1) / getInt(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v1) / getInt(this, v2));
logBinaryProvenance("iquotient", v1, v2, r);
return r;
}
@@ -173,102 +190,157 @@
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
Type t = type(v1, v2);
DSHandle r;
- if (t == Types.INT) {
- r = new RootDataNode(Types.INT, getInt(this, v1) % getInt(this, v2));
+ try {
+ if (t == Types.INT) {
+ r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v1) % getInt(this, v2));
+ }
+ else {
+ r = NodeFactory.newRoot(Field.GENERIC_FLOAT, getFloat(this, v1) % getFloat(this, v2));
+ }
+ logBinaryProvenance("remainder", v1, v2, r);
+ return r;
}
- else {
- r = new RootDataNode(Types.FLOAT, getFloat(this, v1) % getFloat(this, v2));
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.Factory.getImmutableField("?", t), e);
}
- logBinaryProvenance("remainder", v1, v2, r);
- return r;
}
}
public static class LE extends SwiftBinaryOp {
@Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
+ @Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getFloat(this, v1) <= getFloat(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getFloat(this, v1) <= getFloat(this, v2));
logBinaryProvenance("le", v1, v2, r);
return r;
}
}
public static class GE extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getFloat(this, v1) >= getFloat(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getFloat(this, v1) >= getFloat(this, v2));
logBinaryProvenance("ge", v1, v2, r);
return r;
}
}
public static class LT extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getFloat(this, v1) < getFloat(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getFloat(this, v1) < getFloat(this, v2));
logBinaryProvenance("lt", v1, v2, r);
return r;
}
}
public static class GT extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getFloat(this, v1) > getFloat(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getFloat(this, v1) > getFloat(this, v2));
logBinaryProvenance("gt", v1, v2, r);
return r;
}
}
public static class EQ extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, v1.getValue().equals(v2.getValue()));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, v1.getValue().equals(v2.getValue()));
logBinaryProvenance("eq", v1, v2, r);
return r;
}
}
public static class NE extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, !v1.getValue().equals(v2.getValue()));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, !v1.getValue().equals(v2.getValue()));
logBinaryProvenance("ne", v1, v2, r);
return r;
}
}
public static class And extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getBool(this, v1) && getBool(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getBool(this, v1) && getBool(this, v2));
logBinaryProvenance("and", v1, v2, r);
return r;
}
}
public static class Or extends SwiftBinaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v1, AbstractDataNode v2) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, getBool(this, v1) || getBool(this, v2));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, getBool(this, v1) || getBool(this, v2));
logBinaryProvenance("or", v1, v2, r);
return r;
}
}
public static class Not extends SwiftUnaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v) {
- DSHandle r = new RootDataNode(Types.BOOLEAN, !getBool(this, v));
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, !getBool(this, v));
logUnaryProvenance("not", v, r);
return r;
}
}
public static class Inc extends SwiftUnaryOp {
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_INT;
+ }
+
@Override
protected DSHandle value(AbstractDataNode v) {
- DSHandle r = new RootDataNode(Types.INT, getInt(this, v) + 1);
+ DSHandle r = NodeFactory.newRoot(Field.GENERIC_INT, getInt(this, v) + 1);
return r;
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/ProcessStageouts.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/ProcessStageouts.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/ProcessStageouts.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -31,12 +31,12 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.FileSystemLister;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.InitMapper;
public class ProcessStageouts extends SwiftFunction {
public static final Logger logger = Logger.getLogger(ProcessStageouts.class);
@@ -78,7 +78,7 @@
Mapper m = var.getMapper();
if (!m.isStatic() && var.getType().hasArrayComponents()) {
Collection<Path> found = m.existing(new FileSystemLister.FileList(collectList));
- RootDataNode.addExisting(found, m, var.getRoot(), var);
+ InitMapper.addExisting(found, m, var.getRoot(), var);
logOnly(var, log);
}
else {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Range.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Range.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Range.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -33,12 +33,13 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.mapping.nodes.RootFutureArrayDataNode;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -49,7 +50,7 @@
@Override
protected Signature getSignature() {
- return new Signature(params("from", "to", optional("step", new RootDataNode(Types.FLOAT, 1))));
+ return new Signature(params("from", "to", optional("step", NodeFactory.newRoot(Field.GENERIC_FLOAT, 1))));
}
@Override
@@ -70,8 +71,9 @@
// only deal with int and float
try {
final AbstractDataNode handle;
+ final Field valueField = Field.Factory.getImmutableField("rangeItem", type);
- handle = new RootArrayDataNode(type.arrayType()) {
+ handle = new RootFutureArrayDataNode(Field.Factory.getImmutableField("range", type.arrayType()), null) {
final DSHandle h = this;
{
closeShallow();
@@ -87,7 +89,7 @@
}
else {
int index = (Integer) path.getFirst();
- DSHandle value = new RootDataNode(type, new Double(start + incr * index));
+ DSHandle value = NodeFactory.newRoot(valueField, new Double(start + incr * index));
return Collections.singletonList(value);
}
}
@@ -113,10 +115,10 @@
{
if (type == Types.INT) {
- value = new RootDataNode(Types.INT, (int) crt);
+ value = NodeFactory.newRoot(Field.GENERIC_INT, (int) crt);
}
else {
- value = new RootDataNode(Types.FLOAT, Double.valueOf(crt));
+ value = NodeFactory.newRoot(Field.GENERIC_FLOAT, Double.valueOf(crt));
}
key = index;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/RemoteFileNames.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/RemoteFileNames.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/RemoteFileNames.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -43,7 +43,6 @@
Collection<AbsFile> files = this.files.getValue(stack);
List<String> ret = new ArrayList<String>();
for (AbsFile f : files) {
- String path = null;
if ("file".equals(f.getProtocol())) {
ret.add(PathUtils.remotePathName(f.getPath()));
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SetDatasetValues.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SetDatasetValues.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SetDatasetValues.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,8 +28,8 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class SetDatasetValues extends SwiftFunction {
private ArgRef<List<DSHandle>> stageouts;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -43,10 +43,11 @@
import org.globus.cog.karajan.parser.WrapperNode;
import org.griphyn.vdl.karajan.PairSet;
import org.griphyn.vdl.karajan.WaitingThreadsMonitor;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Type;
public class SetFieldValue extends SwiftFunction {
@@ -111,8 +112,6 @@
tracer = Tracer.getTracer(this);
return fn;
}
-
-
@Override
protected void initializeArgs(Stack stack) {
@@ -186,9 +185,15 @@
return sb.toString();
}
- protected void deepCopy(DSHandle dest, DSHandle source, Stack stack) {
+ protected void deepCopy(DSHandle dest, DSHandle source, Stack stack) {
// don't create a state if only a non-composite is copied
- ((AbstractDataNode) source).waitFor(this);
+ try {
+ ((AbstractDataNode) source).waitFor(this);
+ }
+ catch (DataDependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return;
+ }
if (source.getType().isPrimitive()) {
dest.setValue(source.getValue());
}
@@ -208,7 +213,13 @@
/** make dest look like source - if its a simple value, copy that
and if its an array then recursively copy */
public void deepCopy(DSHandle dest, DSHandle source, State state, int level) {
- ((AbstractDataNode) source).waitFor(this);
+ try {
+ ((AbstractDataNode) source).waitFor(this);
+ }
+ catch (DataDependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return;
+ }
if (source.getType().isPrimitive()) {
dest.setValue(source.getValue());
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -27,6 +27,8 @@
import org.globus.cog.karajan.util.BoundContact;
import org.globus.cog.karajan.util.ContactSet;
import org.globus.swift.catalog.site.SiteCatalogParser;
+import org.globus.swift.catalog.site.SwiftContact;
+import org.griphyn.vdl.util.FQN;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -120,7 +122,7 @@
return null;
}
String name = poolName(n, v);
- BoundContact bc = new BoundContact(name);
+ SwiftContact bc = new SwiftContact(name);
String sysinfo = attr(n, "sysinfo", null);
if (sysinfo != null) {
@@ -252,14 +254,14 @@
return s;
}
- private void env(BoundContact bc, Node n) {
+ private void env(SwiftContact bc, Node n) {
String key = attr(n, "key");
String value = text(n);
- bc.addProperty("env:" + key, value);
+ bc.addProfile(new FQN("env", key), value);
}
- private void profile(BoundContact bc, Node n) {
+ private void profile(SwiftContact bc, Node n) {
String ns = attr(n, "namespace");
String key = attr(n, "key");
String value = text(n);
@@ -271,7 +273,7 @@
bc.addProperty(key, value);
}
else {
- bc.addProperty(ns + ":" + key, value);
+ bc.addProfile(new FQN(ns, key), value);
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,11 +28,11 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.PairSet;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.RootFutureArrayDataNode;
import org.griphyn.vdl.type.NoSuchTypeException;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -77,7 +77,7 @@
String destinationTypeName = this.type.getValue(stack);
Type destinationType = Types.getType(destinationTypeName);
- RootArrayDataNode destinationArray = new RootArrayDataNode(destinationType);
+ RootFutureArrayDataNode destinationArray = new RootFutureArrayDataNode(sourceArray.getField(), null);
Path cutPath = Path.EMPTY_PATH.addLast(this.path.getValue(stack), false);
@@ -89,8 +89,8 @@
DSHandle sourceElement = (DSHandle) pair.get(1);
DSHandle n = sourceElement.getField(cutPath);
-
- destinationArray.getField((Comparable<?>) index).set(n);
+
+ destinationArray.addField((Comparable<?>) index, n);
}
// all of the inputs should be closed, so
@@ -122,9 +122,6 @@
catch(NoSuchTypeException nste) {
throw new ExecutionException("No such type",nste);
}
- catch (NoSuchFieldException e) {
- throw new ExecutionException(this, e);
- }
catch (InvalidPathException e) {
throw new ExecutionException(this, e);
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -37,10 +37,10 @@
import org.globus.cog.karajan.compiled.nodes.Node;
import org.globus.cog.karajan.futures.FutureFault;
import org.globus.cog.karajan.parser.WrapperNode;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.MappingDependentException;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class Stagein extends SwiftFunction {
public static final Logger logger = Logger.getLogger(Stagein.class);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -27,9 +27,9 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.analyzer.VarRef;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.MappingDependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class Stageout extends SwiftFunction {
public static final Logger logger = Logger.getLogger(Stageout.class);
Added: trunk/src/org/griphyn/vdl/karajan/lib/StringCache.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/StringCache.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/StringCache.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -0,0 +1,28 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Apr 5, 2014
+ */
+package org.griphyn.vdl.karajan.lib;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+public class StringCache {
+ private static Map<String, String> cache = new WeakHashMap<String, String>();
+
+ public synchronized static String get(String s) {
+ String sc = cache.get(s);
+ if (sc == null) {
+ cache.put(s, s);
+ return s;
+ }
+ else {
+ return sc;
+ }
+ }
+}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SwiftBinaryOp.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SwiftBinaryOp.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SwiftBinaryOp.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -12,17 +12,29 @@
import k.rt.Stack;
import org.globus.cog.karajan.compiled.nodes.functions.BinaryOp;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public abstract class SwiftBinaryOp extends BinaryOp<AbstractDataNode, DSHandle> {
@Override
public DSHandle function(Stack stack) {
- AbstractDataNode v1 = this.v1.getValue(stack);
- v1.waitFor(this);
- AbstractDataNode v2 = this.v2.getValue(stack);
- v2.waitFor(this);
- return value(v1, v2);
+ try {
+ AbstractDataNode v1 = this.v1.getValue(stack);
+ v1.waitFor(this);
+ AbstractDataNode v2 = this.v2.getValue(stack);
+ v2.waitFor(this);
+ return value(v1, v2);
+ }
+ catch (DependentException e) {
+ return NodeFactory.newRoot(getReturnType(), e);
+ }
}
+
+ protected Field getReturnType() {
+ return Field.GENERIC_ANY;
+ }
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -50,7 +50,6 @@
import org.griphyn.vdl.karajan.TCCache;
import org.griphyn.vdl.karajan.functions.ConfigProperty;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.GeneralizedFileFormat;
@@ -61,6 +60,9 @@
import org.griphyn.vdl.mapping.PathComparator;
import org.griphyn.vdl.mapping.PhysicalFormat;
import org.griphyn.vdl.mapping.RootHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.FQN;
@@ -103,8 +105,8 @@
@Override
public void runBody(LWThread thr) {
+ Stack stack = thr.getStack();
try {
- Stack stack = thr.getStack();
ret(stack, function(stack));
}
catch (AssertFailedException e) {
@@ -112,11 +114,13 @@
throw e;
}
catch (DependentException e) {
- // This would not be the primal fault so in non-lazy errors mode it
- // should not matter
- throw new ExecutionException("Wrapping a dependent exception in VDLFunction.post() - errors in data dependencies",e);
+ ret(stack, NodeFactory.newRoot(getReturnType(), e));
}
}
+
+ protected Field getReturnType() {
+ return Field.GENERIC_ANY;
+ }
/*
* This will likely break if the engine changes in fundamental ways. It also
@@ -330,9 +334,14 @@
// Close the future
handle.closeShallow();
// Mark all leaves
- for (DSHandle child : handle.getFields(Path.CHILDREN)) {
- child.closeShallow();
- }
+ try {
+ for (DSHandle child : handle.getAllFields()) {
+ child.closeShallow();
+ }
+ }
+ catch (HandleOpenException e) {
+ throw new RuntimeException("Handle not closed after closeShallow()");
+ }
}
public static void waitForAll(Node who, Channel<AbstractDataNode> vargs) throws ExecutionException {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SwiftUnaryOp.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SwiftUnaryOp.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SwiftUnaryOp.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -12,15 +12,27 @@
import k.rt.Stack;
import org.globus.cog.karajan.compiled.nodes.functions.UnaryOp;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public abstract class SwiftUnaryOp extends UnaryOp<AbstractDataNode, DSHandle> {
@Override
public DSHandle function(Stack stack) {
- AbstractDataNode v1 = this.v1.getValue(stack);
- v1.waitFor(this);
- return value(v1);
+ try {
+ AbstractDataNode v1 = this.v1.getValue(stack);
+ v1.waitFor(this);
+ return value(v1);
+ }
+ catch (DependentException e) {
+ return NodeFactory.newRoot(getReturnType(), e);
+ }
}
+
+ protected Field getReturnType() {
+ return Field.GENERIC_ANY;
+ }
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -37,8 +37,8 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.analyzer.VarRef;
import org.globus.cog.karajan.compiled.nodes.functions.Map.Entry;
-import org.globus.cog.karajan.util.BoundContact;
import org.globus.swift.catalog.TCEntry;
+import org.globus.swift.catalog.site.SwiftContact;
import org.globus.swift.catalog.util.Profile;
import org.griphyn.vdl.karajan.TCCache;
import org.griphyn.vdl.util.FQN;
@@ -46,7 +46,7 @@
public class TCProfile extends SwiftFunction {
public static final Logger logger = Logger.getLogger(TCProfile.class);
- private ArgRef<BoundContact> host;
+ private ArgRef<SwiftContact> host;
/**
Allows for dynamic attributes from the SwiftScript
profile statements.
@@ -87,9 +87,9 @@
Map<String, Object> dynamicAttributes = readDynamicAttributes(stack);
- BoundContact bc = this.host.getValue(stack);
+ SwiftContact bc = this.host.getValue(stack);
- Map<String,Object> attrs = null;
+ Map<String, Object> attrs = null;
attrs = attributesFromHost(bc, attrs, stack);
TCEntry tce = null;
@@ -176,12 +176,11 @@
public static final String PROFILE_GLOBUS_PREFIX = (Profile.GLOBUS + "::").toLowerCase();
- private void addEnvironment(Stack stack, BoundContact bc) {
- Map<String,Object> props = bc.getProperties();
- if (props != null) {
- for (Map.Entry<String,Object> e : props.entrySet()) {
- String name = e.getKey();
- FQN fqn = new FQN(name);
+ private void addEnvironment(Stack stack, SwiftContact bc) {
+ Map<FQN, Object> profiles = bc.getProfiles();
+ if (profiles != null) {
+ for (Map.Entry<FQN, Object> e : profiles.entrySet()) {
+ FQN fqn = e.getKey();
String value = (String) e.getValue();
if (Profile.ENV.equalsIgnoreCase(fqn.getNamespace())) {
cr_environment.append(stack, new Entry(fqn.getName(), value));
@@ -235,11 +234,11 @@
Inserts namespace=globus attributes from BoundContact bc
into given attrs
*/
- private Map<String,Object> attributesFromHost(BoundContact bc, Map<String, Object> attrs, Stack stack) {
- Map<String,Object> props = bc.getProperties();
- if (props != null) {
- for (Map.Entry<String,Object> e : props.entrySet()) {
- FQN fqn = new FQN(e.getKey());
+ private Map<String,Object> attributesFromHost(SwiftContact bc, Map<String, Object> attrs, Stack stack) {
+ Map<FQN, Object> profiles = bc.getProfiles();
+ if (profiles != null) {
+ for (Map.Entry<FQN, Object> e : profiles.entrySet()) {
+ FQN fqn = e.getKey();
if (Profile.GLOBUS.equalsIgnoreCase(fqn.getNamespace())) {
Attr a = ATTR_TYPES.get(fqn.getName());
if (a == null) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Tracer.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Tracer.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Tracer.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -19,11 +19,11 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.analyzer.VariableNotFoundException;
import org.globus.cog.karajan.compiled.nodes.Node;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.RootHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.VDL2Config;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -30,8 +30,8 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class UnwrapClosedList extends SwiftFunction {
public static final Logger logger = Logger.getLogger(UnwrapClosedList.class);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -22,9 +22,9 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
public class WaitFieldValue extends SwiftFunction {
private ArgRef<AbstractDataNode> var;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/While.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/While.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/While.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,8 +28,8 @@
import org.globus.cog.karajan.compiled.nodes.InternalFunction;
import org.globus.cog.karajan.compiled.nodes.Node;
import org.globus.cog.karajan.parser.WrapperNode;
-import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class While extends InternalFunction {
@@ -85,7 +85,7 @@
switch(i) {
case 0:
drefs = RefCount.build(stack, srefs);
- var.setValue(stack, new RootDataNode(Types.INT, 0));
+ var.setValue(stack, NodeFactory.newRoot(Field.GENERIC_INT, 0));
c_next.create(stack);
RefCount.incRefs(drefs);
next = (SingleValueChannel<Object>) c_next.get(stack);
Added: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -0,0 +1,37 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Apr 17, 2014
+ */
+package org.griphyn.vdl.karajan.lib.swiftscript;
+
+import k.rt.Stack;
+import k.thr.LWThread;
+
+import org.globus.cog.karajan.compiled.nodes.functions.AbstractSingleValuedFunction;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
+
+public abstract class AbstractSingleValuedSwiftFunction extends AbstractSingleValuedFunction {
+
+
+ @Override
+ public void runBody(LWThread thr) {
+ Stack stack = thr.getStack();
+ try {
+ ret(stack, function(stack));
+ }
+ catch (DependentException e) {
+ ret(stack, NodeFactory.newRoot(getFieldType(), e));
+ }
+ }
+
+ protected Field getFieldType() {
+ return Field.GENERIC_ANY;
+ }
+}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -26,8 +26,9 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.AssertFailedException;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Types;
/**
@@ -58,18 +59,25 @@
hmessage = fargs.get(1);
}
- String message;
- if (hmessage != null) {
- hmessage.waitFor(this);
- message = (String) hmessage.getValue();
+ try {
+ String message;
+ if (hmessage != null) {
+ hmessage.waitFor(this);
+ message = (String) hmessage.getValue();
+ }
+ else {
+ message = "Assertion failed";
+ }
+ AbstractDataNode hvalue = fargs.get(0);
+ hvalue.waitFor(this);
+
+ checkAssert(hvalue, message);
}
- else {
- message = "Assertion failed";
+ catch (DependentException e) {
+ if (logger.isInfoEnabled()) {
+ logger.info(this + " cannot check assertion: data exception");
+ }
}
- AbstractDataNode hvalue = fargs.get(0);
- hvalue.waitFor(this);
-
- checkAssert(hvalue, message);
return null;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,10 +28,11 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class ExtractFloat extends SwiftFunction {
@@ -53,12 +54,15 @@
BufferedReader breader = new BufferedReader(freader);
String str = breader.readLine();
freader.close();
- DSHandle result = new RootDataNode(Types.FLOAT, Double.parseDouble(str));
+ DSHandle result = NodeFactory.newRoot(Field.GENERIC_FLOAT, Double.parseDouble(str));
int provid = SwiftFunction.nextProvenanceID();
SwiftFunction.logProvenanceResult(provid, result, "extractfloat");
SwiftFunction.logProvenanceParameter(provid, handle, "filename");
return result;
}
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.GENERIC_FLOAT, e);
+ }
catch (IOException ioe) {
throw new ExecutionException("Reading integer content of file", ioe);
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,10 +28,11 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class ExtractInt extends SwiftFunction {
@@ -53,12 +54,15 @@
BufferedReader breader = new BufferedReader(freader);
String str = breader.readLine();
freader.close();
- DSHandle result = new RootDataNode(Types.INT, Integer.parseInt(str));
+ DSHandle result = NodeFactory.newRoot(Field.GENERIC_INT, Integer.parseInt(str));
int provid = SwiftFunction.nextProvenanceID();
SwiftFunction.logProvenanceResult(provid, result, "extractint");
SwiftFunction.logProvenanceParameter(provid, handle, "filename");
return result;
}
+ catch (DependentException e) {
+ return NodeFactory.newRoot(Field.GENERIC_INT, e);
+ }
catch (IOException ioe) {
throw new ExecutionException("Reading integer content of file", ioe);
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -22,10 +22,10 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class FileName extends SwiftFunction {
private ArgRef<AbstractDataNode> var;
@@ -39,7 +39,7 @@
public Object function(Stack stack) {
AbstractDataNode var = this.var.getValue(stack);
String s = argList(filename(var), true);
- DSHandle result = new RootDataNode(Types.STRING, s);
+ DSHandle result = NodeFactory.newRoot(Field.GENERIC_STRING, s);
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
SwiftFunction.logProvenanceParameter(provid, var, "input");
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -20,18 +20,17 @@
*/
package org.griphyn.vdl.karajan.lib.swiftscript;
-import k.rt.ExecutionException;
+import java.util.Arrays;
+
import k.rt.Stack;
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.InvalidPathException;
-import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class FileNames extends SwiftFunction {
private ArgRef<AbstractDataNode> var;
@@ -45,16 +44,10 @@
public Object function(Stack stack) {
AbstractDataNode var = this.var.getValue(stack);
String[] f = filename(var);
- DSHandle returnArray = new RootArrayDataNode(Types.STRING.arrayType());
- try {
- for (int i = 0; i < f.length; i++) {
- Path p = parsePath("["+i+"]");
- DSHandle h = returnArray.getField(p);
- h.setValue(relativize(f[i]));
- }
- } catch (InvalidPathException e) {
- throw new ExecutionException("Unexpected invalid path exception",e);
+ for (int i = 0; i < f.length; i++) {
+ f[i] = relativize(f[i]);
}
+ DSHandle returnArray = NodeFactory.newRoot(Field.GENERIC_STRING_ARRAY, Arrays.asList(f));
returnArray.closeShallow();
if (PROVENANCE_ENABLED) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -33,10 +33,10 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.analyzer.VarRef;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
public class FnArg extends SwiftFunction {
@@ -48,6 +48,11 @@
protected Signature getSignature() {
return new Signature(params("..."));
}
+
+ @Override
+ protected Field getReturnType() {
+ return Field.GENERIC_STRING;
+ }
@Override
protected void addLocals(Scope scope) {
@@ -87,7 +92,7 @@
throw new ExecutionException("Missing command line argument: " + name);
}
else {
- DSHandle result = new RootDataNode(Types.STRING, value);
+ DSHandle result = NodeFactory.newRoot(Field.GENERIC_STRING, value);
if (PROVENANCE_ENABLED) {
int provid = nextProvenanceID();
logProvenanceResult(provid, result, "arg");
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -30,7 +30,8 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
/**
Formatted file output. <br>
@@ -55,26 +56,43 @@
@Override
public Object function(Stack stack) {
- AbstractDataNode hfilename = this.filename.getValue(stack);
- AbstractDataNode hspec = this.spec.getValue(stack);
- hfilename.waitFor(this);
- hspec.waitFor(this);
- Channel<AbstractDataNode> args = c_vargs.get(stack);
- waitForAll(this, args);
- String filename = (String) hfilename.getValue();
- String spec = (String) hspec.getValue();
-
- StringBuilder output = new StringBuilder();
try {
- Sprintf.format(spec, args, output);
+ AbstractDataNode hfilename = this.filename.getValue(stack);
+ AbstractDataNode hspec = this.spec.getValue(stack);
+ hfilename.waitFor(this);
+ String filename = (String) hfilename.getValue();
+ try {
+ hspec.waitFor(this);
+ Channel<AbstractDataNode> args = c_vargs.get(stack);
+ waitForAll(this, args);
+ String spec = (String) hspec.getValue();
+
+ StringBuilder output = new StringBuilder();
+ try {
+ Sprintf.format(spec, args, output);
+ }
+ catch (RuntimeException e) {
+ throw new ExecutionException(this, e.getMessage());
+ }
+ String msg = output.toString();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("file: " + filename + " msg: " + msg);
+ }
+ write(filename, msg);
+ }
+ catch (DependentException e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("file: " + filename + " msg: <exception>");
+ }
+ write(filename, "<exception>");
+ }
}
- catch (RuntimeException e) {
- throw new ExecutionException(this, e.getMessage());
+ catch (DependentException e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("<exception>");
+ }
}
- String msg = output.toString();
-
- logger.debug("file: " + filename + " msg: " + msg);
- write(filename, msg);
return null;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -28,8 +28,8 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -48,6 +48,7 @@
AbstractDataNode hlib = this.lib.getValue(stack);
AbstractDataNode hname = this.name.getValue(stack);
Channel<AbstractDataNode> args = this.c_vargs.get(stack);
+
hlib.waitFor(this);
hname.waitFor(this);
waitForAll(this, args);
@@ -56,7 +57,7 @@
Object[] p = convertInputs(method, args);
Type type = returnType(method);
Object value = invoke(method, p);
- return new RootDataNode(type, value);
+ return NodeFactory.newRoot(type, value);
}
/**
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -17,10 +17,10 @@
package org.griphyn.vdl.karajan.lib.swiftscript;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.BufferedReader;
-
+import java.util.Arrays;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -35,14 +35,15 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.compiled.nodes.InternalFunction;
-import org.globus.cog.karajan.compiled.nodes.functions.AbstractSingleValuedFunction;
import org.globus.cog.karajan.util.TypeUtil;
+import org.griphyn.vdl.karajan.lib.StringCache;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.RootArrayDataNode;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.VDL2Config;
@@ -76,27 +77,39 @@
@Override
protected void runBody(LWThread thr) {
Channel<AbstractDataNode> vargs = c_vargs.get(thr.getStack());
- SwiftFunction.waitForAll(this, vargs);
+ StringBuilder buf = new StringBuilder();
+ try {
+ Tracef.waitForAll(this, vargs);
+ buf.append("SwiftScript trace: ");
+ boolean first = true;
+ for (AbstractDataNode n : vargs) {
+ if (!first) {
+ buf.append(", ");
+ }
+ else {
+ first = false;
+ }
+ //buf.append(v == null ? args[i] : v);
+ prettyPrint(buf, n);
+ }
+ }
+ catch (DependentException e) {
+ buf.append("SwiftScript trace: <exception>");
+ }
- StringBuilder buf = new StringBuilder();
- buf.append("SwiftScript trace: ");
- boolean first = true;
- for (AbstractDataNode n : vargs) {
- if (!first) {
- buf.append(", ");
- }
- else {
- first = false;
- }
- //buf.append(v == null ? args[i] : v);
- prettyPrint(buf, n);
- }
traceLogger.warn(buf);
}
}
private static void prettyPrint(StringBuilder buf, DSHandle h) {
- Object o = h.getValue();
+ Object o;
+ try {
+ o = h.getValue();
+ }
+ catch (DependentException e) {
+ buf.append("<exception>");
+ return;
+ }
if (o == null) {
buf.append(h);
}
@@ -131,7 +144,7 @@
}
}
- public static class StrCat extends AbstractSingleValuedFunction {
+ public static class StrCat extends AbstractSingleValuedSwiftFunction {
private ChannelRef<AbstractDataNode> c_vargs;
@Override
@@ -140,6 +153,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
Channel<AbstractDataNode> vargs = c_vargs.get(stack);
Channel<Object> args = SwiftFunction.unwrapAll(this, vargs);
@@ -150,7 +168,7 @@
buf.append(TypeUtil.toString(o));
}
- DSHandle handle = new RootDataNode(Types.STRING, buf.toString());
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, buf.toString());
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -164,7 +182,7 @@
}
}
- public static class Exists extends AbstractSingleValuedFunction {
+ public static class Exists extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> file;
@Override
@@ -173,6 +191,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_BOOLEAN;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode dn = file.getValue(stack);
String filename;
@@ -187,7 +210,7 @@
if (logger.isDebugEnabled()) {
logger.debug("exists: " + file);
}
- DSHandle handle = new RootDataNode(Types.BOOLEAN, file.exists());
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_BOOLEAN, file.exists());
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -199,7 +222,7 @@
}
}
- public static class StrCut extends AbstractSingleValuedFunction {
+ public static class StrCut extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -209,6 +232,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -235,7 +263,7 @@
if (logger.isDebugEnabled()) {
logger.debug("strcut matched '" + group + "'");
}
- DSHandle handle = new RootDataNode(Types.STRING, group);
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, group);
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -247,7 +275,7 @@
}
}
- public static class StrStr extends AbstractSingleValuedFunction {
+ public static class StrStr extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -257,6 +285,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -267,7 +300,7 @@
logger.debug("strstr will search '" + input + "' for pattern '" + pattern + "'");
}
- DSHandle result = new RootDataNode(Types.INT, input.indexOf(pattern));
+ DSHandle result = NodeFactory.newRoot(Field.GENERIC_INT, input.indexOf(pattern));
if (PROVENANCE_ENABLED) {
@@ -280,62 +313,63 @@
}
}
- public static class ExecSystem extends AbstractSingleValuedFunction {
+ public static class ExecSystem extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
- //private ArgRef<AbstractDataNode> pattern;
-
+
@Override
protected Signature getSignature() {
return new Signature(params("input"));
- }
+ }
@Override
- public Object function(Stack stack) {
- AbstractDataNode hinput = this.input.getValue(stack);
- String input = SwiftFunction.unwrap(this, hinput);
-
- DSHandle handle = new RootArrayDataNode(Types.STRING.arrayType());
- StringBuffer out = new StringBuffer();
- Process proc;
- int i = 0;
-
- try {
- proc = Runtime.getRuntime().exec(new String[] {"bash", "-c", input});
- proc.waitFor();
- int exitcode = proc.exitValue();
- // If the shell returned a non-zero exit code, attempt to print stderr
- if ( exitcode != 0 ) {
- BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getErrorStream()) );
- String line = "";
- StringBuffer stderr = new StringBuffer();
+ public Object function(Stack stack) {
+ AbstractDataNode hinput = this.input.getValue(stack);
+ String input = SwiftFunction.unwrap(this, hinput);
+
+ DSHandle handle = NodeFactory.newOpenRoot(Field.GENERIC_STRING_ARRAY, null);
+
+ StringBuffer out = new StringBuffer();
+ Process proc;
+ int i = 0;
+
+ try {
+ proc = Runtime.getRuntime().exec(new String[] {"bash", "-c", input});
+ proc.waitFor();
+ int exitcode = proc.exitValue();
+ // If the shell returned a non-zero exit code, attempt to print stderr
+ if ( exitcode != 0 ) {
+ BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getErrorStream()) );
+ String line = "";
+ StringBuffer stderr = new StringBuffer();
+ while ( (line = reader.readLine()) != null ) {
+ stderr.append(line);
+ }
+ logger.warn("swift:system returned exitcode :" + exitcode);
+ logger.warn("swift:system stderr:\n " + stderr );
+ }
+ BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getInputStream()) );
+ String line = "";
while ( (line = reader.readLine()) != null ) {
- stderr.append(line);
+ DSHandle el;
+ el = handle.getField(i++);
+ el.setValue(line);
}
- logger.warn("swift:system returned exitcode :" + exitcode);
- logger.warn("swift:system stderr:\n " + stderr );
- }
- BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getInputStream()) );
- String line = "";
- while ( (line = reader.readLine()) != null ) {
- DSHandle el;
- el = handle.getField(i++);
- el.setValue(line);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- handle.closeDeep();
-
- if (PROVENANCE_ENABLED) {
- int provid = SwiftFunction.nextProvenanceID();
- SwiftFunction.logProvenanceResult(provid, handle, "system");
- SwiftFunction.logProvenanceParameter(provid, hinput, "input");
- }
- return handle;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ handle.closeDeep();
+
+ if (PROVENANCE_ENABLED) {
+ int provid = SwiftFunction.nextProvenanceID();
+ SwiftFunction.logProvenanceResult(provid, handle, "system");
+ SwiftFunction.logProvenanceParameter(provid, hinput, "input");
+ }
+ return handle;
}
}
- public static class StrSplit extends AbstractSingleValuedFunction {
+ public static class StrSplit extends AbstractSingleValuedSwiftFunction {
+
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -345,6 +379,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING_ARRAY;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -353,17 +392,7 @@
String[] split = input.split(pattern);
- DSHandle handle = new RootArrayDataNode(Types.STRING.arrayType());
- for (int i = 0; i < split.length; i++) {
- DSHandle el;
- try {
- el = handle.getField(i);
- el.setValue(split[i]);
- }
- catch (NoSuchFieldException e) {
- throw new ExecutionException(this, e);
- }
- }
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING_ARRAY, Arrays.asList(split));
handle.closeDeep();
if (PROVENANCE_ENABLED) {
@@ -382,7 +411,7 @@
* @return DSHandle representing the resulting string
* @throws ExecutionException
*/
- public static class StrJoin extends AbstractSingleValuedFunction {
+ public static class StrJoin extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> array;
private ArgRef<AbstractDataNode> delim;
@@ -392,6 +421,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode harray = this.array.getValue(stack);
Map<Comparable<?>, DSHandle> arrayValues = SwiftFunction.waitForArray(this, harray);
@@ -411,7 +445,7 @@
result.append(h.getValue());
}
- DSHandle handle = new RootDataNode(Types.STRING, result.toString());
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, result.toString());
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -423,7 +457,7 @@
}
}
- public static class Regexp extends AbstractSingleValuedFunction {
+ public static class Regexp extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
private ArgRef<AbstractDataNode> transform;
@@ -434,6 +468,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -461,7 +500,7 @@
if (logger.isDebugEnabled()) {
logger.debug("regexp replacement produced '" + group + "'");
}
- DSHandle handle = new RootDataNode(Types.STRING, group);
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, group);
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -474,7 +513,7 @@
}
}
- public static class ToInt extends AbstractSingleValuedFunction {
+ public static class ToInt extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> str;
@Override
@@ -483,11 +522,16 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_INT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hstr = str.getValue(stack);
String str = SwiftFunction.unwrap(this, hstr);
- DSHandle handle = new RootDataNode(Types.INT, Integer.valueOf(str));
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_INT, Integer.valueOf(str));
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -499,7 +543,7 @@
}
}
- public static class ToFloat extends AbstractSingleValuedFunction {
+ public static class ToFloat extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> str;
@Override
@@ -508,6 +552,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_FLOAT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hstr = str.getValue(stack);
Object obj = SwiftFunction.unwrap(this, hstr);
@@ -515,10 +564,10 @@
DSHandle handle;
if (obj instanceof String) {
- handle = new RootDataNode(Types.FLOAT, Double.valueOf((String) obj));
+ handle = NodeFactory.newRoot(Field.GENERIC_FLOAT, Double.valueOf((String) obj));
}
else if (obj instanceof Number) {
- handle = new RootDataNode(Types.FLOAT, ((Number) obj).doubleValue());
+ handle = NodeFactory.newRoot(Field.GENERIC_FLOAT, ((Number) obj).doubleValue());
}
else {
throw new ExecutionException("Expected a string or int. Got " + obj);
@@ -538,7 +587,7 @@
/*
* Takes in a float and formats to desired precision and returns a string
*/
- public static class Format extends AbstractSingleValuedFunction {
+ public static class Format extends AbstractSingleValuedSwiftFunction {
private ChannelRef<AbstractDataNode> c_vargs;
@Override
@@ -547,6 +596,11 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
Channel<AbstractDataNode> vargs = c_vargs.get(stack);
Channel<Object> args = SwiftFunction.unwrapAll(this, vargs);
@@ -558,7 +612,7 @@
String format = (String) args.get(0);
Object[] a = args.subChannel(1).toArray();
- DSHandle handle = new RootDataNode(Types.STRING, String.format(format, a));
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, String.format(format, a));
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -571,7 +625,7 @@
/*
* Takes in an int and pads zeros to the left and returns a string
*/
- public static class Pad extends AbstractSingleValuedFunction {
+ public static class Pad extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> size;
private ArgRef<AbstractDataNode> value;
@@ -581,13 +635,18 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hsize = this.size.getValue(stack);
Integer size = SwiftFunction.unwrap(this, hsize);
AbstractDataNode hvalue = this.value.getValue(stack);
Integer value = SwiftFunction.unwrap(this, hvalue);
- DSHandle handle = new RootDataNode(Types.STRING,
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING,
String.format("%0" + size + "d", value));
if (PROVENANCE_ENABLED) {
@@ -600,7 +659,7 @@
}
}
- public static class ToString extends AbstractSingleValuedFunction {
+ public static class ToString extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> value;
@Override
@@ -609,13 +668,18 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hvalue = this.value.getValue(stack);
hvalue.waitFor(this);
StringBuilder sb = new StringBuilder();
prettyPrint(sb, hvalue);
- DSHandle handle = new RootDataNode(Types.STRING, sb.toString());
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, StringCache.get(sb.toString()));
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -634,7 +698,7 @@
* Good for debugging because array needs to be closed
* before the length is determined
*/
- public static class Dirname extends AbstractSingleValuedFunction {
+ public static class Dirname extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> file;
@Override
@@ -643,12 +707,17 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode dn = file.getValue(stack);
String name = SwiftFunction.filename(dn)[0];
String result = new AbsFile(name).getDirectory();
- DSHandle handle = new RootDataNode(Types.STRING, result);
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_STRING, result);
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
@@ -660,7 +729,7 @@
}
}
- public static class Length extends AbstractSingleValuedFunction {
+ public static class Length extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> array;
@Override
@@ -669,11 +738,16 @@
}
@Override
+ protected Field getFieldType() {
+ return Field.GENERIC_INT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode harray = this.array.getValue(stack);
harray.waitFor(this);
- DSHandle handle = new RootDataNode(Types.INT, Integer.valueOf(harray.getArrayValue().size()));
+ DSHandle handle = NodeFactory.newRoot(Field.GENERIC_INT, Integer.valueOf(harray.getArrayValue().size()));
if (PROVENANCE_ENABLED) {
int provid = SwiftFunction.nextProvenanceID();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -36,9 +36,11 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.PhysicalFormat;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -59,7 +61,13 @@
public Object function(Stack stack) {
AbstractDataNode dest = this.dest.getValue(stack);
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -33,10 +33,12 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Types;
public class ReadStructured extends SwiftFunction {
@@ -57,7 +59,13 @@
public Object function(Stack stack) {
AbstractDataNode dest = this.dest.getValue(stack);
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
dest.closeDeep();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -26,11 +26,12 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
-import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.Path;
-import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
+import org.griphyn.vdl.mapping.nodes.ArrayHandle;
+import org.griphyn.vdl.mapping.nodes.NodeFactory;
+import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Types;
/**
@@ -63,8 +64,12 @@
return new Signature(params("spec", "..."));
}
-
@Override
+ protected Field getReturnType() {
+ return Field.GENERIC_STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hspec = this.spec.getValue(stack);
hspec.waitFor(this);
@@ -77,9 +82,9 @@
logger.debug("generated: " + msg);
}
- return new RootDataNode(Types.STRING, msg);
+ return NodeFactory.newRoot(Field.GENERIC_STRING, msg);
}
-
+
public static String format(String spec, Channel<AbstractDataNode> args) {
logger.debug("spec: " + spec);
StringBuilder output = new StringBuilder();
@@ -197,11 +202,11 @@
}
private static void append_q(DSHandle arg, StringBuilder output) {
- if (arg instanceof ArrayDataNode) {
- ArrayDataNode node = (ArrayDataNode) arg;
+ if (arg instanceof ArrayHandle) {
+ ArrayHandle node = (ArrayHandle) arg;
output.append("[");
try {
- int size = node.size();
+ int size = node.arraySize();
for (int i = 0; i < size; i++) {
String entry = "["+i+"]";
DSHandle handle =
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -24,8 +24,10 @@
import org.globus.cog.karajan.analyzer.ArgRef;
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
+import org.globus.cog.karajan.compiled.nodes.Node;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
-import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
/**
Formatted trace output. <br>
@@ -52,14 +54,32 @@
@Override
public Object function(Stack stack) {
AbstractDataNode hspec = this.spec.getValue(stack);
- hspec.waitFor(this);
- Channel<AbstractDataNode> args = c_vargs.get(stack);
- waitForAll(this, args);
- String spec = (String) hspec.getValue();
-
- String msg = Sprintf.format(spec, args);
+ String msg;
+ try {
+ hspec.waitFor(this);
+ Channel<AbstractDataNode> args = c_vargs.get(stack);
+ waitForAll(this, args);
+ String spec = (String) hspec.getValue();
+
+ msg = Sprintf.format(spec, args);
+ }
+ catch (DependentException e) {
+ msg = "<exception>";
+ }
logger.info(msg);
System.out.print(msg);
return null;
}
+
+ public static void waitForAll(Node who, Channel<AbstractDataNode> vargs) {
+ for (AbstractDataNode n : vargs) {
+ try {
+ n.waitFor(who);
+ }
+ catch (DependentException e) {
+ // ignore here, will print special message in trace
+ }
+ }
+ }
+
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2014-05-09 04:48:47 UTC (rev 7842)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2014-05-09 04:56:39 UTC (rev 7843)
@@ -32,11 +32,13 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbsFile;
-import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
+import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -62,7 +64,16 @@
// src can be any of several forms of value
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ if (logger.isInfoEnabled()) {
+ logger.info(this + " caught dependent exception");
+ }
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (dest.getType().equals(Types.STRING)) {
writeData((String)dest.getValue(), src);
More information about the Swift-commit
mailing list