[Swift-commit] r3283 - in branches/1.0/src/org/griphyn/vdl: karajan/lib mapping

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Apr 12 19:09:50 CDT 2010


Author: hategan
Date: 2010-04-12 19:09:50 -0500 (Mon, 12 Apr 2010)
New Revision: 3283

Modified:
   branches/1.0/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
   branches/1.0/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
   branches/1.0/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
   branches/1.0/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   branches/1.0/src/org/griphyn/vdl/mapping/ArrayDataNode.java
   branches/1.0/src/org/griphyn/vdl/mapping/RootDataNode.java
Log:
fixed problems with returning fixed arrays of structures

Modified: branches/1.0/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/karajan/lib/CloseDataset.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/karajan/lib/CloseDataset.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -6,6 +6,7 @@
 import org.apache.log4j.Logger;
 import org.globus.cog.karajan.arguments.Arg;
 import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.util.TypeUtil;
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.griphyn.vdl.mapping.DSHandle;
 import org.griphyn.vdl.mapping.InvalidPathException;
@@ -13,12 +14,13 @@
 
 public class CloseDataset extends VDLFunction {
 	public static final Logger logger = Logger.getLogger(CloseDataset.class);
+	
+	public static final Arg OA_CHILDREN_ONLY = new Arg.Optional("childrenOnly", Boolean.FALSE); 
 
 	static {
-		setArguments(CloseDataset.class, new Arg[] { PA_VAR, OA_PATH });
+		setArguments(CloseDataset.class, new Arg[] { PA_VAR, OA_PATH, OA_CHILDREN_ONLY });
 	}
 
-	// TODO path is not used!
 	public Object function(VariableStack stack) throws ExecutionException {
 		Path path = parsePath(OA_PATH.getValue(stack), stack);
 		DSHandle var = (DSHandle) PA_VAR.getValue(stack);
@@ -27,7 +29,13 @@
 				logger.info("Closing " + var);
 			}
 			var = var.getField(path);
-			closeChildren(stack, var);
+			
+			if (TypeUtil.toBoolean(OA_CHILDREN_ONLY.getValue(stack))) {
+			    closeChildren(stack, var);
+			}
+			else {
+			    closeDeep(stack, var);
+			}
 		}
 		catch (InvalidPathException e) {
 			throw new ExecutionException(e);

Modified: branches/1.0/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -29,7 +29,7 @@
 	public Object function(VariableStack stack) throws ExecutionException {
 		DSHandle var = (DSHandle) PA_VAR.getValue(stack);
 		try {
-			Path path = parsePath(OA_PATH.getValue(stack), stack);
+		    Path path = parsePath(OA_PATH.getValue(stack), stack);
 			DSHandle leaf = var.getField(path);
 			DSHandle value = (DSHandle) PA_VALUE.getValue(stack);
 			if (logger.isInfoEnabled()) {
@@ -47,6 +47,9 @@
 					}
 					deepCopy(leaf, value, stack);
 				}
+				if (var.getParent() != null && var.getParent().getType().isArray()) {
+				    markAsAvailable(stack, leaf.getParent(), leaf.getPathFromRoot().getLast());
+				}
 			}
 			return null;
 		}

Modified: branches/1.0/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -438,8 +438,31 @@
 			markToRoot(stack, handle);
 		}
 	}
+	
+	protected void closeDeep(VariableStack stack, DSHandle handle) 
+	    throws ExecutionException, InvalidPathException {
+	    synchronized(handle.getRoot()) {
+	        closeDeep(stack, handle, getFutureWrapperMap(stack));
+	    }
+	}
 
-	private void markToRoot(VariableStack stack, DSHandle handle) throws ExecutionException {
+	private void closeDeep(VariableStack stack, DSHandle handle,
+            WrapperMap hash) throws InvalidPathException, ExecutionException {
+	    handle.closeShallow();
+	    hash.close(handle);
+	    try {
+            // Mark all leaves
+            Iterator it = handle.getFields(Path.CHILDREN).iterator();
+            while (it.hasNext()) {
+                closeDeep(stack, (DSHandle) it.next(), hash);
+            }
+        }
+        catch (HandleOpenException e) {
+            throw new ExecutionException("Handle open in closeChildren",e);
+        }
+    }
+
+    private void markToRoot(VariableStack stack, DSHandle handle) throws ExecutionException {
 		// Also mark all arrays from root
 		Path fullPath = handle.getPathFromRoot();
 		DSHandle root = handle.getRoot();

Modified: branches/1.0/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -504,6 +504,26 @@
 	public boolean isClosed() {
 		return closed;
 	}
+	
+	/**
+     * Recursively closes arrays through a tree of arrays and complex types.
+     */
+    public void closeArraySizes() {
+        if (!this.closed && this.getType().isArray()) {
+            closeShallow();
+        }
+        synchronized (handles) {
+            Iterator i = handles.entrySet().iterator();
+            while (i.hasNext()) {
+                Map.Entry e = (Map.Entry) i.next();
+                AbstractDataNode child = (AbstractDataNode) e.getValue();
+                if (child.getType().isArray() ||
+                                  child.getType().getFields().size() > 0) {
+                    child.closeArraySizes();
+                }
+            }
+        }
+    }
 
 	public void closeDeep() {
 		if (!this.closed) {
@@ -519,25 +539,6 @@
 		}
 	}
 
-	/** Recursively closes arrays through a tree of arrays and complex
- 	    types. */
-	public void closeDeepStructure() {
-		if (!this.closed && this.getType().isArray()) {
-			closeShallow();
-		}
-		synchronized (handles) {
-			Iterator i = handles.entrySet().iterator();
-			while (i.hasNext()) {
-				Map.Entry e = (Map.Entry) i.next();
-				AbstractDataNode child = (AbstractDataNode) e.getValue();
-				if(child.getType().isArray()  ||
-				   child.getType().getFields().size() > 0 ) {
-					child.closeDeepStructure();
-				}
-			}
-		}
-	}
-
 	public synchronized Path getPathFromRoot() {
 		if (pathFromRoot == null) {
 			AbstractDataNode parent = (AbstractDataNode) this.getParent();

Modified: branches/1.0/src/org/griphyn/vdl/mapping/ArrayDataNode.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/mapping/ArrayDataNode.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -42,6 +42,24 @@
 			}
 		}
 	}
+	
+	/** Recursively closes arrays through a tree of arrays and complex
+        types. */
+    public void closeDeep() {
+        assert(this.getType().isArray());
+        if (!this.isClosed()) {
+            closeShallow();
+        }
+        Map handles = getHandles();
+        synchronized (handles) {
+            Iterator i = handles.entrySet().iterator();
+            while (i.hasNext()) {
+                Map.Entry e = (Map.Entry) i.next();
+                AbstractDataNode child = (AbstractDataNode) e.getValue();
+                child.closeDeep();
+            }
+        }
+    }
 
 	
 	public boolean isArray() {

Modified: branches/1.0/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- branches/1.0/src/org/griphyn/vdl/mapping/RootDataNode.java	2010-04-12 14:55:42 UTC (rev 3282)
+++ branches/1.0/src/org/griphyn/vdl/mapping/RootDataNode.java	2010-04-13 00:09:50 UTC (rev 3283)
@@ -113,6 +113,8 @@
 			checkConsistency(root);
 		}
 		else if (mapper.isStatic()) {
+			// Static mappers are (array) mappers which know the size of
+			// an array statically. A good example is the fixed array mapper
 			Iterator i = mapper.existing().iterator();
 			while (i.hasNext()) {
 				Path p = (Path) i.next();
@@ -129,7 +131,7 @@
 				}
 			}
 			if (root.isArray()) {
-				root.closeDeepStructure();
+			    root.closeArraySizes();
 			}
 			checkConsistency(root);
 		}




More information about the Swift-commit mailing list