This list is closed, nobody may subscribe to it.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(139) |
Aug
(94) |
Sep
(232) |
Oct
(143) |
Nov
(138) |
Dec
(55) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(127) |
Feb
(90) |
Mar
(101) |
Apr
(74) |
May
(148) |
Jun
(241) |
Jul
(169) |
Aug
(121) |
Sep
(157) |
Oct
(199) |
Nov
(281) |
Dec
(75) |
2012 |
Jan
(107) |
Feb
(122) |
Mar
(184) |
Apr
(73) |
May
(14) |
Jun
(49) |
Jul
(26) |
Aug
(103) |
Sep
(133) |
Oct
(61) |
Nov
(51) |
Dec
(55) |
2013 |
Jan
(59) |
Feb
(72) |
Mar
(99) |
Apr
(62) |
May
(92) |
Jun
(19) |
Jul
(31) |
Aug
(138) |
Sep
(47) |
Oct
(83) |
Nov
(95) |
Dec
(111) |
2014 |
Jan
(125) |
Feb
(60) |
Mar
(119) |
Apr
(136) |
May
(270) |
Jun
(83) |
Jul
(88) |
Aug
(30) |
Sep
(47) |
Oct
(27) |
Nov
(23) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jer...@us...> - 2013-10-01 22:05:02
|
Revision: 7426 http://bigdata.svn.sourceforge.net/bigdata/?rev=7426&view=rev Author: jeremy_carroll Date: 2013-10-01 22:04:56 +0000 (Tue, 01 Oct 2013) Log Message: ----------- Fix for trac737 FILTER ( ?s = <eg:a> ) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/AssignmentNode.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/AssignmentNode.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/AssignmentNode.java 2013-10-01 22:04:37 UTC (rev 7425) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/AssignmentNode.java 2013-10-01 22:04:56 UTC (rev 7426) @@ -139,4 +139,13 @@ } + + @Override + public int replaceAllWith(final BOp oldVal, final BOp newVal) { + if (oldVal.equals(get(0)) && !(newVal instanceof VarNode)) { + return 0; + } + return super.replaceAllWith(oldVal, newVal); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2013-10-01 22:04:43
|
Revision: 7425 http://bigdata.svn.sourceforge.net/bigdata/?rev=7425&view=rev Author: jeremy_carroll Date: 2013-10-01 22:04:37 +0000 (Tue, 01 Oct 2013) Log Message: ----------- Fix for nested subselects and unions as in trac737 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSparql11SubqueryOptimizer.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSparql11SubqueryOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSparql11SubqueryOptimizer.java 2013-10-01 20:14:59 UTC (rev 7424) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSparql11SubqueryOptimizer.java 2013-10-01 22:04:37 UTC (rev 7425) @@ -50,6 +50,7 @@ import com.bigdata.rdf.sparql.ast.QueryType; import com.bigdata.rdf.sparql.ast.StaticAnalysis; import com.bigdata.rdf.sparql.ast.SubqueryRoot; +import com.bigdata.rdf.sparql.ast.UnionNode; import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; import com.bigdata.rdf.sparql.ast.service.ServiceNode; @@ -330,7 +331,7 @@ final NamedSubqueryInclude include = new NamedSubqueryInclude(newName); - final IGroupNode<IGroupMemberNode> parent = subqueryRoot.getParent(); + final IGroupNode<?> parent = subqueryRoot.getParent(); /* * Note: A SubqueryRoot normally starts out as the sole child of a @@ -347,7 +348,8 @@ */ if ((parent instanceof JoinGroupNode) && ((BOp) parent).arity() == 1 - && parent.getParent() != null) { + && parent.getParent() != null && + !((IGroupNode<?>)parent.getParent() instanceof UnionNode)) { final IGroupNode<IGroupMemberNode> pp = parent.getParent(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2013-10-01 20:15:07
|
Revision: 7424 http://bigdata.svn.sourceforge.net/bigdata/?rev=7424&view=rev Author: jeremy_carroll Date: 2013-10-01 20:14:59 +0000 (Tue, 01 Oct 2013) Log Message: ----------- Moved and renamed the 500 tests to not just check the optimization step, but also to run the queries Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNoExceptions.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/filterSubselect737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/nestedSubselectsWithUnion737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/ticket746.rq Removed Paths: ------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java 2013-10-01 17:57:50 UTC (rev 7423) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java 2013-10-01 20:14:59 UTC (rev 7424) @@ -1,192 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2013. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Oct 1, 2013 - */ - -package com.bigdata.rdf.sparql.ast.optimizers; - -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; - -import org.apache.commons.io.IOUtils; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.RDFS; -import org.openrdf.query.BindingSet; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.algebra.StatementPattern.Scope; -import org.openrdf.query.algebra.evaluation.QueryBindingSet; - -import com.bigdata.bop.BOpUtility; -import com.bigdata.bop.IBindingSet; -import com.bigdata.bop.IVariable; -import com.bigdata.bop.Var; -import com.bigdata.bop.bindingSet.EmptyBindingSet; -import com.bigdata.rdf.internal.IV; -import com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser; -import com.bigdata.rdf.sail.sparql.TestSubqueryPatterns; -import com.bigdata.rdf.sail.sparql.ast.ParseException; -import com.bigdata.rdf.sail.sparql.ast.TokenMgrError; -import com.bigdata.rdf.sparql.ast.ASTContainer; -import com.bigdata.rdf.sparql.ast.AbstractASTEvaluationTestCase; -import com.bigdata.rdf.sparql.ast.ConstantNode; -import com.bigdata.rdf.sparql.ast.IQueryNode; -import com.bigdata.rdf.sparql.ast.JoinGroupNode; -import com.bigdata.rdf.sparql.ast.NamedSubqueriesNode; -import com.bigdata.rdf.sparql.ast.NamedSubqueryInclude; -import com.bigdata.rdf.sparql.ast.NamedSubqueryRoot; -import com.bigdata.rdf.sparql.ast.ProjectionNode; -import com.bigdata.rdf.sparql.ast.QueryRoot; -import com.bigdata.rdf.sparql.ast.QueryType; -import com.bigdata.rdf.sparql.ast.StatementPatternNode; -import com.bigdata.rdf.sparql.ast.StaticAnalysis; -import com.bigdata.rdf.sparql.ast.SubqueryRoot; -import com.bigdata.rdf.sparql.ast.ValueExpressionNode; -import com.bigdata.rdf.sparql.ast.VarNode; -import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; -import com.bigdata.rdf.vocab.decls.FOAFVocabularyDecl; - -/** - * This test suite is for trac items where the failure mode is a 500 error caused - * by a software error in the static optimizer. - * - * The tests each consist of a test query in a file in this package. - * The typical test succeeds if the optimizers run on this query without a disaster. - * This test suite does NOT have either of the following objectives: - * - that the static optimizer is correct in the sense that the optimized query has the same meaning as the original query - * or - * - an optimizer in the sense that the optimized query is likely to be faster than the original query. - * - * The very limited goal is that no uncaught exceptions are thrown! - * - */ -public class TestASTOptimizer500s extends - AbstractASTEvaluationTestCase { - - /** - * - */ - public TestASTOptimizer500s() { - } - - /** - * @param name - */ - public TestASTOptimizer500s(String name) { - super(name); - } - - - /** - * Unit test for WITH {subquery} AS "name" and INCLUDE. The WITH must be in - * the top-level query. - * - * This is specifically for Trac 746 which crashed out during optimize. - * So the test simply runs that far, and does not verify anything - * other than the ability to optimize without an exception - * @throws IOException - */ - public void test_namedSubquery746() throws MalformedQueryException, - TokenMgrError, ParseException, IOException { - optimizeQuery("ticket746"); - - } - -/** - * <pre> -SELECT * -{ { SELECT * { ?s ?p ?o } LIMIT 1 } - FILTER ( ?s = <eg:a> ) -} - </pre> - * @throws MalformedQueryException - * @throws TokenMgrError - * @throws ParseException - * @throws IOException - */ - public void test_filterSubselect737() throws MalformedQueryException, - TokenMgrError, ParseException, IOException { - optimizeQuery("filterSubselect737"); - - } - - -/** - * <pre> -SELECT * -WHERE { - - { FILTER ( false ) } - UNION - { - { SELECT ?Subject_A - WHERE { - { SELECT $j__5 ?Subject_A - { - } ORDER BY $j__5 - } - } GROUP BY ?Subject_A - } - } - OPTIONAL { - { SELECT ?Subject_A - WHERE { - { SELECT $j__8 ?Subject_A - { - - } ORDER BY $j_8 - } - } GROUP BY ?Subject_A - } - } -} - </pre> - * @throws MalformedQueryException - * @throws TokenMgrError - * @throws ParseException - * @throws IOException - */ - public void test_nestedSubselectsWithUnion737() throws MalformedQueryException, - TokenMgrError, ParseException, IOException { - optimizeQuery("nestedSubselectsWithUnion737"); - - } - - void optimizeQuery(final String queryfile) throws IOException, MalformedQueryException { - final String sparql = IOUtils.toString(getClass().getResourceAsStream(queryfile+".rq")); - - - final QueryRoot ast = new Bigdata2ASTSPARQLParser(store).parseQuery2(sparql,baseURI).getOriginalAST(); - - final IASTOptimizer rewriter = new DefaultOptimizerList(); - - final AST2BOpContext context = new AST2BOpContext(new ASTContainer(ast), store); - rewriter.optimize(context, ast/* queryNode */, new IBindingSet[]{EmptyBindingSet.INSTANCE}); - } - -} Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq 2013-10-01 17:57:50 UTC (rev 7423) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -1,4 +0,0 @@ -SELECT * -{ { SELECT * { ?s ?p ?o } LIMIT 1 } - FILTER ( ?s = <eg:a> ) -} \ No newline at end of file Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq 2013-10-01 17:57:50 UTC (rev 7423) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -1,27 +0,0 @@ -SELECT * -WHERE { - - { FILTER ( false ) } - UNION - { - { SELECT ?Subject_A - WHERE { - { SELECT $j__5 ?Subject_A - { - } ORDER BY $j__5 - } - } GROUP BY ?Subject_A - } - } - OPTIONAL { - { SELECT ?Subject_A - WHERE { - { SELECT $j__8 ?Subject_A - { - - } ORDER BY $j_8 - } - } GROUP BY ?Subject_A - } - } -} \ No newline at end of file Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq 2013-10-01 17:57:50 UTC (rev 7423) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -1,35 +0,0 @@ -base <http://example.org/> -prefix sys: </bdm/api/kbobject/sys:> -prefix base: </bdm/api/kbobject/base:> -prefix syapse: </graph/syapse#> -prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> -prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - -SELECT * - -WITH { -SELECT * - -WHERE { - - OPTIONAL { - base:disease syapse:hasLiteralProperty $j2 . - ?Sample_A $j2 ?j1 - } - OPTIONAL { - base:species syapse:hasLiteralProperty $j4 . - ?Sample_A $j4 ?j3 - } - OPTIONAL { - ?Sample_A sys:name ?j5 - } - ?Sample_A rdf:type / rdfs:subClassOf * base:MammalianCellLineSample -} - -} AS %__UserQuery - -WHERE { - -INCLUDE %__UserQuery - -} Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNoExceptions.java (from rev 7423, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNoExceptions.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNoExceptions.java 2013-10-01 20:14:59 UTC (rev 7424) @@ -0,0 +1,272 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2013. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on Oct 1, 2013 + */ + +package com.bigdata.rdf.sail; + +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.Properties; + +import org.apache.commons.io.IOUtils; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.URIImpl; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.BindingSet; +import org.openrdf.query.MalformedQueryException; +import org.openrdf.query.QueryEvaluationException; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQuery; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.algebra.StatementPattern.Scope; +import org.openrdf.query.algebra.evaluation.QueryBindingSet; +import org.openrdf.repository.RepositoryConnection; +import org.openrdf.repository.RepositoryException; +import org.openrdf.repository.sail.SailRepository; +import org.openrdf.rio.RDFHandlerException; +import org.openrdf.rio.RDFParseException; +import org.openrdf.sail.memory.MemoryStore; + +import com.bigdata.bop.BOpUtility; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.IVariable; +import com.bigdata.bop.Var; +import com.bigdata.bop.bindingSet.EmptyBindingSet; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser; +import com.bigdata.rdf.sail.sparql.TestSubqueryPatterns; +import com.bigdata.rdf.sail.sparql.ast.ParseException; +import com.bigdata.rdf.sail.sparql.ast.TokenMgrError; +import com.bigdata.rdf.sparql.ast.ASTContainer; +import com.bigdata.rdf.sparql.ast.AbstractASTEvaluationTestCase; +import com.bigdata.rdf.sparql.ast.ConstantNode; +import com.bigdata.rdf.sparql.ast.IQueryNode; +import com.bigdata.rdf.sparql.ast.JoinGroupNode; +import com.bigdata.rdf.sparql.ast.NamedSubqueriesNode; +import com.bigdata.rdf.sparql.ast.NamedSubqueryInclude; +import com.bigdata.rdf.sparql.ast.NamedSubqueryRoot; +import com.bigdata.rdf.sparql.ast.ProjectionNode; +import com.bigdata.rdf.sparql.ast.QueryRoot; +import com.bigdata.rdf.sparql.ast.QueryType; +import com.bigdata.rdf.sparql.ast.StatementPatternNode; +import com.bigdata.rdf.sparql.ast.StaticAnalysis; +import com.bigdata.rdf.sparql.ast.SubqueryRoot; +import com.bigdata.rdf.sparql.ast.ValueExpressionNode; +import com.bigdata.rdf.sparql.ast.VarNode; +import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; +import com.bigdata.rdf.sparql.ast.optimizers.DefaultOptimizerList; +import com.bigdata.rdf.sparql.ast.optimizers.IASTOptimizer; +import com.bigdata.rdf.vocab.NoVocabulary; +import com.bigdata.rdf.vocab.decls.FOAFVocabularyDecl; + +/** + * This test suite is for trac items where the failure mode is a 500 error caused + * by a software error, often in the static optimizer. + * + * The tests each consist of a test query in a file in this package. + * The typical test succeeds if the optimizers run on this query without a disaster. + * This test suite does NOT have either of the following objectives: + * - that the static optimizer is correct in the sense that the optimized query has the same meaning as the original query + * or + * - an optimizer in the sense that the optimized query is likely to be faster than the original query. + * + * The very limited goal is that no uncaught exceptions are thrown! + * + */ +public class TestNoExceptions extends + QuadsTestCase { + + /** + * + */ + public TestNoExceptions() { + } + + /** + * @param name + */ + public TestNoExceptions(String name) { + super(name); + } + + public AbstractBigdataSailTestCase getOurDelegate() { + + if (getDelegate() == null) { + + String testClass = System.getProperty("testClass"); + if (testClass != null) { + return super.getOurDelegate(); + + } + setDelegate(new com.bigdata.rdf.sail.TestBigdataSailWithQuads()); + } + return (AbstractBigdataSailTestCase) super.getDelegate(); + } + + /** + * Please set your database properties here, except for your journal file, + * please DO NOT SPECIFY A JOURNAL FILE. + */ + @Override + public Properties getProperties() { + + final Properties props = super.getProperties(); + + /* + * For example, here is a set of five properties that turns off + * inference, truth maintenance, and the free text index. + */ + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, + NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, + NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); +// props.setProperty(BigdataSail.Options.INLINE_DATE_TIMES, "true"); +// props.setProperty(BigdataSail.Options.ISOLATABLE_INDICES, "true"); +// props.setProperty(BigdataSail.Options.EXACT_SIZE, "true"); +// props.setProperty(BigdataSail.Options.ALLOW_SESAME_QUERY_EVALUATION, +// "false"); + props.setProperty(BigdataSail.Options.STATEMENT_IDENTIFIERS, "false"); + + return props; + + } + /** + * Unit test for WITH {subquery} AS "name" and INCLUDE. The WITH must be in + * the top-level query. + * + * This is specifically for Trac 746 which crashed out during optimize. + * So the test simply runs that far, and does not verify anything + * other than the ability to optimize without an exception + * @throws IOException + */ + public void test_namedSubquery746() throws Exception, + TokenMgrError, ParseException, IOException { + optimizeQuery("ticket746"); + + } + +/** + * <pre> +SELECT * +{ { SELECT * { ?s ?p ?o } LIMIT 1 } + FILTER ( ?s = <eg:a> ) +} + </pre> + * @throws MalformedQueryException + * @throws TokenMgrError + * @throws ParseException + * @throws IOException + */ + public void test_filterSubselect737() throws Exception, + TokenMgrError, ParseException, IOException { + optimizeQuery("filterSubselect737"); + + } + + +/** + * <pre> +SELECT * +WHERE { + + { FILTER ( false ) } + UNION + { + { SELECT ?Subject_A + WHERE { + { SELECT $j__5 ?Subject_A + { + } ORDER BY $j__5 + } + } GROUP BY ?Subject_A + } + } + OPTIONAL { + { SELECT ?Subject_A + WHERE { + { SELECT $j__8 ?Subject_A + { + + } ORDER BY $j_8 + } + } GROUP BY ?Subject_A + } + } +} + </pre> + * @throws MalformedQueryException + * @throws TokenMgrError + * @throws ParseException + * @throws IOException + */ + public void test_nestedSubselectsWithUnion737() throws Exception, + TokenMgrError, ParseException, IOException { + optimizeQuery("nestedSubselectsWithUnion737"); + + } + + void optimizeQuery(final String queryfile) throws Exception { + final String sparql = IOUtils.toString(getClass().getResourceAsStream(queryfile+".rq")); + // try with Bigdata: + final BigdataSail sail = getSail(); + try { + executeQuery(new BigdataSailRepository(sail),sparql); + } finally { + sail.__tearDownUnitTest(); + } + + } + + private void executeQuery(final SailRepository repo, final String query) + throws RepositoryException, MalformedQueryException, + QueryEvaluationException, RDFParseException, IOException, + RDFHandlerException { + try { + repo.initialize(); + final RepositoryConnection conn = repo.getConnection(); + conn.setAutoCommit(false); + try { + final ValueFactory vf = conn.getValueFactory(); + conn.commit(); + TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult tqr = tq.evaluate(); + tqr.close(); + } finally { + conn.close(); + } + } finally { + repo.shutDown(); + } + } + +} Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/filterSubselect737.rq (from rev 7423, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/filterSubselect737.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/filterSubselect737.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -0,0 +1,4 @@ +SELECT * +{ { SELECT * { ?s ?p ?o } LIMIT 1 } + FILTER ( ?s = <eg:a> ) +} \ No newline at end of file Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/nestedSubselectsWithUnion737.rq (from rev 7423, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/nestedSubselectsWithUnion737.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/nestedSubselectsWithUnion737.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -0,0 +1,27 @@ +SELECT * +WHERE { + + { FILTER ( false ) } + UNION + { + { SELECT ?Subject_A + WHERE { + { SELECT $j__5 ?Subject_A + { + } ORDER BY $j__5 + } + } GROUP BY ?Subject_A + } + } + OPTIONAL { + { SELECT ?Subject_A + WHERE { + { SELECT $j__8 ?Subject_A + { + + } ORDER BY $j_8 + } + } GROUP BY ?Subject_A + } + } +} \ No newline at end of file Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/ticket746.rq (from rev 7423, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/ticket746.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/ticket746.rq 2013-10-01 20:14:59 UTC (rev 7424) @@ -0,0 +1,35 @@ +base <http://example.org/> +prefix sys: </bdm/api/kbobject/sys:> +prefix base: </bdm/api/kbobject/base:> +prefix syapse: </graph/syapse#> +prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> +prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + +SELECT * + +WITH { +SELECT * + +WHERE { + + OPTIONAL { + base:disease syapse:hasLiteralProperty $j2 . + ?Sample_A $j2 ?j1 + } + OPTIONAL { + base:species syapse:hasLiteralProperty $j4 . + ?Sample_A $j4 ?j3 + } + OPTIONAL { + ?Sample_A sys:name ?j5 + } + ?Sample_A rdf:type / rdfs:subClassOf * base:MammalianCellLineSample +} + +} AS %__UserQuery + +WHERE { + +INCLUDE %__UserQuery + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2013-10-01 17:57:57
|
Revision: 7423 http://bigdata.svn.sourceforge.net/bigdata/?rev=7423&view=rev Author: jeremy_carroll Date: 2013-10-01 17:57:50 +0000 (Tue, 01 Oct 2013) Log Message: ----------- added new tests for java exceptions during static optimize: specifically trac737 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq Removed Paths: ------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java 2013-09-28 19:18:59 UTC (rev 7422) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java 2013-10-01 17:57:50 UTC (rev 7423) @@ -843,32 +843,5 @@ } - /** - * Unit test for WITH {subquery} AS "name" and INCLUDE. The WITH must be in - * the top-level query. - * - * This is specifically for Trac 746 which crashed out during optimize. - * So the test simply runs that far, and does not verify anything - * other than the ability to optimize without an exception - * @throws IOException - */ - public void test_namedSubquery746() throws MalformedQueryException, - TokenMgrError, ParseException, IOException { - - final String sparql = IOUtils.toString(getClass().getResourceAsStream("ticket746.txt")); - - - final QueryRoot ast = new Bigdata2ASTSPARQLParser(store).parseQuery2(sparql, - baseURI).getOriginalAST(); - - - final IASTOptimizer rewriter = new DefaultOptimizerList(); - - final AST2BOpContext context = new AST2BOpContext(new ASTContainer( - ast), store); - rewriter.optimize(context, ast/* queryNode */, null); - - - } } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTOptimizer500s.java 2013-10-01 17:57:50 UTC (rev 7423) @@ -0,0 +1,192 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2013. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on Oct 1, 2013 + */ + +package com.bigdata.rdf.sparql.ast.optimizers; + +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; + +import org.apache.commons.io.IOUtils; +import org.openrdf.model.impl.URIImpl; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.BindingSet; +import org.openrdf.query.MalformedQueryException; +import org.openrdf.query.algebra.StatementPattern.Scope; +import org.openrdf.query.algebra.evaluation.QueryBindingSet; + +import com.bigdata.bop.BOpUtility; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.IVariable; +import com.bigdata.bop.Var; +import com.bigdata.bop.bindingSet.EmptyBindingSet; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser; +import com.bigdata.rdf.sail.sparql.TestSubqueryPatterns; +import com.bigdata.rdf.sail.sparql.ast.ParseException; +import com.bigdata.rdf.sail.sparql.ast.TokenMgrError; +import com.bigdata.rdf.sparql.ast.ASTContainer; +import com.bigdata.rdf.sparql.ast.AbstractASTEvaluationTestCase; +import com.bigdata.rdf.sparql.ast.ConstantNode; +import com.bigdata.rdf.sparql.ast.IQueryNode; +import com.bigdata.rdf.sparql.ast.JoinGroupNode; +import com.bigdata.rdf.sparql.ast.NamedSubqueriesNode; +import com.bigdata.rdf.sparql.ast.NamedSubqueryInclude; +import com.bigdata.rdf.sparql.ast.NamedSubqueryRoot; +import com.bigdata.rdf.sparql.ast.ProjectionNode; +import com.bigdata.rdf.sparql.ast.QueryRoot; +import com.bigdata.rdf.sparql.ast.QueryType; +import com.bigdata.rdf.sparql.ast.StatementPatternNode; +import com.bigdata.rdf.sparql.ast.StaticAnalysis; +import com.bigdata.rdf.sparql.ast.SubqueryRoot; +import com.bigdata.rdf.sparql.ast.ValueExpressionNode; +import com.bigdata.rdf.sparql.ast.VarNode; +import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; +import com.bigdata.rdf.vocab.decls.FOAFVocabularyDecl; + +/** + * This test suite is for trac items where the failure mode is a 500 error caused + * by a software error in the static optimizer. + * + * The tests each consist of a test query in a file in this package. + * The typical test succeeds if the optimizers run on this query without a disaster. + * This test suite does NOT have either of the following objectives: + * - that the static optimizer is correct in the sense that the optimized query has the same meaning as the original query + * or + * - an optimizer in the sense that the optimized query is likely to be faster than the original query. + * + * The very limited goal is that no uncaught exceptions are thrown! + * + */ +public class TestASTOptimizer500s extends + AbstractASTEvaluationTestCase { + + /** + * + */ + public TestASTOptimizer500s() { + } + + /** + * @param name + */ + public TestASTOptimizer500s(String name) { + super(name); + } + + + /** + * Unit test for WITH {subquery} AS "name" and INCLUDE. The WITH must be in + * the top-level query. + * + * This is specifically for Trac 746 which crashed out during optimize. + * So the test simply runs that far, and does not verify anything + * other than the ability to optimize without an exception + * @throws IOException + */ + public void test_namedSubquery746() throws MalformedQueryException, + TokenMgrError, ParseException, IOException { + optimizeQuery("ticket746"); + + } + +/** + * <pre> +SELECT * +{ { SELECT * { ?s ?p ?o } LIMIT 1 } + FILTER ( ?s = <eg:a> ) +} + </pre> + * @throws MalformedQueryException + * @throws TokenMgrError + * @throws ParseException + * @throws IOException + */ + public void test_filterSubselect737() throws MalformedQueryException, + TokenMgrError, ParseException, IOException { + optimizeQuery("filterSubselect737"); + + } + + +/** + * <pre> +SELECT * +WHERE { + + { FILTER ( false ) } + UNION + { + { SELECT ?Subject_A + WHERE { + { SELECT $j__5 ?Subject_A + { + } ORDER BY $j__5 + } + } GROUP BY ?Subject_A + } + } + OPTIONAL { + { SELECT ?Subject_A + WHERE { + { SELECT $j__8 ?Subject_A + { + + } ORDER BY $j_8 + } + } GROUP BY ?Subject_A + } + } +} + </pre> + * @throws MalformedQueryException + * @throws TokenMgrError + * @throws ParseException + * @throws IOException + */ + public void test_nestedSubselectsWithUnion737() throws MalformedQueryException, + TokenMgrError, ParseException, IOException { + optimizeQuery("nestedSubselectsWithUnion737"); + + } + + void optimizeQuery(final String queryfile) throws IOException, MalformedQueryException { + final String sparql = IOUtils.toString(getClass().getResourceAsStream(queryfile+".rq")); + + + final QueryRoot ast = new Bigdata2ASTSPARQLParser(store).parseQuery2(sparql,baseURI).getOriginalAST(); + + final IASTOptimizer rewriter = new DefaultOptimizerList(); + + final AST2BOpContext context = new AST2BOpContext(new ASTContainer(ast), store); + rewriter.optimize(context, ast/* queryNode */, new IBindingSet[]{EmptyBindingSet.INSTANCE}); + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/filterSubselect737.rq 2013-10-01 17:57:50 UTC (rev 7423) @@ -0,0 +1,4 @@ +SELECT * +{ { SELECT * { ?s ?p ?o } LIMIT 1 } + FILTER ( ?s = <eg:a> ) +} \ No newline at end of file Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/nestedSubselectsWithUnion737.rq 2013-10-01 17:57:50 UTC (rev 7423) @@ -0,0 +1,27 @@ +SELECT * +WHERE { + + { FILTER ( false ) } + UNION + { + { SELECT ?Subject_A + WHERE { + { SELECT $j__5 ?Subject_A + { + } ORDER BY $j__5 + } + } GROUP BY ?Subject_A + } + } + OPTIONAL { + { SELECT ?Subject_A + WHERE { + { SELECT $j__8 ?Subject_A + { + + } ORDER BY $j_8 + } + } GROUP BY ?Subject_A + } + } +} \ No newline at end of file Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq (from rev 7422, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.rq 2013-10-01 17:57:50 UTC (rev 7423) @@ -0,0 +1,35 @@ +base <http://example.org/> +prefix sys: </bdm/api/kbobject/sys:> +prefix base: </bdm/api/kbobject/base:> +prefix syapse: </graph/syapse#> +prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> +prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + +SELECT * + +WITH { +SELECT * + +WHERE { + + OPTIONAL { + base:disease syapse:hasLiteralProperty $j2 . + ?Sample_A $j2 ?j1 + } + OPTIONAL { + base:species syapse:hasLiteralProperty $j4 . + ?Sample_A $j4 ?j3 + } + OPTIONAL { + ?Sample_A sys:name ?j5 + } + ?Sample_A rdf:type / rdfs:subClassOf * base:MammalianCellLineSample +} + +} AS %__UserQuery + +WHERE { + +INCLUDE %__UserQuery + +} Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt 2013-09-28 19:18:59 UTC (rev 7422) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt 2013-10-01 17:57:50 UTC (rev 7423) @@ -1,35 +0,0 @@ -base <http://example.org/> -prefix sys: </bdm/api/kbobject/sys:> -prefix base: </bdm/api/kbobject/base:> -prefix syapse: </graph/syapse#> -prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> -prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - -SELECT * - -WITH { -SELECT * - -WHERE { - - OPTIONAL { - base:disease syapse:hasLiteralProperty $j2 . - ?Sample_A $j2 ?j1 - } - OPTIONAL { - base:species syapse:hasLiteralProperty $j4 . - ?Sample_A $j4 ?j3 - } - OPTIONAL { - ?Sample_A sys:name ?j5 - } - ?Sample_A rdf:type / rdfs:subClassOf * base:MammalianCellLineSample -} - -} AS %__UserQuery - -WHERE { - -INCLUDE %__UserQuery - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2013-09-28 19:19:07
|
Revision: 7422 http://bigdata.svn.sourceforge.net/bigdata/?rev=7422&view=rev Author: mrpersonick Date: 2013-09-28 19:18:59 +0000 (Sat, 28 Sep 2013) Log Message: ----------- remote query cancellation Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepositoryManager.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java 2013-09-28 18:35:26 UTC (rev 7421) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/RemoteServiceCallImpl.java 2013-09-28 19:18:59 UTC (rev 7422) @@ -27,6 +27,8 @@ package com.bigdata.rdf.sparql.ast.service; +import java.util.UUID; + import org.apache.http.HttpResponse; import org.apache.http.impl.client.DefaultHttpClient; import org.openrdf.query.BindingSet; @@ -134,7 +136,11 @@ // opts.queryStr = queryStr; + final UUID queryId = UUID.randomUUID(); + o.addRequestParam("query", queryStr); + + o.addRequestParam("queryId", queryId.toString()); final RemoteRepository repo = new RemoteRepository(uriStr, new DefaultHttpClient(params.getClientConnectionManager()), @@ -152,14 +158,16 @@ try { - final HttpResponse resp = repo.doConnect(o); +// final HttpResponse resp = repo.doConnect(o); +// +// RemoteRepository.checkResponseCode(resp); +// +// queryResult = repo.tupleResults(resp); +// +//// queryResult = parseResults(checkResponseCode(doSparqlQuery(opts))); + + queryResult = repo.tupleResults(o, queryId); - RemoteRepository.checkResponseCode(resp); - - queryResult = repo.tupleResults(resp); - -// queryResult = parseResults(checkResponseCode(doSparqlQuery(opts))); - } finally { /* Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java 2013-09-28 18:35:26 UTC (rev 7421) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java 2013-09-28 19:18:59 UTC (rev 7422) @@ -151,7 +151,7 @@ * The name of a request parameter whose value is the {@link UUID} of a * top-level query. */ - public static final String QUERY_ID = "queryId"; + private static final String QUERY_ID = "queryId"; /** * The name of a request parameter used to cancel a running query. At least @@ -160,7 +160,7 @@ * * @see #QUERY_ID */ - public static final String CANCEL_QUERY = "cancelQuery"; + protected static final String CANCEL_QUERY = "cancelQuery"; /** * Request a snapshot of the journal (HA only). The snapshot will be written Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:35:26 UTC (rev 7421) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 19:18:59 UTC (rev 7422) @@ -99,8 +99,6 @@ import org.xml.sax.Attributes; import org.xml.sax.ext.DefaultHandler2; -import com.bigdata.rdf.sail.webapp.StatusServlet; - // Note: Do not import. Not part of the bigdata-client.jar // //import com.bigdata.rdf.sparql.ast.service.RemoteServiceOptions; @@ -329,13 +327,13 @@ opts.method = "GET"; - HttpResponse response = null; +// HttpResponse response = null; opts.setAcceptHeader(ConnectOptions.DEFAULT_GRAPH_ACCEPT_HEADER); - checkResponseCode(response = doConnect(opts)); +// checkResponseCode(response = doConnect(opts)); - return graphResults(response); + return graphResults(opts, null); } @@ -531,11 +529,14 @@ */ public void cancel(final UUID queryId) throws Exception { + if (queryId == null) + return; + final ConnectOptions opts = newUpdateConnectOptions(); - opts.addRequestParam(StatusServlet.CANCEL_QUERY); + opts.addRequestParam("cancelQuery"); - opts.addRequestParam(StatusServlet.QUERY_ID, queryId.toString()); + opts.addRequestParam("queryId", queryId.toString()); checkResponseCode(doConnect(opts)); @@ -1037,14 +1038,10 @@ @Override public GraphQueryResult evaluate() throws Exception { - HttpResponse response = null; - setupConnectOptions(); - checkResponseCode(response = doConnect(opts)); + return graphResults(opts, getQueryId()); - return graphResults(response); - } } @@ -1072,30 +1069,34 @@ @Override public boolean evaluate() throws Exception { + + setupConnectOptions(); - HttpResponse response = null; - try { + return booleanResults(opts, getQueryId()); - setupConnectOptions(); - - checkResponseCode(response = doConnect(opts)); - - return booleanResults(response); - - } finally { - - try { - - if (response != null) - EntityUtils.consume(response.getEntity()); - - } catch (Exception ex) { - - log.warn(ex); - - } - - } +// HttpResponse response = null; +// try { +// +// setupConnectOptions(); +// +// checkResponseCode(response = doConnect(opts)); +// +// return booleanResults(response); +// +// } finally { +// +// try { +// +// if (response != null) +// EntityUtils.consume(response.getEntity()); +// +// } catch (Exception ex) { +// +// log.warn(ex); +// +// } +// +// } } @@ -1535,90 +1536,6 @@ * @throws Exception * If anything goes wrong. */ - public TupleQueryResult tupleResults(final HttpResponse response) - throws Exception { - - HttpEntity entity = null; - BackgroundTupleResult result = null; - try { - - entity = response.getEntity(); - - final String contentType = entity.getContentType().getValue(); - - final MiniMime mimeType = new MiniMime(contentType); - - final TupleQueryResultFormat format = TupleQueryResultFormat - .forMIMEType(mimeType.getMimeType()); - - if (format == null) - throw new IOException( - "Could not identify format for service response: serviceURI=" - + sparqlEndpointURL + ", contentType=" + contentType - + " : response=" + getResponseBody(response)); - - final TupleQueryResultParserFactory parserFactory = TupleQueryResultParserRegistry - .getInstance().get(format); - - if (parserFactory == null) - throw new IOException( - "No parser for format for service response: serviceURI=" - + sparqlEndpointURL + ", contentType=" + contentType - + ", format=" + format + " : response=" - + getResponseBody(response)); - - final TupleQueryResultParser parser = parserFactory.getParser(); - - final InputStream in = entity.getContent(); - - result = new BackgroundTupleResult(parser, in, entity); - - executor.execute(result); - - final MapBindingSet bindings = new MapBindingSet(); - - final InsertBindingSetCursor cursor = - new InsertBindingSetCursor(result, bindings); - - final List<String> list = new ArrayList<String>( - result.getBindingNames()); - - return new TupleQueryResultImpl(list, cursor); - -// final TupleQueryResultBuilder handler = new TupleQueryResultBuilder(); -// -// parser.setTupleQueryResultHandler(handler); -// -// parser.parse(entity.getContent()); -// -// // done. -// return handler.getQueryResult(); - - } finally { - -// // terminate the http connection. -// response.disconnect(); - if (result == null) { - try { - EntityUtils.consume(entity); - } catch (IOException ex) { } - } - - } - - } - - /** - * Extracts the solutions from a SPARQL query. - * - * @param response - * The connection from which to read the results. - * - * @return The results. - * - * @throws Exception - * If anything goes wrong. - */ public TupleQueryResult tupleResults(final ConnectOptions opts, final UUID queryId) throws Exception { @@ -1693,20 +1610,24 @@ } @Override - public synchronized void close() throws QueryEvaluationException { + public void close() throws QueryEvaluationException { - super.close(); + try { - if (notDone.compareAndSet(true, false)) { - - try { - cancel(queryId); - } catch (Exception ex) { - throw new QueryEvaluationException(ex); - } - - } + super.close(); + } finally { + + if (notDone.compareAndSet(true, false)) { + + try { + cancel(queryId); + } catch (Exception ex) { } + + } + + } + }; }; @@ -1726,7 +1647,7 @@ // // terminate the http connection. // response.disconnect(); - if (result == null) { + if (entity != null && result == null) { try { EntityUtils.consume(entity); } catch (IOException ex) { } @@ -1753,12 +1674,18 @@ * @throws Exception * If anything goes wrong. */ - public GraphQueryResult graphResults(final HttpResponse response) throws Exception { + public GraphQueryResult graphResults(final ConnectOptions opts, final UUID queryId) + throws Exception { + HttpResponse response = null; HttpEntity entity = null; BackgroundGraphResult result = null; try { + response = doConnect(opts); + + checkResponseCode(response); + entity = response.getEntity(); final String baseURI = ""; @@ -1808,11 +1735,53 @@ // charset=application/rdf+xml } - result = new BackgroundGraphResult( - parser, entity.getContent(), charset, baseURI, entity); + final BackgroundGraphResult tmp = new BackgroundGraphResult( + parser, entity.getContent(), charset, baseURI, entity) { + + final AtomicBoolean notDone = new AtomicBoolean(true); + + @Override + public boolean hasNext() throws QueryEvaluationException { + + final boolean hasNext = super.hasNext(); + + if (hasNext == false) { + + notDone.set(false); + + } + + return hasNext; + + } + + @Override + public void close() throws QueryEvaluationException { + + try { + + super.close(); + + } finally { + + if (notDone.compareAndSet(true, false)) { + + try { + cancel(queryId); + } catch (Exception ex) { } + + } + + } + + }; + + }; - executor.execute(result); + executor.execute(tmp); + result = tmp; + return result; // final Graph g = new GraphImpl(); @@ -1828,10 +1797,14 @@ // // terminate the http connection. // response.disconnect(); - if (result == null) { + if (response != null && result == null) { try { EntityUtils.consume(entity); } catch (IOException ex) { } + + try { + cancel(queryId); + } catch (Exception ex) { } } } @@ -1851,11 +1824,17 @@ * If anything goes wrong, including if the result set does not * encode a single boolean value. */ - protected boolean booleanResults(final HttpResponse response) throws Exception { + protected boolean booleanResults(final ConnectOptions opts, final UUID queryId) throws Exception { + HttpResponse response = null; HttpEntity entity = null; + Boolean result = null; try { + response = doConnect(opts); + + checkResponseCode(response); + entity = response.getEntity(); final String contentType = entity.getContentType().getValue(); @@ -1879,7 +1858,7 @@ final BooleanQueryResultParser parser = factory.getParser(); - final boolean result = parser.parse(entity.getContent()); + result = parser.parse(entity.getContent()); return result; @@ -1887,9 +1866,15 @@ // // terminate the http connection. // response.disconnect(); - try { - EntityUtils.consume(entity); - } catch (IOException ex) { } + if (result == null) { + try { + EntityUtils.consume(entity); + } catch (IOException ex) { } + + try { + cancel(queryId); + } catch (Exception ex) { } + } } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepositoryManager.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepositoryManager.java 2013-09-28 18:35:26 UTC (rev 7421) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepositoryManager.java 2013-09-28 19:18:59 UTC (rev 7422) @@ -171,27 +171,29 @@ opts.method = "GET"; - HttpResponse response = null; - GraphQueryResult result = null; +// HttpResponse response = null; +// GraphQueryResult result = null; opts.setAcceptHeader(ConnectOptions.DEFAULT_GRAPH_ACCEPT_HEADER); - try { - // check response in try. - checkResponseCode(response = doConnect(opts)); - - // return asynchronous parse of result. - return result = graphResults(response); - - } finally { - if (result == null) { - // Consume entity if bad response. - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException ex) { - } - } - } + return graphResults(opts, null); + +// try { +// // check response in try. +// checkResponseCode(response = doConnect(opts)); +// +// // return asynchronous parse of result. +// return result = graphResults(response); +// +// } finally { +// if (result == null) { +// // Consume entity if bad response. +// try { +// EntityUtils.consume(response.getEntity()); +// } catch (IOException ex) { +// } +// } +// } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2013-09-28 18:35:32
|
Revision: 7421 http://bigdata.svn.sourceforge.net/bigdata/?rev=7421&view=rev Author: mrpersonick Date: 2013-09-28 18:35:26 +0000 (Sat, 28 Sep 2013) Log Message: ----------- remote query cancellation - intermediate commit 3 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:29:41 UTC (rev 7420) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:35:26 UTC (rev 7421) @@ -41,6 +41,7 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import javax.xml.parsers.SAXParser; @@ -1674,7 +1675,7 @@ tqrImpl = new TupleQueryResultImpl(list, cursor) { - transient boolean done = false; + final AtomicBoolean notDone = new AtomicBoolean(true); @Override public boolean hasNext() throws QueryEvaluationException { @@ -1683,7 +1684,7 @@ if (hasNext == false) { - done = true; + notDone.set(false); } @@ -1696,7 +1697,7 @@ super.close(); - if (!done) { + if (notDone.compareAndSet(true, false)) { try { cancel(queryId); @@ -1704,8 +1705,6 @@ throw new QueryEvaluationException(ex); } - done = true; - } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2013-09-28 18:30:02
|
Revision: 7420 http://bigdata.svn.sourceforge.net/bigdata/?rev=7420&view=rev Author: mrpersonick Date: 2013-09-28 18:29:41 +0000 (Sat, 28 Sep 2013) Log Message: ----------- remote query cancellation - intermediate commit 2 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:23:26 UTC (rev 7419) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:29:41 UTC (rev 7420) @@ -1621,20 +1621,13 @@ public TupleQueryResult tupleResults(final ConnectOptions opts, final UUID queryId) throws Exception { + HttpResponse response = null; HttpEntity entity = null; BackgroundTupleResult result = null; - boolean needToCancel = false; + TupleQueryResultImpl tqrImpl = null; try { - /* - * If we put this after the doConnect we risk an interruption in - * between the doConnect and the setting the flag to true, which - * would result in a query running on the server that should have - * been canceled. - */ - needToCancel = true; - - final HttpResponse response = doConnect(opts); + response = doConnect(opts); checkResponseCode(response); @@ -1679,7 +1672,7 @@ final List<String> list = new ArrayList<String>( result.getBindingNames()); - final TupleQueryResultImpl tqrImpl = new TupleQueryResultImpl(list, cursor) { + tqrImpl = new TupleQueryResultImpl(list, cursor) { transient boolean done = false; @@ -1719,8 +1712,6 @@ }; - needToCancel = false; - return tqrImpl; // final TupleQueryResultBuilder handler = new TupleQueryResultBuilder(); @@ -1742,7 +1733,7 @@ } catch (IOException ex) { } } - if (needToCancel) { + if (response != null && tqrImpl == null) { try { cancel(queryId); } catch(Exception ex) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2013-09-28 18:23:33
|
Revision: 7419 http://bigdata.svn.sourceforge.net/bigdata/?rev=7419&view=rev Author: mrpersonick Date: 2013-09-28 18:23:26 +0000 (Sat, 28 Sep 2013) Log Message: ----------- remote query cancellation - intermediate commit 1 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/IPreparedSparqlUpdate.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java 2013-09-26 14:52:49 UTC (rev 7418) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/StatusServlet.java 2013-09-28 18:23:26 UTC (rev 7419) @@ -151,7 +151,7 @@ * The name of a request parameter whose value is the {@link UUID} of a * top-level query. */ - private static final String QUERY_ID = "queryId"; + public static final String QUERY_ID = "queryId"; /** * The name of a request parameter used to cancel a running query. At least @@ -160,7 +160,7 @@ * * @see #QUERY_ID */ - static final String CANCEL_QUERY = "cancelQuery"; + public static final String CANCEL_QUERY = "cancelQuery"; /** * Request a snapshot of the journal (HA only). The snapshot will be written Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/IPreparedSparqlUpdate.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/IPreparedSparqlUpdate.java 2013-09-26 14:52:49 UTC (rev 7418) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/IPreparedSparqlUpdate.java 2013-09-28 18:23:26 UTC (rev 7419) @@ -27,6 +27,8 @@ package com.bigdata.rdf.sail.webapp.client; +import java.util.UUID; + /** * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ @@ -34,5 +36,7 @@ public interface IPreparedSparqlUpdate { void evaluate() throws Exception; + + UUID getQueryId(); } \ No newline at end of file Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-26 14:52:49 UTC (rev 7418) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/client/RemoteRepository.java 2013-09-28 18:23:26 UTC (rev 7419) @@ -74,6 +74,7 @@ import org.openrdf.model.impl.ValueFactoryImpl; import org.openrdf.query.BindingSet; import org.openrdf.query.GraphQueryResult; +import org.openrdf.query.QueryEvaluationException; import org.openrdf.query.TupleQueryResult; import org.openrdf.query.TupleQueryResultHandlerBase; import org.openrdf.query.impl.MapBindingSet; @@ -97,6 +98,8 @@ import org.xml.sax.Attributes; import org.xml.sax.ext.DefaultHandler2; +import com.bigdata.rdf.sail.webapp.StatusServlet; + // Note: Do not import. Not part of the bigdata-client.jar // //import com.bigdata.rdf.sparql.ast.service.RemoteServiceOptions; @@ -529,9 +532,9 @@ final ConnectOptions opts = newUpdateConnectOptions(); - opts.addRequestParam("cancelQuery"); + opts.addRequestParam(StatusServlet.CANCEL_QUERY); - opts.addRequestParam("queryId", queryId.toString()); + opts.addRequestParam(StatusServlet.QUERY_ID, queryId.toString()); checkResponseCode(doConnect(opts)); @@ -1000,32 +1003,13 @@ } + @Override public TupleQueryResult evaluate() throws Exception { - HttpResponse response = null; -// try { - setupConnectOptions(); - checkResponseCode(response = doConnect(opts)); + return tupleResults(opts, getQueryId()); - return tupleResults(response); - -// } finally { -// -// try { -// -// if (response != null) -// EntityUtils.consume(response.getEntity()); -// -// } catch (Exception ex) { -// -// log.warn(ex); -// -// } -// -// } - } } @@ -1556,7 +1540,7 @@ HttpEntity entity = null; BackgroundTupleResult result = null; try { - + entity = response.getEntity(); final String contentType = entity.getContentType().getValue(); @@ -1624,6 +1608,151 @@ } /** + * Extracts the solutions from a SPARQL query. + * + * @param response + * The connection from which to read the results. + * + * @return The results. + * + * @throws Exception + * If anything goes wrong. + */ + public TupleQueryResult tupleResults(final ConnectOptions opts, final UUID queryId) + throws Exception { + + HttpEntity entity = null; + BackgroundTupleResult result = null; + boolean needToCancel = false; + try { + + /* + * If we put this after the doConnect we risk an interruption in + * between the doConnect and the setting the flag to true, which + * would result in a query running on the server that should have + * been canceled. + */ + needToCancel = true; + + final HttpResponse response = doConnect(opts); + + checkResponseCode(response); + + entity = response.getEntity(); + + final String contentType = entity.getContentType().getValue(); + + final MiniMime mimeType = new MiniMime(contentType); + + final TupleQueryResultFormat format = TupleQueryResultFormat + .forMIMEType(mimeType.getMimeType()); + + if (format == null) + throw new IOException( + "Could not identify format for service response: serviceURI=" + + sparqlEndpointURL + ", contentType=" + contentType + + " : response=" + getResponseBody(response)); + + final TupleQueryResultParserFactory parserFactory = TupleQueryResultParserRegistry + .getInstance().get(format); + + if (parserFactory == null) + throw new IOException( + "No parser for format for service response: serviceURI=" + + sparqlEndpointURL + ", contentType=" + contentType + + ", format=" + format + " : response=" + + getResponseBody(response)); + + final TupleQueryResultParser parser = parserFactory.getParser(); + + final InputStream in = entity.getContent(); + + result = new BackgroundTupleResult(parser, in, entity); + + executor.execute(result); + + final MapBindingSet bindings = new MapBindingSet(); + + final InsertBindingSetCursor cursor = + new InsertBindingSetCursor(result, bindings); + + final List<String> list = new ArrayList<String>( + result.getBindingNames()); + + final TupleQueryResultImpl tqrImpl = new TupleQueryResultImpl(list, cursor) { + + transient boolean done = false; + + @Override + public boolean hasNext() throws QueryEvaluationException { + + final boolean hasNext = super.hasNext(); + + if (hasNext == false) { + + done = true; + + } + + return hasNext; + + } + + @Override + public synchronized void close() throws QueryEvaluationException { + + super.close(); + + if (!done) { + + try { + cancel(queryId); + } catch (Exception ex) { + throw new QueryEvaluationException(ex); + } + + done = true; + + } + + }; + + }; + + needToCancel = false; + + return tqrImpl; + +// final TupleQueryResultBuilder handler = new TupleQueryResultBuilder(); +// +// parser.setTupleQueryResultHandler(handler); +// +// parser.parse(entity.getContent()); +// +// // done. +// return handler.getQueryResult(); + + } finally { + +// // terminate the http connection. +// response.disconnect(); + if (result == null) { + try { + EntityUtils.consume(entity); + } catch (IOException ex) { } + } + + if (needToCancel) { + try { + cancel(queryId); + } catch(Exception ex) { } + } + + } + + } + + /** * Builds a graph from an RDF result set (statements, not binding sets). * * @param response This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2013-09-26 14:52:57
|
Revision: 7418 http://bigdata.svn.sourceforge.net/bigdata/?rev=7418&view=rev Author: jeremy_carroll Date: 2013-09-26 14:52:49 +0000 (Thu, 26 Sep 2013) Log Message: ----------- Test and fix for optimizing optionals with ALPP. trac746 Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTComplexOptionalOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/sparql/AbstractBigdataExprBuilderTestCase.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTComplexOptionalOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTComplexOptionalOptimizer.java 2013-09-21 12:39:31 UTC (rev 7417) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTComplexOptionalOptimizer.java 2013-09-26 14:52:49 UTC (rev 7418) @@ -36,6 +36,7 @@ import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IVariable; import com.bigdata.rdf.sparql.ast.ASTBase; +import com.bigdata.rdf.sparql.ast.ArbitraryLengthPathNode; import com.bigdata.rdf.sparql.ast.AssignmentNode; import com.bigdata.rdf.sparql.ast.FilterNode; import com.bigdata.rdf.sparql.ast.GraphPatternGroup; @@ -346,7 +347,8 @@ || t instanceof NamedSubqueryInclude || t instanceof SubqueryRoot || t instanceof ServiceNode - || t instanceof UnionNode) { + || t instanceof UnionNode + || t instanceof ArbitraryLengthPathNode ) { // Moved to the named subquery. // move.add(t); group.removeChild(t); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java 2013-09-21 12:39:31 UTC (rev 7417) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/TestASTNamedSubqueryOptimizer.java 2013-09-26 14:52:49 UTC (rev 7418) @@ -27,17 +27,28 @@ package com.bigdata.rdf.sparql.ast.optimizers; +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.LinkedList; +import org.apache.commons.io.IOUtils; import org.openrdf.model.impl.URIImpl; import org.openrdf.model.vocabulary.RDF; import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.MalformedQueryException; import org.openrdf.query.algebra.StatementPattern.Scope; +import com.bigdata.bop.BOpUtility; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IVariable; import com.bigdata.bop.Var; import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.sail.sparql.Bigdata2ASTSPARQLParser; +import com.bigdata.rdf.sail.sparql.TestSubqueryPatterns; +import com.bigdata.rdf.sail.sparql.ast.ParseException; +import com.bigdata.rdf.sail.sparql.ast.TokenMgrError; import com.bigdata.rdf.sparql.ast.ASTContainer; import com.bigdata.rdf.sparql.ast.AbstractASTEvaluationTestCase; import com.bigdata.rdf.sparql.ast.ConstantNode; @@ -52,6 +63,7 @@ import com.bigdata.rdf.sparql.ast.StatementPatternNode; import com.bigdata.rdf.sparql.ast.StaticAnalysis; import com.bigdata.rdf.sparql.ast.SubqueryRoot; +import com.bigdata.rdf.sparql.ast.ValueExpressionNode; import com.bigdata.rdf.sparql.ast.VarNode; import com.bigdata.rdf.sparql.ast.eval.AST2BOpContext; import com.bigdata.rdf.vocab.decls.FOAFVocabularyDecl; @@ -830,4 +842,33 @@ } + + /** + * Unit test for WITH {subquery} AS "name" and INCLUDE. The WITH must be in + * the top-level query. + * + * This is specifically for Trac 746 which crashed out during optimize. + * So the test simply runs that far, and does not verify anything + * other than the ability to optimize without an exception + * @throws IOException + */ + public void test_namedSubquery746() throws MalformedQueryException, + TokenMgrError, ParseException, IOException { + + final String sparql = IOUtils.toString(getClass().getResourceAsStream("ticket746.txt")); + + + final QueryRoot ast = new Bigdata2ASTSPARQLParser(store).parseQuery2(sparql, + baseURI).getOriginalAST(); + + + final IASTOptimizer rewriter = new DefaultOptimizerList(); + + final AST2BOpContext context = new AST2BOpContext(new ASTContainer( + ast), store); + rewriter.optimize(context, ast/* queryNode */, null); + + + } + } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/optimizers/ticket746.txt 2013-09-26 14:52:49 UTC (rev 7418) @@ -0,0 +1,35 @@ +base <http://example.org/> +prefix sys: </bdm/api/kbobject/sys:> +prefix base: </bdm/api/kbobject/base:> +prefix syapse: </graph/syapse#> +prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> +prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + +SELECT * + +WITH { +SELECT * + +WHERE { + + OPTIONAL { + base:disease syapse:hasLiteralProperty $j2 . + ?Sample_A $j2 ?j1 + } + OPTIONAL { + base:species syapse:hasLiteralProperty $j4 . + ?Sample_A $j4 ?j3 + } + OPTIONAL { + ?Sample_A sys:name ?j5 + } + ?Sample_A rdf:type / rdfs:subClassOf * base:MammalianCellLineSample +} + +} AS %__UserQuery + +WHERE { + +INCLUDE %__UserQuery + +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/sparql/AbstractBigdataExprBuilderTestCase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/sparql/AbstractBigdataExprBuilderTestCase.java 2013-09-21 12:39:31 UTC (rev 7417) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/test/com/bigdata/rdf/sail/sparql/AbstractBigdataExprBuilderTestCase.java 2013-09-26 14:52:49 UTC (rev 7418) @@ -237,7 +237,7 @@ /** * Applies the {@link Bigdata2ASTSPARQLParser}. */ - protected QueryRoot parse(final String queryStr, final String baseURI) + public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final QueryRoot ast = new Bigdata2ASTSPARQLParser(tripleStore).parseQuery2(queryStr, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-21 12:39:37
|
Revision: 7417 http://bigdata.svn.sourceforge.net/bigdata/?rev=7417&view=rev Author: thompsonbry Date: 2013-09-21 12:39:31 +0000 (Sat, 21 Sep 2013) Log Message: ----------- added PRE tags around the examples in the test class javadoc. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTwoPropertyPaths734.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTwoPropertyPaths734.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTwoPropertyPaths734.java 2013-09-21 12:36:13 UTC (rev 7416) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTwoPropertyPaths734.java 2013-09-21 12:39:31 UTC (rev 7417) @@ -28,47 +28,45 @@ /** * Tests concerning: - * + * <pre> SELECT ?A WHERE { ?A rdf:type / rdfs:subClassOf * <os:ClassA> ; rdf:value ?B . ?B rdf:type / rdfs:subClassOf * <os:ClassB> . } - +</pre> There is a work-around which is to replace a * with a UNION of a zero and a + - +<pre> { { ?B rdf:type <os:ClassB> } UNION { ?B rdf:type / rdfs:subClassOf + <os:ClassB> } } - +</pre> In property-path-734-B-none.rq, this is taken as the following variant: - +<pre> { { ?A rdf:type / rdfs:subClassOf ? <os:ClassA> } UNION { ?A rdf:type / rdfs:subClassOf / rdfs:subClassOf + <os:ClassA> } } - +</pre> and in property-path-734-B-workaround2.rq it is taken to (the broken): - - +<pre> ?A rdf:type / ( rdfs:subClassOf ? | ( rdfs:subClassOf + / rdfs:subClassOf ) ) <os:ClassA> . +</pre> - and in property-path-734-B-workaround3.rq it is taken to (the working): - - +<pre> ?A ( ( rdf:type / rdfs:subClassOf ? ) | ( rdf:type / rdfs:subClassOf + / rdfs:subClassOf ) ) <os:ClassA> . +</pre> - */ public class TestTwoPropertyPaths734 extends AbstractDataDrivenSPARQLTestCase { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-21 12:36:21
|
Revision: 7416 http://bigdata.svn.sourceforge.net/bigdata/?rev=7416&view=rev Author: thompsonbry Date: 2013-09-21 12:36:13 +0000 (Sat, 21 Sep 2013) Log Message: ----------- Bug fix for #732 (describe statement limit does not work). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/CBD.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/CBD.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/CBD.java 2013-09-20 17:02:38 UTC (rev 7415) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/CBD.java 2013-09-21 12:36:13 UTC (rev 7416) @@ -307,7 +307,7 @@ final boolean cutoffRounds = nrounds >= describeIterationLimit; - final boolean cutoffStatements =nrounds >= describeStatementLimit; + final boolean cutoffStatements = nstmts >= describeStatementLimit; return cutoffRounds && cutoffStatements; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2013-09-20 17:02:45
|
Revision: 7415 http://bigdata.svn.sourceforge.net/bigdata/?rev=7415&view=rev Author: mrpersonick Date: 2013-09-20 17:02:38 +0000 (Fri, 20 Sep 2013) Log Message: ----------- fixed the slice service factory to correctly build the toKey in the presence of RangeBOp Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/SliceServiceFactory.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/SliceServiceFactory.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/SliceServiceFactory.java 2013-09-17 14:16:25 UTC (rev 7414) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/SliceServiceFactory.java 2013-09-20 17:02:38 UTC (rev 7415) @@ -416,6 +416,10 @@ // Handle a range. final RangeBOp rangeBOp = sp.getRange() != null ? sp.getRange().getRangeBOp() : null; + if (log.isTraceEnabled()) { + log.trace("range: " + rangeBOp); + } + // Create the predicate. @SuppressWarnings("unchecked") final IPredicate<ISPO> pred = (IPredicate<ISPO>) @@ -461,7 +465,7 @@ startIndex = indexOf(ndx, startKey); - final byte[] endKey = SuccessorUtil.successor(startKey.clone()); + final byte[] endKey = keyOrder.getToKey(KeyBuilder.newInstance(), pred); //SuccessorUtil.successor(startKey.clone()); endIndex = indexOf(ndx, endKey); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-17 14:16:33
|
Revision: 7414 http://bigdata.svn.sourceforge.net/bigdata/?rev=7414&view=rev Author: thompsonbry Date: 2013-09-17 14:16:25 +0000 (Tue, 17 Sep 2013) Log Message: ----------- Bug fix for #743 (AbstractTripleStore.destroy() does not filter for correct prefix). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/IIndexStore.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/relation/AbstractResource.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/service/ListIndicesTask.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreDestroy.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/IIndexStore.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/IIndexStore.java 2013-09-13 19:35:09 UTC (rev 7413) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/IIndexStore.java 2013-09-17 14:16:25 UTC (rev 7414) @@ -62,7 +62,13 @@ * Iterator visits the names of all indices spanned by the given prefix. * * @param prefix - * The prefix (optional). + * The prefix (optional). When given, this MUST include a + * <code>.</code> if you want to restrict the scan to only those + * indices in a given namespace. Otherwise you can find indices + * in <code>kb2</code> if you provide the prefix <code>kb</code> + * where both kb and kb2 are namespaces since the indices spanned + * by <code>kb</code> would include both <code>kb.xyz</code> and + * <code>kb2.xyx</code>. * @param timestamp * A timestamp which represents either a possible commit time on * the store or a read-only transaction identifier. Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java 2013-09-13 19:35:09 UTC (rev 7413) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/journal/Name2Addr.java 2013-09-17 14:16:25 UTC (rev 7414) @@ -1600,6 +1600,14 @@ * {@link Name2Addr#getKey(String)} and * {@link Name2AddrTupleSerializer#serializeKey(Object)} * implementation (depending on how the keys are being encoded). + * <p> + * Update: See <a + * href="https://sourceforge.net/apps/trac/bigdata/ticket/743"> + * AbstractTripleStore.destroy() does not filter for correct prefix + * </a> as well. Maybe the problem is just that we need to have the + * "." appended to the namespace. This could be something that is + * done automatically if the caller does not take care of it + * themselves. */ public static final Iterator<String> indexNameScan(final String prefix, final IIndex n2a) { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/relation/AbstractResource.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/relation/AbstractResource.java 2013-09-13 19:35:09 UTC (rev 7413) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/relation/AbstractResource.java 2013-09-17 14:16:25 UTC (rev 7414) @@ -694,8 +694,8 @@ */ { - final Iterator<String> itr = indexManager.indexNameScan(namespace, - timestamp); + final Iterator<String> itr = indexManager.indexNameScan(namespace + + ".", timestamp); while (itr.hasNext()) { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/service/ListIndicesTask.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/service/ListIndicesTask.java 2013-09-13 19:35:09 UTC (rev 7413) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/service/ListIndicesTask.java 2013-09-17 14:16:25 UTC (rev 7414) @@ -54,6 +54,13 @@ * @param namespace * The namespace prefix for the indices to be returned (may be an * empty string to return the names of all registered indices). + * <p> + * Note: This SHOULD include a "." if you want to restrict the + * scan to only those indices in a given namespace. Otherwise you + * can find indices in <code>kb2</code> if you provide the prefix + * <code>kb</code> and both kb and kb2 are namespaces since the + * indices spanned by <code>kb</code> would include both + * <code>kb.xyz</code> and <code>kb2.xyx</code>. */ public ListIndicesTask(final long ts, final String namespace) { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreDestroy.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreDestroy.java 2013-09-13 19:35:09 UTC (rev 7413) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreDestroy.java 2013-09-17 14:16:25 UTC (rev 7414) @@ -37,6 +37,7 @@ import com.bigdata.journal.ITx; import com.bigdata.rdf.lexicon.LexiconKeyOrder; import com.bigdata.rdf.spo.SPOKeyOrder; +import com.bigdata.relation.AbstractResource; import com.bigdata.relation.RelationSchema; import com.bigdata.relation.locator.DefaultResourceLocator; import com.bigdata.sparse.ITPS; @@ -282,4 +283,227 @@ } + /** + * Verify the namespace prefix for the triple store is imposed correctly in + * {@link AbstractResource#destroy()}. Create two KBs such that the + * namespace for one instance is a prefix of the namespace for the other + * instance, e.g., + * + * <pre> + * kb + * kb1 + * </pre> + * + * Verify that destroying <code>kb</code> does not cause the indices for + * <code>kb1</code> to be destroyed. + * + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/743"> + * AbstractTripleStore.destroy() does not filter for correct prefix + * </a> + */ + public void test_destroyTwo() { + + final String namespace = "kb"; + final String namespaceLexiconRelation = namespace + ".lex"; + final String namespaceSPORelation = namespace + ".spo"; + final String lexiconRelationIndexName = namespaceLexiconRelation + "." + + LexiconKeyOrder.TERM2ID.getIndexName(); + final String primaryStatementIndexName = namespaceSPORelation + "." + + SPOKeyOrder.SPO.getIndexName(); + + final String namespace1 = "kb1"; + final String namespaceLexiconRelation1 = namespace1 + ".lex"; + final String namespaceSPORelation1 = namespace1 + ".spo"; + final String lexiconRelationIndexName1 = namespaceLexiconRelation1 + + "." + LexiconKeyOrder.TERM2ID.getIndexName(); + final String primaryStatementIndexName1 = namespaceSPORelation1 + "." + + SPOKeyOrder.SPO.getIndexName(); + + final Properties properties = new Properties(); + properties.setProperty(com.bigdata.journal.Options.CREATE_TEMP_FILE, "true"); + properties.setProperty(AbstractTripleStore.Options.BUFFER_MODE,BufferMode.DiskWORM.toString()); + properties.setProperty(AbstractTripleStore.Options.TRIPLES_MODE,"true"); + + final AbstractTripleStore kb = getStore(properties); + + final IIndexManager indexManager = kb.getIndexManager(); + + try { + + assertEquals(namespace, kb.getNamespace()); + + final AbstractTripleStore kb1 = new LocalTripleStore(indexManager, + namespace1, ITx.UNISOLATED, properties); + kb1.create(); + + // make the tripleStore dirty so commit() will do something. + kb.addTerm(kb.getValueFactory().createLiteral("bigdata")); + kb1.addTerm(kb.getValueFactory().createLiteral("bigdata")); + + // Verify post-conditions of the created KBs. + { + + /* + * Verify that both triple store declarations exist in the GRS. + * + * Note: Will be in lexical order for Unicode. + */ + final String[] namespaces = getNamespaces(indexManager) + .toArray(new String[] {}); + assertEquals(new String[] { namespace, namespace1 }, namespaces); + + /* + * Verify that the unislolated versions of each triple stores is + * the same reference that we obtained above when that triple + * store was created. + */ + assertTrue(kb == indexManager.getResourceLocator().locate( + kb.getNamespace(), ITx.UNISOLATED)); + assertTrue(kb1 == indexManager.getResourceLocator().locate( + kb1.getNamespace(), ITx.UNISOLATED)); + + /* Verify lexicon relations exist. */ + assertTrue(kb.getLexiconRelation() == indexManager + .getResourceLocator().locate(namespaceLexiconRelation, + ITx.UNISOLATED)); + assertTrue(kb1.getLexiconRelation() == indexManager + .getResourceLocator().locate(namespaceLexiconRelation1, + ITx.UNISOLATED)); + + /* Verify SPO relations exist. */ + assertTrue(kb.getSPORelation() == indexManager + .getResourceLocator().locate(namespaceSPORelation, + ITx.UNISOLATED)); + assertTrue(kb1.getSPORelation() == indexManager + .getResourceLocator().locate(namespaceSPORelation1, + ITx.UNISOLATED)); + + /* Verify lexicon index exists. */ + assertNotNull(indexManager.getIndex(lexiconRelationIndexName, + ITx.UNISOLATED)); + assertNotNull(indexManager.getIndex(lexiconRelationIndexName1, + ITx.UNISOLATED)); + + /* Verify primary SPO index exists. */ + assertNotNull(indexManager.getIndex(primaryStatementIndexName, + ITx.UNISOLATED)); + assertNotNull(indexManager.getIndex(primaryStatementIndexName1, + ITx.UNISOLATED)); + + } + + /* Commit. */ + final long commitTime = kb.commit(); + assertTrue(commitTime > 0); + + /* + * Destroy the triple store whose namespace is a prefix of the 2nd + * triple store namespace. + */ + { + kb.destroy(); + + // global row store entry is gone. + final String[] namespaces = getNamespaces(indexManager).toArray( + new String[] {}); + assertEquals(new String[] { namespace1 }, namespaces); + + // resources can not be located. + assertTrue(null == indexManager.getResourceLocator().locate( + namespace, ITx.UNISOLATED)); + assertTrue(null == indexManager.getResourceLocator().locate( + namespaceLexiconRelation, ITx.UNISOLATED)); + assertTrue(null == indexManager.getResourceLocator().locate( + namespaceSPORelation, ITx.UNISOLATED)); + + // indicies are gone. + assertNull(indexManager.getIndex(lexiconRelationIndexName, + ITx.UNISOLATED)); + assertNull(indexManager.getIndex(primaryStatementIndexName, + ITx.UNISOLATED)); + + // The committed version of the triple store remains visible. + assertNotNull(indexManager.getResourceLocator().locate( + namespace, commitTime - 1)); + } + + /* + * Verify that the other kb still exists, including its GRS + * declaration and its indices. + */ + { + + /* + * Verify that the triple store declaration exists in the GRS. + * + * Note: Will be in lexical order for Unicode. + */ + final String[] namespaces = getNamespaces(indexManager).toArray( + new String[] {}); + assertEquals(new String[] { namespace1 }, namespaces); + + /* + * Verify that the unislolated versions of each triple stores is the + * same reference that we obtained above when that triple store was + * created. + */ + assertTrue(kb1 == indexManager.getResourceLocator().locate( + kb1.getNamespace(), ITx.UNISOLATED)); + + /* Verify lexicon relations exist. */ + assertTrue(kb1.getLexiconRelation() == indexManager + .getResourceLocator().locate(namespaceLexiconRelation1, + ITx.UNISOLATED)); + + /* Verify SPO relations exist. */ + assertTrue(kb1.getSPORelation() == indexManager + .getResourceLocator().locate(namespaceSPORelation1, + ITx.UNISOLATED)); + + /* Verify lexicon index exists. */ + assertNotNull(indexManager.getIndex(lexiconRelationIndexName1, + ITx.UNISOLATED)); + + /* Verify primary SPO index exists. */ + assertNotNull(indexManager.getIndex(primaryStatementIndexName1, + ITx.UNISOLATED)); + + } + + /* + * Destroy the other triple store. + */ + { + kb1.destroy(); + + // global row store entry is gone. + assertTrue(getNamespaces(indexManager).isEmpty()); + + // resources can not be located. + assertTrue(null == indexManager.getResourceLocator().locate( + namespace1, ITx.UNISOLATED)); + assertTrue(null == indexManager.getResourceLocator().locate( + namespaceLexiconRelation1, ITx.UNISOLATED)); + assertTrue(null == indexManager.getResourceLocator().locate( + namespaceSPORelation1, ITx.UNISOLATED)); + + // indicies are gone. + assertNull(indexManager.getIndex(lexiconRelationIndexName1, + ITx.UNISOLATED)); + assertNull(indexManager.getIndex(primaryStatementIndexName1, + ITx.UNISOLATED)); + + // The committed version of the triple store remains visible. + assertNotNull(indexManager.getResourceLocator().locate( + namespace1, commitTime - 1)); + } + + } finally { + + indexManager.destroy(); + + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-13 19:35:16
|
Revision: 7413 http://bigdata.svn.sourceforge.net/bigdata/?rev=7413&view=rev Author: thompsonbry Date: 2013-09-13 19:35:09 +0000 (Fri, 13 Sep 2013) Log Message: ----------- The code was not closing the digest file handles (resource leak). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/DumpLogDigests.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/DumpLogDigests.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/DumpLogDigests.java 2013-09-13 14:42:08 UTC (rev 7412) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/journal/jini/ha/DumpLogDigests.java 2013-09-13 19:35:09 UTC (rev 7413) @@ -385,13 +385,15 @@ log.warn("Found log file: " + file.getName()); // compute file digest + final MessageDigest digest = MessageDigest + .getInstance("MD5"); final IHALogReader r = nexus.getReader(cur); - - final MessageDigest digest = MessageDigest - .getInstance("MD5"); - - r.computeDigest(digest); - + try { + r.computeDigest(digest); + } finally { + // ensure file is closed. + r.close(); + } infos.add(new HALogInfo(cur, r.isLive(), digest .digest())); } catch (FileNotFoundException fnf) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-13 14:42:17
|
Revision: 7412 http://bigdata.svn.sourceforge.net/bigdata/?rev=7412&view=rev Author: thompsonbry Date: 2013-09-13 14:42:08 +0000 (Fri, 13 Sep 2013) Log Message: ----------- Changes to the sampling logic. The BD and SAIL implementations no longer include self-loops into the set from which the vertex sample is drawn. The sampling logic has been modified to look at whether the algorithm wants to visit in-edges, out-edges, or all edges for GATHER. If there is no gather (no-edges), then it looks at the SCATTER phase. The samples are then only drawn from a distribution for the kinds of edges that will be traversed in the phase phase of the algorithm (either scatter or gather). The sampling logic was modified to drop vertices that have zero-degree with respect to the type(s) of edges that are being sampled. The GASRunner has been modified to drop vertices that are not connected to at least one other vertex by the execution of the GASProgram (the cumulative frontier size is one) and to report the number of such unconnected vertices that were found in the sample. See #629 (graph mining) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java 2013-09-13 12:41:49 UTC (rev 7411) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java 2013-09-13 14:42:08 UTC (rev 7412) @@ -230,11 +230,11 @@ boolean modified = false; if (o instanceof URI) { // Edge - modified|=get(s, true/* create */).addOutEdge(st); - modified|=get(o, true/* create */).addInEdge(st); + modified |= get(s, true/* create */).addOutEdge(st); + modified |= get(o, true/* create */).addInEdge(st); } else { // Property value. - modified|=get(s, true/* create */).addAttrib(st); + modified |= get(s, true/* create */).addAttrib(st); } return modified; @@ -341,12 +341,27 @@ final VertexDistribution sample = new VertexDistribution(r); - for (Value v : g.vertices.keySet()) { + for (RAMGraph.Vertex vertex : g.vertices.values()) { + final Value v = vertex.v; + if (v instanceof Resource) { - sample.addSample((Resource) v); + /* + * FIXME This is not ignoring self-loops. Realistically, we + * want to include them in the data since they are part of + * the data, but we do not want to consider them in samples + * since they do not actually go anywhere. The SAIL and BD + * implementations of this method filter out self-loops, but + * this implementation does not. + */ + + if (vertex.getInEdgeCount() > 0) + sample.addInEdgeSample((Resource) v); + if (vertex.getOutEdgeCount() > 0) + sample.addOutEdgeSample((Resource) v); + } } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java 2013-09-13 12:41:49 UTC (rev 7411) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java 2013-09-13 14:42:08 UTC (rev 7412) @@ -246,10 +246,17 @@ continue; } - sample.addSample(st.getSubject()); + if (st.getSubject().equals(st.getObject())) { - sample.addSample((Resource) st.getObject()); + // ignore self-loops. + continue; + } + + sample.addOutEdgeSample(st.getSubject()); + + sample.addInEdgeSample((Resource) st.getObject()); + } } finally { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-13 12:41:49 UTC (rev 7411) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-13 14:42:08 UTC (rev 7412) @@ -9,6 +9,7 @@ import org.apache.log4j.Logger; import org.openrdf.model.Value; +import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASEngine; import com.bigdata.rdf.graph.IGASProgram; @@ -415,10 +416,24 @@ final VertexDistribution dist = graphAccessor.getDistribution(opt.r); - final Value[] sampled = dist.getWeightedSample(opt.nsamples); + // Assume that a GATHER will be done for each starting vertex. + EdgesEnum edges = gasProgram.getGatherEdges(); + if (edges == EdgesEnum.NoEdges) { + + // If no GATHER is performed, then use the SCATTER edges. + edges = gasProgram.getScatterEdges(); + + } + + final Value[] sampled = dist.getWeightedSample(opt.nsamples, + edges); + final IGASStats total = new GASStats(); + // #of vertices that were not connected for that analytic. + long nunconnected = 0; + for (int i = 0; i < sampled.length; i++) { final Value startingVertex = sampled[i]; @@ -427,6 +442,19 @@ final IGASStats stats = (IGASStats) gasContext.call(); + if (stats.getFrontierSize() == 1) { + /* + * The starting vertex was not actually connected to any + * other vertices by the traversal performed by the GAS + * program. + */ + if (log.isInfoEnabled()) + log.info("Ignoring unconnected startingVertex: " + + startingVertex + ", stats=" + stats); + nunconnected++; + continue; + } + total.add(stats); if (log.isInfoEnabled()) { @@ -445,6 +473,7 @@ sb.append(", nsamples=" + opt.nsamples); // #desired samples sb.append(", nsampled=" + sampled.length);// #actually sampled sb.append(", distSize=" + dist.size());// #available for sampling. + sb.append(", nunconnected=" + nunconnected);// #unconnected vertices. sb.append(", nthreads=" + opt.nthreads); sb.append(", scheduler=" + ((GASState<VS, ES, ST>)gasState).getScheduler().getClass().getSimpleName()); sb.append(", gasEngine=" + gasEngine.getClass().getSimpleName()); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java 2013-09-13 12:41:49 UTC (rev 7411) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java 2013-09-13 14:42:08 UTC (rev 7412) @@ -23,6 +23,8 @@ import org.openrdf.model.Resource; +import com.bigdata.rdf.graph.EdgesEnum; + /** * Utility class for sampling vertices from a graph. * <p> @@ -47,16 +49,28 @@ * A sample. */ private static class VertexSample { - /** The frequence of the {@link Resource}. */ - public double f; /** The {@link Resource}. */ public final Resource v; + /** The #of the {@link Resource} occurring as the target of an in-edge. */ + public int in; + /** The #of the {@link Resource} occurring as the source of an out-edge. */ + public int out; - // /** The #of times the {@link Resource} has been selected. */ - // public int n; - public VertexSample(final double f, final Resource v) { - this.f = f; + /** + * + * @param v + * The resource. + * @param in + * The #of times this {@link Resource} has been observed as + * the target of an in-edge. + * @param out + * The #of times this {@link Resource} has been observed as + * the source of an out-edge. + */ + public VertexSample(final Resource v, final int in, final int out) { this.v = v; + this.in = in; + this.out = out; // this.n = 0; } } @@ -87,19 +101,19 @@ } /** - * Add a sample. + * Add a sample of a vertex having some out-edge. * * @param v * The vertex. */ - public void addSample(final Resource v) { + public void addOutEdgeSample(final Resource v) { VertexSample s = samples.get(v); if (s == null) { // new sample. - samples.put(v, s = new VertexSample(1d/* f */, v)); + samples.put(v, s = new VertexSample(v, 0/* in */, 1/* out */)); // indexOf that sample. indexOf.put(samples.size() - 1, s); @@ -109,6 +123,28 @@ } /** + * Add a sample of a vertex having some in-edge. + * + * @param v + * The vertex. + */ + public void addInEdgeSample(final Resource v) { + + VertexSample s = samples.get(v); + + if (s == null) { + + // new sample. + samples.put(v, s = new VertexSample(v, 1/* in */, 0/* out */)); + + // indexOf that sample. + indexOf.put(samples.size() - 1, s); + + } + + } + + /** * Return the #of samples in the distribution from which a called specified * number of samples may then drawn using a random sampling without * replacement technique. @@ -123,19 +159,35 @@ } /** - * Build a normalized vector over the sample frequences. The indices of the - * sample vector are correlated with the {@link #indexOf} map. The values in - * the normalized vector are in <code>[0:1]</code> and sum to - * <code>1.0</code>. + * Build a vector over the samples. The indices of the sample vector are + * correlated with the {@link #indexOf} map. + * + * @param edges + * Only vertice having the specified type(s) of edges will be + * included in the distribution. + * @param normalize + * When <code>true</code> the vector will be normalized such that + * the elements in the vector are in <code>[0:1]</code> and sum + * to <code>1.0</code>. When <code>false</code> the elements of + * the vector are the unnormalized sum of the #of edges of the + * specified type(s). + * + * @return The distribution vector over the samples. */ - double[] getNormVector() { + double[] getVector(final EdgesEnum edges, final boolean normalize) { - final double[] norm = new double[samples.size()]; + if (edges == null) + throw new IllegalArgumentException(); - if (norm.length == 0) { + if (edges == EdgesEnum.NoEdges) + throw new IllegalArgumentException(); + final double[] a = new double[samples.size()]; + + if (a.length == 0) { + // No samples. Avoid division by zero. - return norm; + return a; } @@ -145,18 +197,64 @@ for (VertexSample s : samples.values()) { - norm[i++] = sum += s.f; + final double d; + switch (edges) { + case InEdges: + d = s.in; + break; + case OutEdges: + d = s.out; + break; + case AllEdges: + d = (s.in + s.out); + break; + default: + throw new AssertionError(); + } + + if (d == 0) + continue; + if (normalize) { + a[i] = sum += d; + } else { + a[i] = d; + } + + i++; + } + final int nfound = i; - for (i = 0; i < norm.length; i++) { + if (nfound == 0) { + // Empty sample. + return new double[0]; + } + + if (normalize) { - norm[i] /= sum; + for (i = 0; i < a.length; i++) { + a[i] /= sum; + + } + } - return norm; + if (nfound < a.length) { + // Make the array dense. + + final double[] b = new double[nfound]; + + System.arraycopy(a/* src */, 0/* srcPos */, b/* dest */, + 0/* destPos */, nfound/* length */); + + return b; + } + + return a; + } /** @@ -165,10 +263,15 @@ * * @param desiredSampleSize * The desired sample size. + * @param edges + * The sample is taken from vertices having the specified type(s) + * of edges. Vertices with zero degree for the specified type(s) + * of edges will not be present in the returned sampled. * * @return The distinct samples that were found. */ - public Resource[] getWeightedSample(final int desiredSampleSize) { + public Resource[] getWeightedSample(final int desiredSampleSize, + final EdgesEnum edges) { if (samples.isEmpty()) { @@ -178,7 +281,7 @@ } // Build a normalized vector over the sample. - final double[] norm = getNormVector(); + final double[] norm = getVector(edges, true/* normalized */); // Maximum number of samples to attempt. final int limit = (int) Math.min(desiredSampleSize * 3L, @@ -218,10 +321,16 @@ * at random without regard to their frequency distribution. * * @param desiredSampleSize + * The desired sample size. + * @param edges + * The sample is taken from vertices having the specified type(s) + * of edges. Vertices with zero degree for the specified type(s) + * of edges will not be present in the returned sampled. * - * @return + * @return The distinct samples that were found. */ - public Resource[] getUnweightedSample(final int desiredSampleSize) { + public Resource[] getUnweightedSample(final int desiredSampleSize, + final EdgesEnum edges) { if (samples.isEmpty()) { @@ -230,6 +339,9 @@ } + // Build a vector over the sample. + final double[] vec = getVector(edges, true/* normalized */); + // Maximum number of samples to attempt. final int limit = (int) Math.min(desiredSampleSize * 3L, Integer.MAX_VALUE); @@ -239,11 +351,9 @@ // The selected samples. final Set<Resource> selected = new HashSet<Resource>(); - final int nsamples = this.samples.size(); - while (selected.size() < desiredSampleSize && round++ < limit) { - final int i = r.nextInt(nsamples); + final int i = r.nextInt(vec.length); final Resource v = indexOf.get(Integer.valueOf(i)).v; @@ -252,6 +362,23 @@ } return selected.toArray(new Resource[selected.size()]); + +// // The selected samples. +// final Set<Resource> selected = new HashSet<Resource>(); +// +// final int nsamples = this.samples.size(); +// +// while (selected.size() < desiredSampleSize && round++ < limit) { +// +// final int i = r.nextInt(nsamples); +// +// final Resource v = indexOf.get(Integer.valueOf(i)).v; +// +// selected.add(v); +// +// } +// +// return selected.toArray(new Resource[selected.size()]); } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java 2013-09-13 12:41:49 UTC (rev 7411) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java 2013-09-13 14:42:08 UTC (rev 7412) @@ -494,10 +494,17 @@ continue; } - sample.addSample((Resource) spo.s()); + if (spo.s().equals(spo.o())) { - sample.addSample((Resource) spo.o()); + // ignore self-loops. + continue; + } + + sample.addOutEdgeSample((Resource) spo.s()); + + sample.addInEdgeSample((Resource) spo.o()); + } return sample; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-13 12:41:56
|
Revision: 7411 http://bigdata.svn.sourceforge.net/bigdata/?rev=7411&view=rev Author: thompsonbry Date: 2013-09-13 12:41:49 +0000 (Fri, 13 Sep 2013) Log Message: ----------- javadoc Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/zookeeper/ZooKeeperAccessor.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/zookeeper/ZooKeeperAccessor.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/zookeeper/ZooKeeperAccessor.java 2013-09-13 11:19:30 UTC (rev 7410) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/java/com/bigdata/zookeeper/ZooKeeperAccessor.java 2013-09-13 12:41:49 UTC (rev 7411) @@ -35,11 +35,11 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.log4j.Logger; +import org.apache.zookeeper.KeeperException.SessionExpiredException; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; +import org.apache.zookeeper.Watcher.Event.KeeperState; import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.KeeperException.SessionExpiredException; -import org.apache.zookeeper.Watcher.Event.KeeperState; /** * Interface exposing a {@link ZooKeeper} client that may be transparently @@ -117,19 +117,26 @@ private volatile ZooKeeper zookeeper; /** - * The hosts parameter. + * The <code>hosts</code> parameter. */ public final String hosts; /** - * The session timeout parameter. + * The <code>session</code> timeout parameter (this is used by the client + * when establishing the connection to zookeeper - the negotiated timeout + * MAY be different and MAY change at each reconnect). + * + * @see ZooKeeper#getSessionTimeout() */ public final int sessionTimeout; /** * * @param hosts + * The <code>hosts</code> parameter. * @param sessionTimeout + * The <code>session</code> timeout parameter. + * * @throws InterruptedException * if the caller's thread is interrupted while awaiting a * zookeeper client connection. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-13 11:19:39
|
Revision: 7410 http://bigdata.svn.sourceforge.net/bigdata/?rev=7410&view=rev Author: thompsonbry Date: 2013-09-13 11:19:30 +0000 (Fri, 13 Sep 2013) Log Message: ----------- javadoc on the RAMGraphLoader exposed the size of the distribution in the GASRunner report. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java 2013-09-13 11:16:46 UTC (rev 7409) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java 2013-09-13 11:19:30 UTC (rev 7410) @@ -22,6 +22,17 @@ import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; import com.bigdata.rdf.graph.util.GraphLoader; +/** + * TODO Blank nodes have global scope. We should have a bnode resolution scope + * to the source document to be consistent with RDF semantics. This could be + * imposed through the {@link RAMStatementHandler}. + * + * TODO It is not possible to parallelize the load since the mutation operations + * on the {@link RAMGraph} assume a single writer (there is no built in + * synchronization). This makes load performance quite slow. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ public class RAMGraphLoader extends GraphLoader { private final RAMGraph g; Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-13 11:16:46 UTC (rev 7409) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-13 11:19:30 UTC (rev 7410) @@ -444,6 +444,7 @@ sb.append(", nseed=" + opt.seed); sb.append(", nsamples=" + opt.nsamples); // #desired samples sb.append(", nsampled=" + sampled.length);// #actually sampled + sb.append(", distSize=" + dist.size());// #available for sampling. sb.append(", nthreads=" + opt.nthreads); sb.append(", scheduler=" + ((GASState<VS, ES, ST>)gasState).getScheduler().getClass().getSimpleName()); sb.append(", gasEngine=" + gasEngine.getClass().getSimpleName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-13 11:16:54
|
Revision: 7409 http://bigdata.svn.sourceforge.net/bigdata/?rev=7409&view=rev Author: thompsonbry Date: 2013-09-13 11:16:46 +0000 (Fri, 13 Sep 2013) Log Message: ----------- added the distribution size to the GASRunner report - this is the #of samples in the distribution from which the specified number of samples are then drawn using a random sampling without replacement technique. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java 2013-09-12 21:28:54 UTC (rev 7408) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/VertexDistribution.java 2013-09-13 11:16:46 UTC (rev 7409) @@ -109,6 +109,20 @@ } /** + * Return the #of samples in the distribution from which a called specified + * number of samples may then drawn using a random sampling without + * replacement technique. + * + * @see #getUnweightedSample(int) + * @see #getWeightedSample(int) + */ + public int size() { + + return samples.size(); + + } + + /** * Build a normalized vector over the sample frequences. The indices of the * sample vector are correlated with the {@link #indexOf} map. The values in * the normalized vector are in <code>[0:1]</code> and sum to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:29:00
|
Revision: 7408 http://bigdata.svn.sourceforge.net/bigdata/?rev=7408&view=rev Author: thompsonbry Date: 2013-09-12 21:28:54 +0000 (Thu, 12 Sep 2013) Log Message: ----------- distinguished reporting of the #of desired samples and the #of samples actually collected. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-12 21:18:40 UTC (rev 7407) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/util/GASRunnerBase.java 2013-09-12 21:28:54 UTC (rev 7408) @@ -415,13 +415,13 @@ final VertexDistribution dist = graphAccessor.getDistribution(opt.r); - final Value[] samples = dist.getWeightedSample(opt.nsamples); + final Value[] sampled = dist.getWeightedSample(opt.nsamples); final IGASStats total = new GASStats(); - for (int i = 0; i < samples.length; i++) { + for (int i = 0; i < sampled.length; i++) { - final Value startingVertex = samples[i]; + final Value startingVertex = sampled[i]; gasState.init(startingVertex); @@ -431,7 +431,7 @@ if (log.isInfoEnabled()) { log.info("Run complete: vertex[" + i + "] of " - + samples.length + " : startingVertex=" + + sampled.length + " : startingVertex=" + startingVertex + ", stats(sample)=" + stats); } @@ -442,7 +442,8 @@ sb.append("TOTAL"); sb.append(": analytic=" + gasProgram.getClass().getSimpleName()); sb.append(", nseed=" + opt.seed); - sb.append(", nsamples=" + opt.nsamples); + sb.append(", nsamples=" + opt.nsamples); // #desired samples + sb.append(", nsampled=" + sampled.length);// #actually sampled sb.append(", nthreads=" + opt.nthreads); sb.append(", scheduler=" + ((GASState<VS, ES, ST>)gasState).getScheduler().getClass().getSimpleName()); sb.append(", gasEngine=" + gasEngine.getClass().getSimpleName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:18:47
|
Revision: 7407 http://bigdata.svn.sourceforge.net/bigdata/?rev=7407&view=rev Author: thompsonbry Date: 2013-09-12 21:18:40 +0000 (Thu, 12 Sep 2013) Log Message: ----------- was attemping to load directories as files.... Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:17:52 UTC (rev 7406) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:18:40 UTC (rev 7407) @@ -158,19 +158,20 @@ } + // recursion. loadGraph(fallback, f.toString()); } - } else { + // end of directory. + return; + } - is = new FileInputStream(file); + is = new FileInputStream(file); - // set for file as URI. - baseURI = file.toURI().toString(); + // set for file as URI. + baseURI = file.toURI().toString(); - } - } else { throw new FileNotFoundException( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:17:58
|
Revision: 7406 http://bigdata.svn.sourceforge.net/bigdata/?rev=7406&view=rev Author: thompsonbry Date: 2013-09-12 21:17:52 +0000 (Thu, 12 Sep 2013) Log Message: ----------- was attemping to load directories as files.... Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:16:12 UTC (rev 7405) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:17:52 UTC (rev 7406) @@ -162,13 +162,15 @@ } + } else { + + is = new FileInputStream(file); + + // set for file as URI. + baseURI = file.toURI().toString(); + } - is = new FileInputStream(file); - - // set for file as URI. - baseURI = file.toURI().toString(); - } else { throw new FileNotFoundException( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:16:19
|
Revision: 7405 http://bigdata.svn.sourceforge.net/bigdata/?rev=7405&view=rev Author: thompsonbry Date: 2013-09-12 21:16:12 +0000 (Thu, 12 Sep 2013) Log Message: ----------- again, skipping hidden files. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:12:09 UTC (rev 7404) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:16:12 UTC (rev 7405) @@ -139,12 +139,6 @@ if (file.exists()) { - if (file.isHidden()) { - if (log.isDebugEnabled()) - log.debug("Skipping hidden file: " + file); - return; - } - if (file.isDirectory()) { /* @@ -155,6 +149,15 @@ for (File f : a) { + if (file.isHidden()) { + + if (log.isDebugEnabled()) + log.debug("Skipping hidden file: " + file); + + continue; + + } + loadGraph(fallback, f.toString()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:12:16
|
Revision: 7404 http://bigdata.svn.sourceforge.net/bigdata/?rev=7404&view=rev Author: thompsonbry Date: 2013-09-12 21:12:09 +0000 (Thu, 12 Sep 2013) Log Message: ----------- added code to skip hidden files Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:01:29 UTC (rev 7403) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:12:09 UTC (rev 7404) @@ -139,8 +139,14 @@ if (file.exists()) { + if (file.isHidden()) { + if (log.isDebugEnabled()) + log.debug("Skipping hidden file: " + file); + return; + } + if (file.isDirectory()) { - + /* * Recursion. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:01:36
|
Revision: 7403 http://bigdata.svn.sourceforge.net/bigdata/?rev=7403&view=rev Author: thompsonbry Date: 2013-09-12 21:01:29 +0000 (Thu, 12 Sep 2013) Log Message: ----------- organized import Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java 2013-09-12 21:00:56 UTC (rev 7402) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java 2013-09-12 21:01:29 UTC (rev 7403) @@ -18,7 +18,6 @@ import org.openrdf.model.Resource; import org.openrdf.model.Statement; import org.openrdf.rio.RDFHandlerException; -import org.openrdf.sail.SailException; import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; import com.bigdata.rdf.graph.util.GraphLoader; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2013-09-12 21:01:05
|
Revision: 7402 http://bigdata.svn.sourceforge.net/bigdata/?rev=7402&view=rev Author: thompsonbry Date: 2013-09-12 21:00:56 +0000 (Thu, 12 Sep 2013) Log Message: ----------- Added a very simple graph model for GAS graph mining. It uses a collection of vertices and linked hash sets for the in-edges, out-edges, and property values. This passes the basic "TestGather". I have written an extension to load data into this. It is ready for testing against a larger data set. The purpose is to replace the memory sail, which is way to slow when loading the data, and provide a basis for understanding the overhead associated with graph traversal versus object decoding as a pre-cursor to an exploration of column-wise indexing for graph mining. See #629 (Graph Mining API) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASRunner.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/AbstractGraphFixture.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GASUtil.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/TestAll.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASRunner.java Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASRunner.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphFixture.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/package.html branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/SailGraphLoader.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/AbstractRAMGraphTestCase.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestAll.java branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestGather.java Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,360 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.impl.ram; + +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.ValueFactoryImpl; +import org.openrdf.sail.SailException; + +import com.bigdata.rdf.graph.EdgesEnum; +import com.bigdata.rdf.graph.IGASContext; +import com.bigdata.rdf.graph.IGASProgram; +import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.impl.GASEngine; +import com.bigdata.rdf.graph.impl.util.VertexDistribution; + +import cutthecrap.utils.striterators.EmptyIterator; +import cutthecrap.utils.striterators.IStriterator; +import cutthecrap.utils.striterators.Striterator; + +public class RAMGASEngine extends GASEngine { + + public RAMGASEngine(int nthreads) { + super(nthreads); + } + + /** + * Returns <code>false</code>. There is no intrinsic ordering that can + * improve access for this implementation. + */ + @Override + public boolean getSortFrontier() { + return false; + } + + /** + * A simple RDF graph model suitable for graph mining algorithms. + * + * TODO This model does not support link weights. It was developed to + * provide an implementation without any object encode/decode overhead that + * could be used to explore the possible performance of GAS algorithms under + * Java. + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + */ + static public class RAMGraph { + + private final ValueFactory vf; + public ValueFactory getValueFactory() { + return vf; + } + + /** + * From a vertex, we can visit the in-edges, out-edges, or attribute + * values. These things are organized into three sets of statements. A + * non-thread-safe collection is used to provide the distinct semantics + * for those sets and fast traversal. This design precludes the ability + * to concurrently modify the graph during graph traversal operations. + */ + static private class Vertex { + + /** The {@link Value} for that {@link Vertex}. */ + final private Value v; + /** + * The distinct set of in-edges for this {@link Vertex}. + * <p> + * The {@link Statement#getObject()} for each {@link Statement} in + * this collection will be the {@link #v}. + */ + private Set<Statement> inEdges = null; + /** + * The distinct set of out-edges for this {@link Vertex}. + * <p> + * The {@link Statement#getSubject()} for each {@link Statement} in + * this collection will be the {@link #v}. + */ + private Set<Statement> outEdges = null; + /** + * The distinct set of property values for this {@link Vertex}. + * <p> + * The {@link Statement#getSubject()} for each {@link Statement} in + * this collection will be the {@link #v}. + * <p> + * The {@link Statement#getObject()} for each {@link Statement} in + * this collection will be a {@link URI}. + */ + private Set<Statement> attribs = null; + + public Vertex(final Value v) { + if (v == null) + throw new NullPointerException(); + this.v = v; + } + @Override + public String toString() { + return "Vertex{" + v + ",inEdges=" + getInEdgeCount() + + ",outEdges=" + getOutEdgeCount() + ",attribs=" + + getAttribCount() + "}"; + } + + private boolean addAttrib(final Statement s) { + if (attribs == null) { + attribs = new LinkedHashSet<Statement>(); + } + return attribs.add(s); + } + + private boolean addOutEdge(final Statement s) { + if (outEdges == null) { + outEdges = new LinkedHashSet<Statement>(); + } + return outEdges.add(s); + } + + private boolean addInEdge(final Statement s) { + if (inEdges == null) { + inEdges = new LinkedHashSet<Statement>(); + } + return inEdges.add(s); + } + + public int getAttribCount() { + return attribs == null ? 0 : attribs.size(); + } + + public int getInEdgeCount() { + return inEdges == null ? 0 : inEdges.size(); + } + + public int getOutEdgeCount() { + return outEdges == null ? 0 : outEdges.size(); + } + + public Iterator<Statement> inEdges() { + if (inEdges == null) + return EmptyIterator.DEFAULT; + return inEdges.iterator(); + } + + public Iterator<Statement> outEdges() { + if (outEdges == null) + return EmptyIterator.DEFAULT; + return outEdges.iterator(); + } + + public Iterator<Statement> attribs() { + if (attribs == null) + return EmptyIterator.DEFAULT; + return attribs.iterator(); + } + + } + + /** + * The vertices. + */ + private final ConcurrentMap<Value,Vertex> vertices; + + public RAMGraph() { + + vertices = new ConcurrentHashMap<Value, Vertex>(); + + vf = new ValueFactoryImpl(); + + } + + /** + * Lookup / create a vertex. + * + * @param x + * The {@link Value}. + * @param create + * when <code>true</code> the {@link Vertex} will be created + * if it does not exist. + * + * @return The {@link Vertex}. + */ + private Vertex get(final Value x, final boolean create) { + + Vertex v = vertices.get(x); + + if (v == null && create) { + + final Vertex oldVal = vertices + .putIfAbsent(x, v = new Vertex(x)); + + if (oldVal != null) { + + // lost data race. + v = oldVal; + + } + + } + + return v; + + } + + public boolean add(final Statement st) { + + final Resource s = st.getSubject(); + + final Value o = st.getObject(); + + boolean modified = false; + if (o instanceof URI) { + // Edge + modified|=get(s, true/* create */).addOutEdge(st); + modified|=get(o, true/* create */).addInEdge(st); + } else { + // Property value. + modified|=get(s, true/* create */).addAttrib(st); + } + return modified; + + } + + public Iterator<Statement> inEdges(final Value v) { + final Vertex x = get(v, false/* create */); + if (x == null) + return EmptyIterator.DEFAULT; + return x.inEdges(); + } + + public Iterator<Statement> outEdges(final Value v) { + final Vertex x = get(v, false/* create */); + if (x == null) + return EmptyIterator.DEFAULT; + return x.outEdges(); + } + public Iterator<Statement> attribs(final Value v) { + final Vertex x = get(v, false/* create */); + if (x == null) + return EmptyIterator.DEFAULT; + return x.attribs(); + } + + } // class RAMGraph + + static public class RAMGraphAccessor implements IGraphAccessor { + + private final RAMGraph g; + + public RAMGraphAccessor(final RAMGraph g) { + if (g == null) + throw new IllegalArgumentException(); + this.g = g; + } + + @Override + public void advanceView() { + // NOP + } + + @SuppressWarnings("unchecked") + @Override + public Iterator<Statement> getEdges(final IGASContext<?, ?, ?> p, + final Value u, final EdgesEnum edges) { + + try { + switch (edges) { + case NoEdges: + return EmptyIterator.DEFAULT; + case InEdges: + return getEdges(true/* inEdges */, p, u); + case OutEdges: + return getEdges(false/* inEdges */, p, u); + case AllEdges: { + final IStriterator a = getEdges(true/* inEdges */, p, u); + final IStriterator b = getEdges(false/* outEdges */, p, u); + a.append(b); + return a; + } + default: + throw new UnsupportedOperationException(edges.name()); + } + } catch (SailException ex) { + throw new RuntimeException(ex); + } + + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private IStriterator getEdges(final boolean inEdges, + final IGASContext<?, ?, ?> ctx, final Value u) + throws SailException { + + final URI linkTypeIV = (URI) ctx.getGASProgram().getLinkType(); + if(linkTypeIV != null) { + /* + * FIXME RDR: We need to use a union of access paths for link + * attributes for the generic SAIL since it does not have the + * concept of statements about statements. This will require + * applying the access paths that will visit the appropriate + * reified triples. This needs to be done for both the standard + * path and the POS optimization code path. + */ + throw new UnsupportedOperationException(); + } + final Striterator sitr; + if(inEdges) { + sitr = new Striterator(g.get(u, false/*create*/).inEdges()); + } else { + sitr = new Striterator(g.get(u, false/*create*/).outEdges()); + } + /* + * Optionally wrap the program specified filter. + */ + return ((IGASProgram) ctx.getGASProgram()).constrainFilter(ctx, + sitr); + + } + + @Override + public VertexDistribution getDistribution(final Random r) { + + final VertexDistribution sample = new VertexDistribution(r); + + for (Value v : g.vertices.keySet()) { + + if (v instanceof Resource) { + + sample.addSample((Resource) v); + + } + + } + + return sample; + + } + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASRunner.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASRunner.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASRunner.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,130 @@ +package com.bigdata.rdf.graph.impl.ram; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.log4j.Logger; + +import com.bigdata.rdf.graph.IGASEngine; +import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; +import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraphAccessor; +import com.bigdata.rdf.graph.impl.util.GASRunnerBase; + +/** + * Class for running GAS performance tests against the SAIL. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public class RAMGASRunner<VS, ES, ST> extends GASRunnerBase<VS, ES, ST> { + + private static final Logger log = Logger.getLogger(RAMGASRunner.class); + + public RAMGASRunner(String[] args) throws ClassNotFoundException { + super(args); + } + + protected class RAMOptionData extends GASRunnerBase<VS, ES, ST>.OptionData { + + final private RAMGraph g = new RAMGraph(); + + public RAMGraph getGraph() { + synchronized(g) { + /* + * Note: Synchronization pattern is intended to provide + * visibility for graph traversal following a load of data into + * the graph. + */ + return g; + } + } + + @Override + public void init() throws Exception { + + super.init(); + + } + + @Override + public void shutdown() { + + } + @Override + public boolean handleArg(final AtomicInteger i, final String[] args) { + if (super.handleArg(i, args)) { + return true; + } +// final String arg = args[i.get()]; +// if (arg.equals("-bufferMode")) { +// final String s = args[i.incrementAndGet()]; +// bufferModeOverride = BufferMode.valueOf(s); +// } else if (arg.equals("-namespace")) { +// final String s = args[i.incrementAndGet()]; +// namespaceOverride = s; +// } else { +// return false; +// } + return false; + } + + @Override + public void report(final StringBuilder sb) { + // NOP + } + + } // class SAILOptionData + + @Override + protected RAMOptionData newOptionData() { + + return new RAMOptionData(); + + } + + @Override + protected IGASEngine newGASEngine() { + + return new RAMGASEngine(getOptionData().nthreads); + + } + + @Override + protected void loadFiles() throws Exception { + + final RAMOptionData opt = getOptionData(); + + final String[] resources = opt.loadSet.toArray(new String[0]); + + new RAMGraphLoader(opt.getGraph()).loadGraph(null/* fallback */, + resources); + + } + + @SuppressWarnings("unchecked") + @Override + protected RAMOptionData getOptionData() { + + return (RAMOptionData) super.getOptionData(); + + } + + @Override + protected IGraphAccessor newGraphAccessor() { + + return new RAMGraphAccessor(getOptionData().g); + + } + + /** + * Performance testing harness. + * + * @see #GASRunner(String[]) + */ + @SuppressWarnings("rawtypes") + public static void main(final String[] args) throws Exception { + + new RAMGASRunner(args).call(); + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphFixture.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphFixture.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphFixture.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,68 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.impl.ram; + +import org.openrdf.sail.Sail; +import org.openrdf.sail.SailConnection; +import org.openrdf.sail.SailException; +import org.openrdf.sail.memory.MemoryStore; + +import com.bigdata.rdf.graph.IGASEngine; +import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; +import com.bigdata.rdf.graph.impl.sail.SAILGASEngine.SAILGraphAccessor; +import com.bigdata.rdf.graph.util.AbstractGraphFixture; + +public class RAMGraphFixture extends AbstractGraphFixture { + + private RAMGraph g; + + public RAMGraphFixture() throws SailException { + g = new RAMGraph(); + } + + public Sail getSail() { + throw new UnsupportedOperationException(); + } + + /** + * Return the {@link RAMGraphFixture}. + */ + public RAMGraph getGraph() { + return g; + } + + @Override + public void destroy() throws SailException { + g = null; + } + + @Override + public IGASEngine newGASEngine(int nthreads) { + + return new RAMGASEngine(nthreads); + + } + + @Override + public IGraphAccessor newGraphAccessor(SailConnection cxnIsIgnored) { + +// return new RAMGraphAccessor(cxnIsIgnored); + throw new UnsupportedOperationException(); + + } + +} \ No newline at end of file Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGraphLoader.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,55 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.impl.ram; + +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.rio.RDFHandlerException; +import org.openrdf.sail.SailException; + +import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; +import com.bigdata.rdf.graph.util.GraphLoader; + +public class RAMGraphLoader extends GraphLoader { + + private final RAMGraph g; + + public RAMGraphLoader(final RAMGraph g) { + if (g == null) + throw new IllegalArgumentException(); + this.g = g; + } + + @Override + protected AddStatementHandler newStatementHandler() { + return new RAMStatementHandler(); + } + + private class RAMStatementHandler extends AddStatementHandler { + + @Override + protected void addStatement(final Statement stmt, final Resource[] c) + throws RDFHandlerException { + + g.add(stmt); + + ntriples++; + + } + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/package.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/package.html (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/package.html 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,14 @@ +<html> +<head> +<title>GAS Engine for RAM</title> +</head> +<body> + <p>This is an implementation of the GAS API for the Java concurrency + class. This package is designed to have no object encoding and + decoding overhead and to support high concurrency operations on the + graph. It does NOT implement the SAIL. Instead, it provides an RDF + graph abstraction using the openrdf data model that support efficient + operations for the GAS API (basically, efficient access to the + in-edges, out-edges, and attribute values).</p> +</body> +</html> \ No newline at end of file Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASRunner.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASRunner.java 2013-09-12 17:07:59 UTC (rev 7401) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASRunner.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -1,3 +1,18 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ package com.bigdata.rdf.graph.impl.sail; import java.util.concurrent.atomic.AtomicInteger; @@ -13,7 +28,7 @@ import com.bigdata.rdf.graph.IGraphAccessor; import com.bigdata.rdf.graph.impl.sail.SAILGASEngine.SAILGraphAccessor; import com.bigdata.rdf.graph.impl.util.GASRunnerBase; -import com.bigdata.rdf.graph.util.GASUtil; +import com.bigdata.rdf.graph.util.SailGraphLoader; /** * Class for running GAS performance tests against the SAIL. @@ -136,7 +151,7 @@ SailConnection cxn = null; try { cxn = opt.cxn; - new GASUtil().loadGraph(cxn, null/* fallback */, resources); + new SailGraphLoader(cxn).loadGraph(null/* fallback */, resources); cxn.commit(); ok = true; } finally { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/AbstractGraphFixture.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/AbstractGraphFixture.java 2013-09-12 17:07:59 UTC (rev 7401) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/AbstractGraphFixture.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -28,7 +28,7 @@ SailConnection cxn = null; try { cxn = getSail().getConnection(); - new GASUtil().loadGraph(cxn, null/* fallback */, resources); + new SailGraphLoader(cxn).loadGraph(null/* fallback */, resources); cxn.commit(); ok = true; } finally { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GASUtil.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GASUtil.java 2013-09-12 17:07:59 UTC (rev 7401) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GASUtil.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -15,34 +15,11 @@ */ package com.bigdata.rdf.graph.util; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.URISyntaxException; import java.util.Iterator; import java.util.concurrent.TimeUnit; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import org.apache.log4j.Logger; -import org.openrdf.model.Resource; import org.openrdf.model.Statement; import org.openrdf.model.Value; -import org.openrdf.rio.RDFFormat; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFParseException; -import org.openrdf.rio.RDFParser; -import org.openrdf.rio.RDFParserFactory; -import org.openrdf.rio.RDFParserRegistry; -import org.openrdf.rio.helpers.RDFHandlerBase; -import org.openrdf.sail.SailConnection; -import org.openrdf.sail.SailException; import cutthecrap.utils.striterators.EmptyIterator; @@ -53,7 +30,7 @@ */ public class GASUtil { - private static final Logger log = Logger.getLogger(GASUtil.class); +// private static final Logger log = Logger.getLogger(GASUtil.class); /** * The average fan out of the frontier. @@ -113,306 +90,4 @@ @SuppressWarnings({ "unchecked" }) public static final Iterator<Statement> EMPTY_EDGES_ITERATOR = EmptyIterator.DEFAULT; - /** - * Return the best guess at the {@link RDFFormat} for a resource. - * <p> - * Note: This handles the .gz and .zip extensions. - * - * @param n - * The name of the resource. - * @param rdfFormat - * The fallback format (optional). - * - * @return The best guess format. - */ - private RDFFormat guessRDFFormat(final String n, final RDFFormat rdfFormat) { - - RDFFormat fmt = RDFFormat.forFileName(n); - - if (fmt == null && n.endsWith(".zip")) { - fmt = RDFFormat.forFileName(n.substring(0, n.length() - 4)); - } - - if (fmt == null && n.endsWith(".gz")) { - fmt = RDFFormat.forFileName(n.substring(0, n.length() - 3)); - } - - if (fmt == null) // fallback - fmt = rdfFormat; - - return fmt; - - } - - public void loadGraph(final SailConnection cxn, final RDFFormat fallback, - final String... resources) throws Exception { - - if (resources != null) { - - for (String resource : resources) { - - loadGraph(cxn, fallback, resource); - - } - - } - - } - - /** - * Load a resource from the classpath, the file system, or a URI. GZ - * compressed files are decompressed. Directories are processed recursively. - * The entries in a ZIP archive are processed. Resources that are not - * recognized as some {@link RDFFormat} will be ignored unless the - * <i>fallback</i> argument is given, in which case that format will be - * <em>assumed</em> for such resources. - * - * @param cxn - * The connection used to load the data. - * @param resource - * A resource on the class path, a file or a directory, or a URI. - * @param fallback - * The default {@link RDFFormat} to be assumed (optional). - * - * @throws IOException - * @throws URISyntaxException - * @throws RDFHandlerException - * @throws RDFParseException - */ - public void loadGraph(final SailConnection cxn, final RDFFormat fallback, - final String resource) throws IOException, URISyntaxException, - RDFParseException, RDFHandlerException { - - if (log.isInfoEnabled()) - log.info("Loading: " + resource); - - String baseURI = null; - - InputStream is = null; - try { - - // try the classpath - is = getClass().getResourceAsStream(resource); - - if (is != null) { - - // set for resource on classpath. - baseURI = getClass().getResource(resource).toURI().toString(); - - } else { - - // try file system. - final File file = new File(resource); - - if (file.exists()) { - - if (file.isDirectory()) { - - /* - * Recursion. - */ - - final File[] a = file.listFiles(); - - for (File f : a) { - - loadGraph(cxn, fallback, f.toString()); - - } - - } - - is = new FileInputStream(file); - - // set for file as URI. - baseURI = file.toURI().toString(); - - } else { - - throw new FileNotFoundException( - "Could not locate resource: " + resource); - - } - - } - - if (resource.endsWith(".gz")) { - - is = new GZIPInputStream(is); - - } else if (resource.endsWith(".zip")) { - - final ZipInputStream zis = new ZipInputStream(is); - - try { - - ZipEntry e; - - while ((e = zis.getNextEntry()) != null) { - - if (e.isDirectory()) { - - // skip directories. - continue; - } - - baseURI = resource + "/" + e.getName(); - - loadFromStream(cxn, zis, resource, baseURI, fallback); - - final RDFFormat format = guessRDFFormat(e.getName(), - fallback); - - if (format == null) { - - if (log.isInfoEnabled()) - log.info("Skipping non-RDF entry: resource=" - + resource + ", entry=" + e.getName()); - - continue; - - } - - } - - return; - - } finally { - - zis.close(); - - } - - } - - loadFromStream(cxn, is, resource, baseURI, fallback); - - } finally { - - if (is != null) { - - try { - is.close(); - } catch (Throwable t) { - log.error(t); - } - - } - - } - - } - - private void loadFromStream(final SailConnection cxn, final InputStream is, - final String resource, final String baseURI, - final RDFFormat fallback) throws RDFParseException, - RDFHandlerException, IOException { - - // guess at the RDF Format - final RDFFormat rdfFormat = guessRDFFormat(resource, fallback); - - if (rdfFormat == null) { - - if (log.isInfoEnabled()) - log.info("Skipping non-RDF resource: " + resource); - - return; - - } - - /* - * Obtain a buffered reader on the input stream. - */ - final Reader reader = new BufferedReader(new InputStreamReader( - is)); - - try { - - final RDFParserFactory rdfParserFactory = RDFParserRegistry - .getInstance().get(rdfFormat); - - final RDFParser rdfParser = rdfParserFactory.getParser(); - - rdfParser.setStopAtFirstError(false); - - final AddStatementHandler h = new AddStatementHandler(cxn); - - rdfParser.setRDFHandler(h); - - /* - * Run the parser, which will cause statements to be - * inserted. - */ - - rdfParser.parse(reader, baseURI); - - if (log.isInfoEnabled()) - log.info("Done: " + resource + ", nread=" + h.ntriples); - - } finally { - - try { - reader.close(); - } catch (Throwable t) { - log.error(t); - } - - } - - } - - /** - * Helper class adds statements to the sail as they are visited by a parser. - */ - private static class AddStatementHandler extends RDFHandlerBase { - - private final SailConnection conn; - /** - * Only used if the statements themselves do not have a context. - */ - private final Resource[] defaultContext; - - private long ntriples = 0; - - /** - * - * @param conn - */ - public AddStatementHandler(final SailConnection conn) { - this.conn = conn; - this.defaultContext = new Resource[0]; - } - - public void handleStatement(final Statement stmt) - throws RDFHandlerException { - - final Resource[] c = (Resource[]) - (stmt.getContext() == null - ? defaultContext - : new Resource[] { stmt.getContext() }); - - try { - - conn.addStatement(// - stmt.getSubject(), // - stmt.getPredicate(), // - stmt.getObject(), // - c - ); - - if (c == null || c.length == 0) - ntriples++; - else - ntriples += c.length; - - } catch (SailException e) { - - throw new RDFHandlerException(e); - - } - - } - - } - } Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/GraphLoader.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,340 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URISyntaxException; +import java.util.zip.GZIPInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.apache.log4j.Logger; +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.rio.RDFFormat; +import org.openrdf.rio.RDFHandlerException; +import org.openrdf.rio.RDFParseException; +import org.openrdf.rio.RDFParser; +import org.openrdf.rio.RDFParserFactory; +import org.openrdf.rio.RDFParserRegistry; +import org.openrdf.rio.helpers.RDFHandlerBase; + +/** + * Utility to load data into a graph. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +abstract public class GraphLoader { + + private static final Logger log = Logger.getLogger(GASUtil.class); + + /** + * Return the best guess at the {@link RDFFormat} for a resource. + * <p> + * Note: This handles the .gz and .zip extensions. + * + * @param n + * The name of the resource. + * @param rdfFormat + * The fallback format (optional). + * + * @return The best guess format. + */ + private RDFFormat guessRDFFormat(final String n, final RDFFormat rdfFormat) { + + RDFFormat fmt = RDFFormat.forFileName(n); + + if (fmt == null && n.endsWith(".zip")) { + fmt = RDFFormat.forFileName(n.substring(0, n.length() - 4)); + } + + if (fmt == null && n.endsWith(".gz")) { + fmt = RDFFormat.forFileName(n.substring(0, n.length() - 3)); + } + + if (fmt == null) // fallback + fmt = rdfFormat; + + return fmt; + + } + + public void loadGraph(final RDFFormat fallback, + final String... resources) throws Exception { + + if (resources != null) { + + for (String resource : resources) { + + loadGraph(fallback, resource); + + } + + } + + } + + /** + * Load a resource from the classpath, the file system, or a URI. GZ + * compressed files are decompressed. Directories are processed recursively. + * The entries in a ZIP archive are processed. Resources that are not + * recognized as some {@link RDFFormat} will be ignored unless the + * <i>fallback</i> argument is given, in which case that format will be + * <em>assumed</em> for such resources. + * + * @param resource + * A resource on the class path, a file or a directory, or a URI. + * @param fallback + * The default {@link RDFFormat} to be assumed (optional). + * + * @throws IOException + * @throws URISyntaxException + * @throws RDFHandlerException + * @throws RDFParseException + */ + public void loadGraph(final RDFFormat fallback, + final String resource) throws IOException, URISyntaxException, + RDFParseException, RDFHandlerException { + + if (log.isInfoEnabled()) + log.info("Loading: " + resource); + + String baseURI = null; + + InputStream is = null; + try { + + // try the classpath + is = getClass().getResourceAsStream(resource); + + if (is != null) { + + // set for resource on classpath. + baseURI = getClass().getResource(resource).toURI().toString(); + + } else { + + // try file system. + final File file = new File(resource); + + if (file.exists()) { + + if (file.isDirectory()) { + + /* + * Recursion. + */ + + final File[] a = file.listFiles(); + + for (File f : a) { + + loadGraph(fallback, f.toString()); + + } + + } + + is = new FileInputStream(file); + + // set for file as URI. + baseURI = file.toURI().toString(); + + } else { + + throw new FileNotFoundException( + "Could not locate resource: " + resource); + + } + + } + + if (resource.endsWith(".gz")) { + + is = new GZIPInputStream(is); + + } else if (resource.endsWith(".zip")) { + + final ZipInputStream zis = new ZipInputStream(is); + + try { + + ZipEntry e; + + while ((e = zis.getNextEntry()) != null) { + + if (e.isDirectory()) { + + // skip directories. + continue; + } + + baseURI = resource + "/" + e.getName(); + + loadFromStream(zis, resource, baseURI, fallback); + + final RDFFormat format = guessRDFFormat(e.getName(), + fallback); + + if (format == null) { + + if (log.isInfoEnabled()) + log.info("Skipping non-RDF entry: resource=" + + resource + ", entry=" + e.getName()); + + continue; + + } + + } + + return; + + } finally { + + zis.close(); + + } + + } + + loadFromStream(is, resource, baseURI, fallback); + + } finally { + + if (is != null) { + + try { + is.close(); + } catch (Throwable t) { + log.error(t); + } + + } + + } + + } + + private void loadFromStream(final InputStream is, + final String resource, final String baseURI, + final RDFFormat fallback) throws RDFParseException, + RDFHandlerException, IOException { + + // guess at the RDF Format + final RDFFormat rdfFormat = guessRDFFormat(resource, fallback); + + if (rdfFormat == null) { + + if (log.isInfoEnabled()) + log.info("Skipping non-RDF resource: " + resource); + + return; + + } + + /* + * Obtain a buffered reader on the input stream. + */ + final Reader reader = new BufferedReader(new InputStreamReader( + is)); + + try { + + final RDFParserFactory rdfParserFactory = RDFParserRegistry + .getInstance().get(rdfFormat); + + final RDFParser rdfParser = rdfParserFactory.getParser(); + + rdfParser.setStopAtFirstError(false); + + final AddStatementHandler h = newStatementHandler(); + + rdfParser.setRDFHandler(h); + + /* + * Run the parser, which will cause statements to be + * inserted. + */ + + rdfParser.parse(reader, baseURI); + + if (log.isInfoEnabled()) + log.info("Done: " + resource + ", nread=" + h.ntriples); + + } finally { + + try { + reader.close(); + } catch (Throwable t) { + log.error(t); + } + + } + + } + + /** + * Factory for the helper class that adds statements to the target + * graph. + */ + protected abstract AddStatementHandler newStatementHandler(); + + /** + * Helper class adds statements to the sail as they are visited by a parser. + */ + protected abstract class AddStatementHandler extends RDFHandlerBase { + + /** + * Only used if the statements themselves do not have a context. + */ + private final Resource[] defaultContext; + + protected long ntriples = 0; + + /** + * + * @param conn + */ + public AddStatementHandler() { + this.defaultContext = new Resource[0]; + } + + public void handleStatement(final Statement stmt) + throws RDFHandlerException { + + final Resource[] c = (Resource[]) + (stmt.getContext() == null + ? defaultContext + : new Resource[] { stmt.getContext() }); + + addStatement(stmt, c); + + } + + abstract protected void addStatement(final Statement stmt, + final Resource[] c) throws RDFHandlerException; + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/SailGraphLoader.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/SailGraphLoader.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/util/SailGraphLoader.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,78 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.util; + +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.rio.RDFHandlerException; +import org.openrdf.sail.SailConnection; +import org.openrdf.sail.SailException; + +public class SailGraphLoader extends GraphLoader { + + /** + * The connection used to load the data. + */ + private final SailConnection cxn; + + /** + * + * @param cxn + * The connection used to load the data. + */ + public SailGraphLoader(final SailConnection cxn) { + + this.cxn = cxn; + + } + + @Override + protected AddStatementHandler newStatementHandler() { + + return new SailStatementHandler(); + + } + + private class SailStatementHandler extends AddStatementHandler { + + @Override + protected void addStatement(final Statement stmt, final Resource[] c) + throws RDFHandlerException { + + try { + + cxn.addStatement(// + stmt.getSubject(), // + stmt.getPredicate(), // + stmt.getObject(), // + c); + + if (c == null || c.length == 0) + ntriples++; + else + ntriples += c.length; + + } catch (SailException e) { + + throw new RDFHandlerException(e); + + } + + } + + } + +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/TestAll.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/TestAll.java 2013-09-12 17:07:59 UTC (rev 7401) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/TestAll.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -51,6 +51,8 @@ suite.addTest(com.bigdata.rdf.graph.impl.sail.TestAll.suite()); + suite.addTest(com.bigdata.rdf.graph.impl.ram.TestAll.suite()); + suite.addTest(com.bigdata.rdf.graph.analytics.TestAll.suite()); return suite; Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/AbstractRAMGraphTestCase.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/AbstractRAMGraphTestCase.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/AbstractRAMGraphTestCase.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,164 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.impl.ram; + +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; + +import com.bigdata.rdf.graph.AbstractGraphTestCase; +import com.bigdata.rdf.graph.impl.ram.RAMGASEngine.RAMGraph; +import com.bigdata.rdf.graph.util.IGraphFixture; +import com.bigdata.rdf.graph.util.IGraphFixtureFactory; + +public class AbstractRAMGraphTestCase extends AbstractGraphTestCase { + +// private static final Logger log = Logger +// .getLogger(AbstractGraphTestCase.class); + + public AbstractRAMGraphTestCase() { + } + + public AbstractRAMGraphTestCase(String name) { + super(name); + } + + @Override + protected IGraphFixtureFactory getGraphFixtureFactory() { + + return new IGraphFixtureFactory() { + + @Override + public IGraphFixture newGraphFixture() throws Exception { + return new RAMGraphFixture(); + } + + }; + + } + + @Override + protected RAMGraphFixture getGraphFixture() { + + return (RAMGraphFixture) super.getGraphFixture(); + + } + + /** + * A small foaf data set relating some of the project contributors (triples + * mode data). + * + * @see {@value #smallGraph} + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + protected class SmallGraphProblem { + + private final URI rdfType, rdfsLabel, foafKnows, foafPerson, mike, + bryan, martyn, dc; + + /** + * The data: + * + * <pre> + * @prefix : <http://www.bigdata.com/> . + * @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . + * @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . + * @prefix foaf: <http://xmlns.com/foaf/0.1/> . + * + * #: { + * :Mike rdf:type foaf:Person . + * :Bryan rdf:type foaf:Person . + * :Martyn rdf:type foaf:Person . + * + * :Mike rdfs:label "Mike" . + * :Bryan rdfs:label "Bryan" . + * :DC rdfs:label "DC" . + * + * :Mike foaf:knows :Bryan . + * :Bryan foaf:knows :Mike . + * :Bryan foaf:knows :Martyn . + * :Martyn foaf:knows :Bryan . + * #} + * </pre> + */ + public SmallGraphProblem() throws Exception { + + final RAMGraph g = getGraphFixture().getGraph(); + + final ValueFactory vf = g.getValueFactory(); + + rdfType = vf.createURI(RDF.TYPE.stringValue()); + rdfsLabel = vf.createURI(RDFS.LABEL.stringValue()); + foafKnows = vf.createURI("http://xmlns.com/foaf/0.1/knows"); + foafPerson = vf.createURI("http://xmlns.com/foaf/0.1/Person"); + mike = vf.createURI("http://www.bigdata.com/Mike"); + bryan = vf.createURI("http://www.bigdata.com/Bryan"); + martyn = vf.createURI("http://www.bigdata.com/Martyn"); + dc = vf.createURI("http://www.bigdata.com/DC"); + + g.add(vf.createStatement(mike, rdfType, foafPerson)); + g.add(vf.createStatement(bryan, rdfType, foafPerson)); + g.add(vf.createStatement(martyn, rdfType, foafPerson)); + + g.add(vf.createStatement(mike, rdfsLabel, vf.createLiteral("Mike"))); + g.add(vf.createStatement(bryan, rdfsLabel, vf.createLiteral("Bryan"))); + g.add(vf.createStatement(dc, rdfsLabel, vf.createLiteral("DC"))); + + g.add(vf.createStatement(mike, foafKnows, bryan)); + g.add(vf.createStatement(bryan, foafKnows, mike)); + g.add(vf.createStatement(bryan, foafKnows, martyn)); + g.add(vf.createStatement(martyn, foafKnows, bryan)); + + } + + public URI getRdfType() { + return rdfType; + } + + public URI getFoafKnows() { + return foafKnows; + } + + public URI getFoafPerson() { + return foafPerson; + } + + public URI getMike() { + return mike; + } + + public URI getBryan() { + return bryan; + } + + public URI getMartyn() { + return martyn; + } + + } + + /** + * Load and setup the {@link SmallGraphProblem}. + */ + protected SmallGraphProblem setupSmallGraphProblem() throws Exception { + + return new SmallGraphProblem(); + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestAll.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestAll.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestAll.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,64 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.bigdata.rdf.graph.impl.ram; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Aggregates test suites into increasing dependency order. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id: TestAll.java 6116 2012-03-13 20:39:17Z thompsonbry $ + */ +public class TestAll extends TestCase { + + /** + * + */ + public TestAll() { + } + + /** + * @param arg0 + */ + public TestAll(String arg0) { + super(arg0); + } + + /** + * Returns a test that will run each of the implementation specific test + * suites in turn. + */ + public static Test suite() + { + + final TestSuite suite = new TestSuite("SAIL Graph Engine"); + + /* + * Only core functionality tests for the SAIL backend belong here. The + * analytic test suites are written to the SAIL backend so there is good + * coverage there. + */ + + suite.addTestSuite(TestGather.class); + + return suite; + + } + +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestGather.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestGather.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/test/com/bigdata/rdf/graph/impl/ram/TestGather.java 2013-09-12 21:00:56 UTC (rev 7402) @@ -0,0 +1,311 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permission... [truncated message content] |