OSDN Git Service

moved relation package into the lens package
authorleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Tue, 7 Jul 2009 04:23:50 +0000 (04:23 +0000)
committerleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Tue, 7 Jul 2009 04:23:50 +0000 (04:23 +0000)
git-svn-id: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core@3447 ae02f08e-27ec-0310-ae8c-8ba02fe2eafd

28 files changed:
src/main/java/org/xerial/lens/ObjectLens.java
src/main/java/org/xerial/lens/ObjectMapper.java
src/main/java/org/xerial/lens/relation/Cell.java [moved from src/main/java/org/xerial/relation/Cell.java with 94% similarity]
src/main/java/org/xerial/lens/relation/CellVisitor.java [moved from src/main/java/org/xerial/relation/CellVisitor.java with 93% similarity]
src/main/java/org/xerial/lens/relation/DataType.java [moved from src/main/java/org/xerial/relation/DataType.java with 96% similarity]
src/main/java/org/xerial/lens/relation/FD.java [moved from src/main/java/org/xerial/relation/FD.java with 97% similarity]
src/main/java/org/xerial/lens/relation/IndexAccess.java [moved from src/main/java/org/xerial/relation/IndexAccess.java with 94% similarity]
src/main/java/org/xerial/lens/relation/LNode.java [moved from src/main/java/org/xerial/relation/LNode.java with 98% similarity]
src/main/java/org/xerial/lens/relation/Node.java [moved from src/main/java/org/xerial/relation/Node.java with 95% similarity]
src/main/java/org/xerial/lens/relation/NodeBase.java [moved from src/main/java/org/xerial/relation/NodeBase.java with 94% similarity]
src/main/java/org/xerial/lens/relation/Tuple.java [moved from src/main/java/org/xerial/relation/Tuple.java with 95% similarity]
src/main/java/org/xerial/lens/relation/TupleIndex.java [moved from src/main/java/org/xerial/relation/TupleIndex.java with 95% similarity]
src/main/java/org/xerial/lens/relation/query/AmoebaJoinHandler.java [moved from src/main/java/org/xerial/relation/query/AmoebaJoinHandler.java with 92% similarity]
src/main/java/org/xerial/lens/relation/query/AmoebaJoinHandlerBase.java [moved from src/main/java/org/xerial/relation/query/AmoebaJoinHandlerBase.java with 88% similarity]
src/main/java/org/xerial/lens/relation/query/QuerySet.java [moved from src/main/java/org/xerial/relation/query/QuerySet.java with 96% similarity]
src/main/java/org/xerial/lens/relation/query/RelationFragmentHolder.java [moved from src/main/java/org/xerial/relation/query/RelationFragmentHolder.java with 96% similarity]
src/main/java/org/xerial/lens/relation/query/StreamAmoebaJoin.java [moved from src/main/java/org/xerial/relation/query/StreamAmoebaJoin.java with 98% similarity]
src/main/java/org/xerial/lens/relation/schema/Schema.java [moved from src/main/java/org/xerial/relation/schema/Schema.java with 94% similarity]
src/main/java/org/xerial/lens/relation/schema/SchemaArray.java [moved from src/main/java/org/xerial/relation/schema/SchemaArray.java with 98% similarity]
src/main/java/org/xerial/lens/relation/schema/SchemaAtom.java [moved from src/main/java/org/xerial/relation/schema/SchemaAtom.java with 94% similarity]
src/main/java/org/xerial/lens/relation/schema/SchemaBuilder.java [moved from src/main/java/org/xerial/relation/schema/SchemaBuilder.java with 90% similarity]
src/main/java/org/xerial/lens/relation/schema/SchemaNode.java [moved from src/main/java/org/xerial/relation/schema/SchemaNode.java with 88% similarity]
src/main/java/org/xerial/lens/relation/schema/SchemaVisitor.java [moved from src/main/java/org/xerial/relation/schema/SchemaVisitor.java with 96% similarity]
src/main/java/org/xerial/silk/archive/SilkArchiver.java
src/test/java/org/xerial/lens/relation/query/StreamAmoebaJoinTest.java [moved from src/test/java/org/xerial/relation/query/StreamAmoebaJoinTest.java with 71% similarity]
src/test/java/org/xerial/lens/relation/query/gene.silk [moved from src/test/java/org/xerial/relation/query/gene.silk with 100% similarity]
src/test/java/org/xerial/lens/relation/query/sample.silk [moved from src/test/java/org/xerial/relation/query/sample.silk with 100% similarity]
src/test/java/org/xerial/lens/relation/schema/SchemaNodeTest.java [moved from src/test/java/org/xerial/relation/schema/SchemaNodeTest.java with 94% similarity]

index 3aca20f..64c9786 100644 (file)
@@ -408,24 +408,31 @@ public class ObjectLens {
             Collection< ? > collection = (Collection< ? >) obj;\r
             boolean hasAttributes = lens.hasAttributes();\r
 \r
+            boolean bracketIsOpen = false;\r
+\r
             if (hasAttributes) {\r
                 json.startObject();\r
                 outputParemters(json, obj);\r
 \r
-                if (!collection.isEmpty())\r
+                if (!collection.isEmpty()) {\r
                     json.startArray("entry");\r
+                    bracketIsOpen = true;\r
+                }\r
             }\r
-            else\r
+            else {\r
                 json.startArray();\r
+                bracketIsOpen = true;\r
+            }\r
 \r
             for (Object elem : collection) {\r
                 toJSON(json, elem);\r
             }\r
 \r
+            if (bracketIsOpen)\r
+                json.endArray();\r
+\r
             if (hasAttributes)\r
                 json.endObject();\r
-            else\r
-                json.endArray();\r
 \r
         }\r
         else if (TypeInfo.isMap(c)) {\r
index 5bda964..15e5b91 100644 (file)
@@ -37,14 +37,14 @@ import org.xerial.lens.impl.MapEntry;
 import org.xerial.lens.impl.ParameterSetter;
 import org.xerial.lens.impl.RelationSetter;
 import org.xerial.lens.impl.ParameterSetter.MapEntryBinder;
-import org.xerial.relation.Node;
-import org.xerial.relation.query.AmoebaJoinHandler;
-import org.xerial.relation.query.AmoebaJoinHandlerBase;
-import org.xerial.relation.query.QuerySet;
-import org.xerial.relation.query.StreamAmoebaJoin;
-import org.xerial.relation.query.QuerySet.QuerySetBuilder;
-import org.xerial.relation.schema.Schema;
-import org.xerial.relation.schema.SchemaBuilder;
+import org.xerial.lens.relation.Node;
+import org.xerial.lens.relation.query.AmoebaJoinHandler;
+import org.xerial.lens.relation.query.AmoebaJoinHandlerBase;
+import org.xerial.lens.relation.query.QuerySet;
+import org.xerial.lens.relation.query.StreamAmoebaJoin;
+import org.xerial.lens.relation.query.QuerySet.QuerySetBuilder;
+import org.xerial.lens.relation.schema.Schema;
+import org.xerial.lens.relation.schema.SchemaBuilder;
 import org.xerial.util.ArrayDeque;
 import org.xerial.util.Deque;
 import org.xerial.util.bean.TypeConverter;
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 /**\r
  * A composite pattern interface for representing tree node and tuple structure.\r
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 /**\r
  * Visitor interface for traversing Tuple\r
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
 
 /**
  * Definition of the data types for schema node
similarity index 97%
rename from src/main/java/org/xerial/relation/FD.java
rename to src/main/java/org/xerial/lens/relation/FD.java
index e899d3e..4a62356 100644 (file)
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
 
 /**
  * Functional dependency that holds in the relation
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 public interface IndexAccess<NodeType>\r
 {\r
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
 
 /**
  * Light-weight node that holds only a node ID and node value.
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 /**\r
  * Node is an element ({@link Cell}) of a relation.\r
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 import org.xerial.core.XerialError;\r
 import org.xerial.core.XerialErrorCode;\r
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
@@ -22,7 +22,7 @@
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
 \r
 import org.xerial.core.XerialError;\r
 import org.xerial.core.XerialErrorCode;\r
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
 
-import org.xerial.relation.Node;
-import org.xerial.relation.schema.Schema;
+import org.xerial.lens.relation.Node;
+import org.xerial.lens.relation.schema.Schema;
 
 public interface AmoebaJoinHandler
 {
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation.query;\r
+package org.xerial.lens.relation.query;\r
 \r
-import org.xerial.relation.Node;\r
-import org.xerial.relation.schema.Schema;\r
+import org.xerial.lens.relation.Node;\r
+import org.xerial.lens.relation.schema.Schema;\r
 \r
 /**\r
  * An empty implementation of {@link AmoebaJoinHandler}\r
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,7 +30,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.xerial.relation.schema.Schema;
+import org.xerial.lens.relation.schema.Schema;
 import org.xerial.util.IndexedSet;
 
 /**
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -30,13 +30,13 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.xerial.relation.Cell;
-import org.xerial.relation.CellVisitor;
-import org.xerial.relation.Node;
-import org.xerial.relation.Tuple;
-import org.xerial.relation.TupleIndex;
-import org.xerial.relation.schema.Schema;
-import org.xerial.relation.schema.SchemaBuilder;
+import org.xerial.lens.relation.Cell;
+import org.xerial.lens.relation.CellVisitor;
+import org.xerial.lens.relation.Node;
+import org.xerial.lens.relation.Tuple;
+import org.xerial.lens.relation.TupleIndex;
+import org.xerial.lens.relation.schema.Schema;
+import org.xerial.lens.relation.schema.SchemaBuilder;
 import org.xerial.util.ArrayDeque;
 import org.xerial.util.Deque;
 import org.xerial.util.log.Logger;
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
 
 import java.io.IOException;
 import java.io.StringWriter;
@@ -36,13 +36,13 @@ import org.xerial.core.XerialError;
 import org.xerial.core.XerialErrorCode;
 import org.xerial.core.XerialException;
 import org.xerial.lens.ObjectLens;
-import org.xerial.relation.Node;
-import org.xerial.relation.TupleIndex;
-import org.xerial.relation.Node.NodeBuilder;
-import org.xerial.relation.schema.Schema;
-import org.xerial.relation.schema.SchemaArray;
-import org.xerial.relation.schema.SchemaAtom;
-import org.xerial.relation.schema.SchemaVisitor;
+import org.xerial.lens.relation.Node;
+import org.xerial.lens.relation.TupleIndex;
+import org.xerial.lens.relation.Node.NodeBuilder;
+import org.xerial.lens.relation.schema.Schema;
+import org.xerial.lens.relation.schema.SchemaArray;
+import org.xerial.lens.relation.schema.SchemaAtom;
+import org.xerial.lens.relation.schema.SchemaVisitor;
 import org.xerial.util.ArrayDeque;
 import org.xerial.util.Deque;
 import org.xerial.util.HashedDeque;
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
 
 import java.util.List;
 
-import org.xerial.relation.FD;
-import org.xerial.relation.TupleIndex;
+import org.xerial.lens.relation.FD;
+import org.xerial.lens.relation.TupleIndex;
 import org.xerial.util.Functor;
 
 /**
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -32,8 +32,8 @@ import java.util.List;
 
 import org.xerial.core.XerialError;
 import org.xerial.core.XerialErrorCode;
-import org.xerial.relation.FD;
-import org.xerial.relation.TupleIndex;
+import org.xerial.lens.relation.FD;
+import org.xerial.lens.relation.TupleIndex;
 import org.xerial.util.Functor;
 
 /**
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.xerial.relation.DataType;
-import org.xerial.relation.FD;
-import org.xerial.relation.TupleIndex;
+import org.xerial.lens.relation.DataType;
+import org.xerial.lens.relation.FD;
+import org.xerial.lens.relation.TupleIndex;
 import org.xerial.util.Functor;
 
 /**
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation.schema;\r
+package org.xerial.lens.relation.schema;\r
 \r
 import java.util.ArrayList;\r
 \r
-import org.xerial.relation.DataType;\r
-import org.xerial.relation.FD;\r
+import org.xerial.lens.relation.DataType;\r
+import org.xerial.lens.relation.FD;\r
 \r
 public class SchemaBuilder\r
 {\r
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation.schema;\r
+package org.xerial.lens.relation.schema;\r
 \r
 import java.io.Serializable;\r
 \r
-import org.xerial.relation.DataType;\r
-import org.xerial.relation.FD;\r
-import org.xerial.relation.NodeBase;\r
+import org.xerial.lens.relation.DataType;\r
+import org.xerial.lens.relation.FD;\r
+import org.xerial.lens.relation.NodeBase;\r
 \r
 /**\r
  * SchemaNode\r
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
 
 public interface SchemaVisitor
 {
index 16636d8..e2a0a2c 100644 (file)
 //--------------------------------------\r
 package org.xerial.silk.archive;\r
 \r
-import org.xerial.relation.Node;\r
-import org.xerial.relation.query.AmoebaJoinHandler;\r
-import org.xerial.relation.query.QuerySet;\r
-import org.xerial.relation.query.StreamAmoebaJoin;\r
-import org.xerial.relation.schema.Schema;\r
+import org.xerial.lens.relation.Node;\r
+import org.xerial.lens.relation.query.AmoebaJoinHandler;\r
+import org.xerial.lens.relation.query.QuerySet;\r
+import org.xerial.lens.relation.query.StreamAmoebaJoin;\r
+import org.xerial.lens.relation.schema.Schema;\r
 import org.xerial.silk.schema.SilkSchema;\r
 import org.xerial.util.tree.TreeParser;\r
 \r
 // $URL$\r
 // $Author$\r
 //--------------------------------------\r
-package org.xerial.relation.query;\r
+package org.xerial.lens.relation.query;\r
 \r
 import static org.junit.Assert.*;\r
 \r
 import org.junit.After;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
-import org.xerial.relation.DataType;\r
-import org.xerial.relation.FD;\r
-import org.xerial.relation.Node;\r
-import org.xerial.relation.query.QuerySet.QuerySetBuilder;\r
-import org.xerial.relation.schema.Schema;\r
-import org.xerial.relation.schema.SchemaBuilder;\r
+import org.xerial.lens.relation.DataType;\r
+import org.xerial.lens.relation.FD;\r
+import org.xerial.lens.relation.Node;\r
+import org.xerial.lens.relation.query.QuerySet.QuerySetBuilder;\r
+import org.xerial.lens.relation.schema.Schema;\r
+import org.xerial.lens.relation.schema.SchemaBuilder;\r
 import org.xerial.silk.SilkParser;\r
 import org.xerial.silk.SilkParserConfig;\r
 import org.xerial.util.FileResource;\r
@@ -42,48 +42,43 @@ import org.xerial.util.StopWatch;
 import org.xerial.util.log.Logger;\r
 import org.xerial.util.tree.TreeEventHandlerBase;\r
 \r
-public class StreamAmoebaJoinTest\r
-{\r
+public class StreamAmoebaJoinTest {\r
     private static Logger _logger = Logger.getLogger(StreamAmoebaJoinTest.class);\r
 \r
     SilkParserConfig config = new SilkParserConfig();\r
 \r
     @Before\r
-    public void setUp() throws Exception\r
-    {\r
+    public void setUp() throws Exception {\r
         config.bufferSize = 1024 * 1024 * 8; // 8MB\r
         config.numWorkers = 2;\r
     }\r
 \r
     @After\r
-    public void tearDown() throws Exception\r
-    {}\r
+    public void tearDown() throws Exception {}\r
 \r
     @Test\r
-    public void query() throws Exception\r
-    {\r
+    public void query() throws Exception {\r
         QuerySetBuilder qs = new QuerySetBuilder();\r
-        qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("group").add("species").add("revision").add("name")\r
-                .add("sequence").build());\r
-        qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("gene", DataType.STRUCT, FD.ONE_OR_MORE).build());\r
-        qs.addQueryTarget(new SchemaBuilder().add("gene").add("id").add("name").add("start").add("end").add("sequence")\r
-                .build());\r
+        qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("group").add("species").add(\r
+                "revision").add("name").add("sequence").build());\r
+        qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("gene", DataType.STRUCT,\r
+                FD.ONE_OR_MORE).build());\r
+        qs.addQueryTarget(new SchemaBuilder().add("gene").add("id").add("name").add("start").add(\r
+                "end").add("sequence").build());\r
 \r
         StreamAmoebaJoin aj = new StreamAmoebaJoin(qs.build(), new AmoebaJoinHandlerBase() {\r
 \r
-            public void newAmoeba(Schema schema, Node n1, Node n2)\r
-            {\r
+            public void newAmoeba(Schema schema, Node n1, Node n2) {\r
                 _logger.debug(String.format("relation (%s, %s)", n1, n2));\r
             }\r
 \r
-            public void leaveNode(Schema schema, Node node)\r
-            {\r
+            public void leaveNode(Schema schema, Node node) {\r
                 _logger.trace(String.format("leave %s in %s", node, schema));\r
             }\r
 \r
-            public void text(Schema schema, Node contextNode, String nodeName, String text)\r
-            {\r
-                _logger.debug(String.format("text %s:%s of %s in %s", nodeName, text, contextNode, schema));\r
+            public void text(Schema schema, Node contextNode, String nodeName, String text) {\r
+                _logger.debug(String.format("text %s:%s of %s in %s", nodeName, text, contextNode,\r
+                        schema));\r
             }\r
         });\r
 \r
@@ -91,8 +86,7 @@ public class StreamAmoebaJoinTest
     }\r
 \r
     @Test\r
-    public void amoebaTest() throws Exception\r
-    {\r
+    public void amoebaTest() throws Exception {\r
         QuerySetBuilder qs = new QuerySetBuilder();\r
         qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("revision").build());\r
 \r
@@ -100,14 +94,12 @@ public class StreamAmoebaJoinTest
 \r
             int count = 0;\r
 \r
-            public void newAmoeba(Schema schema, Node n1, Node n2)\r
-            {\r
+            public void newAmoeba(Schema schema, Node n1, Node n2) {\r
                 _logger.debug(String.format("relation (%s, %s)", n1, n2));\r
                 count++;\r
             }\r
 \r
-            public void finish()\r
-            {\r
+            public void finish() {\r
                 assertEquals(2, count);\r
             }\r
 \r
@@ -118,20 +110,19 @@ public class StreamAmoebaJoinTest
     }\r
 \r
     @Test\r
-    public void loadScaffold1() throws Exception\r
-    {\r
+    public void loadScaffold1() throws Exception {\r
         QuerySet qs = new QuerySetBuilder().build();\r
         StreamAmoebaJoin aj = new StreamAmoebaJoin(qs, new AmoebaJoinHandlerBase());\r
         StopWatch sw = new StopWatch();\r
-        aj.sweep(new SilkParser(FileResource.find(StreamAmoebaJoinTest.class, "../../silk/scaffold1.silk"), config));\r
+        aj.sweep(new SilkParser(FileResource.find(StreamAmoebaJoinTest.class,\r
+                "../../../silk/scaffold1.silk"), config));\r
         _logger.info("time: " + sw.getElapsedTime());\r
     }\r
 \r
     @Test\r
-    public void silkWalkPerformance() throws Exception\r
-    {\r
-        SilkParser parser = new SilkParser(FileResource.find(StreamAmoebaJoinTest.class, "../../silk/scaffold1.silk"),\r
-                config);\r
+    public void silkWalkPerformance() throws Exception {\r
+        SilkParser parser = new SilkParser(FileResource.find(StreamAmoebaJoinTest.class,\r
+                "../../../silk/scaffold1.silk"), config);\r
         StopWatch sw = new StopWatch();\r
         parser.parse(new TreeEventHandlerBase());\r
         _logger.info("time: " + sw.getElapsedTime());\r
@@ -22,7 +22,7 @@
 // $URL$
 // $Author$
 //--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
 
 import static org.junit.Assert.*;
 
@@ -35,7 +35,8 @@ import java.lang.reflect.Field;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.xerial.relation.DataType;
+import org.xerial.lens.relation.DataType;
+import org.xerial.lens.relation.schema.SchemaNode;
 
 public class SchemaNodeTest
 {