[Swift-commit] r3169 - in trunk/src/org/griphyn/vdl/mapping: . file

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Oct 16 16:54:09 CDT 2009


Author: hategan
Date: 2009-10-16 16:54:09 -0500 (Fri, 16 Oct 2009)
New Revision: 3169

Modified:
   trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java
   trunk/src/org/griphyn/vdl/mapping/Mapper.java
   trunk/src/org/griphyn/vdl/mapping/file/ConcurrentMapper.java
Log:
re-mappable mappers

Modified: trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java	2009-10-16 21:53:38 UTC (rev 3168)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractMapper.java	2009-10-16 21:54:09 UTC (rev 3169)
@@ -51,4 +51,11 @@
 		return r;
 	}
 
+	public boolean canBeRemapped(Path path) {
+	    return false;
+	}
+
+    public void remap(Path path, PhysicalFormat file) {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: trunk/src/org/griphyn/vdl/mapping/Mapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/Mapper.java	2009-10-16 21:53:38 UTC (rev 3168)
+++ trunk/src/org/griphyn/vdl/mapping/Mapper.java	2009-10-16 21:54:09 UTC (rev 3169)
@@ -43,4 +43,12 @@
     void setParam(String name, Object value);
 
     Object getParam(String name);
+
+    /**
+     * Specifies whether paths mapped by this mapper can be re-mapped
+     * if needed (such as when aliasing another variable)
+     */
+    boolean canBeRemapped(Path path);
+    
+    void remap(Path path, PhysicalFormat file);
 }

Modified: trunk/src/org/griphyn/vdl/mapping/file/ConcurrentMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/ConcurrentMapper.java	2009-10-16 21:53:38 UTC (rev 3168)
+++ trunk/src/org/griphyn/vdl/mapping/file/ConcurrentMapper.java	2009-10-16 21:54:09 UTC (rev 3169)
@@ -3,12 +3,20 @@
  */
 package org.griphyn.vdl.mapping.file;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.griphyn.vdl.mapping.MappingParam;
+import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.PhysicalFormat;
 
 public class ConcurrentMapper extends AbstractFileMapper {
 	public static final MappingParam PARAM_THREAD_PREFIX = new MappingParam("thread_prefix", "");
+	
+	private Map remappedPaths;
 
 	public ConcurrentMapper() {
 		super(new ConcurrentElementMapper());
@@ -20,5 +28,42 @@
 		PARAM_PREFIX.setValue(params, prefix);
 		super.setParams(params);
 	}
+	
+    public synchronized Collection existing() {
+        Collection c = super.existing();
+        if (remappedPaths != null) {
+            Set s = new HashSet(c);
+            s.add(remappedPaths.keySet());
+            return s;
+        }
+        else {
+            return c;
+        }
+    }
+
+    public synchronized PhysicalFormat map(Path path) {
+        if (remappedPaths != null) {
+            Object o = remappedPaths.get(path);
+            if (o != null) {
+                return (PhysicalFormat) o;
+            }
+        }
+        return super.map(path);
+    }
+
+    public Path rmap(String name) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean canBeRemapped(Path path) {
+        return true;
+    }
+
+    public synchronized void remap(Path path, PhysicalFormat file) {
+        if (remappedPaths == null) {
+            remappedPaths = new HashMap();
+        }
+        remappedPaths.put(path, file);
+    }
 }
 




More information about the Swift-commit mailing list