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
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;
// $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
// $URL$\r
// $Author$\r
//--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
\r
/**\r
* Visitor interface for traversing Tuple\r
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
/**
* Definition of the data types for schema node
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
/**
* Functional dependency that holds in the relation
// $URL$\r
// $Author$\r
//--------------------------------------\r
-package org.xerial.relation;\r
+package org.xerial.lens.relation;\r
\r
public interface IndexAccess<NodeType>\r
{\r
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation;
+package org.xerial.lens.relation;
/**
* Light-weight node that holds only a node ID and node value.
// $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
// $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$\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
// $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
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
import java.util.ArrayList;
import java.util.Collection;
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;
/**
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
import java.util.ArrayList;
import java.util.HashMap;
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;
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.query;
+package org.xerial.lens.relation.query;
import java.io.IOException;
import java.io.StringWriter;
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;
/**
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
import java.util.ArrayList;
import java.util.HashMap;
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
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
public interface SchemaVisitor
{
//--------------------------------------\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
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
}\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
\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
}\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
// $URL$
// $Author$
//--------------------------------------
-package org.xerial.relation.schema;
+package org.xerial.lens.relation.schema;
import static org.junit.Assert.*;
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
{