+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// StreamAmoebaJoinTest.java\r
-// Since: 2009/05/14 17:52:37\r
-//\r
-// $URL$\r
-// $Author$\r
-//--------------------------------------\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.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.StopWatch;\r
-import org.xerial.util.log.Logger;\r
-import org.xerial.util.tree.TreeEventHandlerBase;\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
- config.bufferSize = 1024 * 1024 * 8; // 8MB\r
- config.numWorkers = 2;\r
- }\r
-\r
- @After\r
- public void tearDown() throws Exception {}\r
-\r
- @Test\r
- public void query() throws Exception {\r
- QuerySetBuilder qs = new QuerySetBuilder();\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
- _logger.debug(String.format("relation (%s, %s)", n1, n2));\r
- }\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
- _logger.debug(String.format("text %s:%s of %s in %s", nodeName, text, contextNode,\r
- schema));\r
- }\r
- });\r
-\r
- aj.sweep(new SilkParser(FileResource.find(StreamAmoebaJoinTest.class, "sample.silk")));\r
- }\r
-\r
- @Test\r
- public void amoebaTest() throws Exception {\r
- QuerySetBuilder qs = new QuerySetBuilder();\r
- qs.addQueryTarget(new SchemaBuilder().add("coordinate").add("revision").build());\r
-\r
- StreamAmoebaJoin aj = new StreamAmoebaJoin(qs.build(), new AmoebaJoinHandlerBase() {\r
-\r
- int count = 0;\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
- assertEquals(2, count);\r
- }\r
-\r
- });\r
-\r
- aj.sweep(new SilkParser(FileResource.find(StreamAmoebaJoinTest.class, "gene.silk")));\r
-\r
- }\r
-\r
- @Test\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,\r
- "../../../silk/scaffold1.silk"), config));\r
- _logger.info("time: " + sw.getElapsedTime());\r
- }\r
-\r
- @Test\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
- }\r
-\r
-}\r