[Swift-commit] r7961 - in trunk/src/org/griphyn/vdl/mapping: . file nodes
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Fri Jul 4 01:48:29 CDT 2014
Author: hategan
Date: 2014-07-04 01:48:28 -0500 (Fri, 04 Jul 2014)
New Revision: 7961
Added:
trunk/src/org/griphyn/vdl/mapping/GenericMappingParamSet.java
Modified:
trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java
trunk/src/org/griphyn/vdl/mapping/DSHandle.java
trunk/src/org/griphyn/vdl/mapping/Mapper.java
trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java
trunk/src/org/griphyn/vdl/mapping/NullMapper.java
trunk/src/org/griphyn/vdl/mapping/RootHandle.java
trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapper.java
trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedArrayDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedNonCompositeDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureArrayDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureNonCompositeDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureStructDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/InitMapper.java
trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureArrayDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureMappedSingleDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/RootFuturePrimitiveDataNode.java
trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureStructDataNode.java
Log:
some more mapper stuff cleaning
Modified: trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -19,7 +19,6 @@
import java.util.Collection;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
@@ -66,7 +65,7 @@
}
@Override
- public void setParameters(Map<String, Object> params) {
+ public void setParameters(GenericMappingParamSet params) {
this.params = newParams();
this.params.setAll(params);
}
Modified: trunk/src/org/griphyn/vdl/mapping/DSHandle.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/DSHandle.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/DSHandle.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -84,6 +84,8 @@
public void closeShallow();
public void closeDeep();
+
+ public void closeArraySizes();
public Collection<Path> getFringePaths() throws HandleOpenException;
Added: trunk/src/org/griphyn/vdl/mapping/GenericMappingParamSet.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/GenericMappingParamSet.java (rev 0)
+++ trunk/src/org/griphyn/vdl/mapping/GenericMappingParamSet.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -0,0 +1,74 @@
+//----------------------------------------------------------------------
+//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 Jun 1, 2014
+ */
+package org.griphyn.vdl.mapping;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.globus.cog.karajan.util.Pair;
+
+public class GenericMappingParamSet {
+ private final String descriptor;
+ private List<Pair<String, Object>> params;
+
+ public GenericMappingParamSet(String descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ public void addParam(Pair<String, Object> param) {
+ if (params == null) {
+ params = new ArrayList<Pair<String, Object>>(4);
+ }
+ params.add(param);
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append('<');
+ sb.append(descriptor);
+
+ if (params != null) {
+ sb.append("; ");
+ Iterator<Pair<String, Object>> it = params.iterator();
+ while (it.hasNext()) {
+ Pair<String, Object> p = it.next();
+ sb.append(p.s);
+ sb.append(" = ");
+ sb.append(p.t);
+ if (it.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ }
+ sb.append(">");
+
+ return sb.toString();
+ }
+
+ public String getDescriptor() {
+ return descriptor;
+ }
+
+ public Collection<Pair<String, Object>> getParams() {
+ if (params == null) {
+ return Collections.emptyList();
+ }
+ else {
+ return params;
+ }
+ }
+
+ public void put(String name, Object value) {
+ addParam(new Pair<String, Object>(name, value));
+ }
+}
Modified: trunk/src/org/griphyn/vdl/mapping/Mapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/Mapper.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/Mapper.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -18,7 +18,6 @@
package org.griphyn.vdl.mapping;
import java.util.Collection;
-import java.util.Map;
import java.util.Set;
import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
@@ -83,7 +82,7 @@
Set<String> getSupportedParamNames();
- void setParameters(Map<String, Object> params);
+ void setParameters(GenericMappingParamSet params);
/**
* Called after all parameters have been closed
Modified: trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -4,8 +4,8 @@
package org.griphyn.vdl.mapping;
import java.util.Collection;
-import java.util.Map;
+import org.globus.cog.karajan.util.Pair;
import org.griphyn.vdl.karajan.lib.Tracer;
import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
@@ -86,10 +86,10 @@
}
}
- public void setAll(Map<String, Object> m) {
+ public void setAll(GenericMappingParamSet m) {
if (m != null) {
- for (Map.Entry<String, Object> e : m.entrySet()) {
- set0(e.getKey(), e.getValue());
+ for (Pair<String, Object> e : m.getParams()) {
+ set0(e.s, e.t);
}
}
}
Modified: trunk/src/org/griphyn/vdl/mapping/NullMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/NullMapper.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/NullMapper.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -11,7 +11,6 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.Map;
import java.util.Set;
import org.griphyn.vdl.mapping.nodes.AbstractDataNode;
@@ -74,7 +73,7 @@
}
@Override
- public void setParameters(Map<String, Object> params) {
+ public void setParameters(GenericMappingParamSet params) {
}
@Override
Modified: trunk/src/org/griphyn/vdl/mapping/RootHandle.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootHandle.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/RootHandle.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -25,7 +25,6 @@
Mapper getActualMapper();
boolean isArray();
- void closeArraySizes();
void mapperInitialized(Mapper mapper);
}
Modified: trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapper.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapper.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -20,8 +20,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,6 +27,7 @@
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractMapper;
import org.griphyn.vdl.mapping.FileSystemLister;
+import org.griphyn.vdl.mapping.GenericMappingParamSet;
import org.griphyn.vdl.mapping.MappingParamSet;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
@@ -116,7 +115,7 @@
public static void main(String[] args) {
RegularExpressionMapper reMapper = new RegularExpressionMapper();
- Map<String, Object> params = new HashMap<String, Object>();
+ GenericMappingParamSet params = new GenericMappingParamSet("regex");
params.put("source", "2mass-j1223.fits");
params.put("match", "(.*)\\.(.*)");
params.put("transform", "\\1_area.\\2");
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedArrayDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedArrayDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -155,4 +155,11 @@
public int arraySize() {
return values.length;
}
+
+ @Override
+ public void closeArraySizes() {
+ for (DSHandle h : values) {
+ h.closeArraySizes();
+ }
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedNonCompositeDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedNonCompositeDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/AbstractClosedNonCompositeDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -39,4 +39,8 @@
public boolean isArray() {
return false;
}
+
+ @Override
+ public void closeArraySizes() {
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureArrayDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureArrayDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -170,6 +170,19 @@
handles = Collections.emptyMap();
}
}
+
+ @Override
+ public void closeArraySizes() {
+ closeShallow();
+ try {
+ for (DSHandle h : getAllFields()) {
+ h.closeArraySizes();
+ }
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
@Override
public void closeDeep() {
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureNonCompositeDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureNonCompositeDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureNonCompositeDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -91,4 +91,8 @@
value = null;
super.clean0();
}
+
+ @Override
+ public void closeArraySizes() {
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureStructDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureStructDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/AbstractFutureStructDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -139,4 +139,11 @@
throw exception;
}
}
+
+ @Override
+ public void closeArraySizes() {
+ for (DSHandle h : fields) {
+ h.closeArraySizes();
+ }
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/InitMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/InitMapper.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/InitMapper.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -10,7 +10,6 @@
package org.griphyn.vdl.mapping.nodes;
import java.util.Collection;
-import java.util.Map;
import java.util.Set;
import k.rt.Future;
@@ -24,6 +23,7 @@
import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.DuplicateMappingChecker;
import org.griphyn.vdl.mapping.FileSystemLister;
+import org.griphyn.vdl.mapping.GenericMappingParamSet;
import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Mapper;
@@ -98,7 +98,7 @@
}
@Override
- public void setParameters(Map<String, Object> params) {
+ public void setParameters(GenericMappingParamSet params) {
}
@Override
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureArrayDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureArrayDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -115,9 +115,4 @@
public Mapper getActualMapper() {
return mapper;
}
-
- @Override
- public void closeArraySizes() {
- closeShallow();
- }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureMappedSingleDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureMappedSingleDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureMappedSingleDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -118,9 +118,4 @@
public Mapper getActualMapper() {
return mapper;
}
-
- @Override
- public void closeArraySizes() {
- // does not apply
- }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/RootFuturePrimitiveDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/RootFuturePrimitiveDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/RootFuturePrimitiveDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -97,9 +97,4 @@
public Mapper getMapper() {
throw new UnsupportedOperationException("Primitive types do not have a mapper");
}
-
- @Override
- public void closeArraySizes() {
- // does not apply
- }
}
Modified: trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureStructDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureStructDataNode.java 2014-07-04 06:46:49 UTC (rev 7960)
+++ trunk/src/org/griphyn/vdl/mapping/nodes/RootFutureStructDataNode.java 2014-07-04 06:48:28 UTC (rev 7961)
@@ -129,9 +129,4 @@
public Mapper getActualMapper() {
return mapper;
}
-
- @Override
- public void closeArraySizes() {
- // does not apply
- }
}
More information about the Swift-commit
mailing list