From: <mrp...@us...> - 2010-10-19 16:02:24
|
Revision: 3821 http://bigdata.svn.sourceforge.net/bigdata/?rev=3821&view=rev Author: mrpersonick Date: 2010-10-19 16:02:18 +0000 (Tue, 19 Oct 2010) Log Message: ----------- testing single tail rules Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -271,7 +271,7 @@ if(!(accessPath1 instanceof SPOAccessPath)) { // The logic relies on wrapping an SPOAccessPath, at least for now. - throw new IllegalArgumentException(); + throw new IllegalArgumentException(accessPath1.getClass().toString()); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -497,31 +497,6 @@ } - /** - * Override evaluation of StatementPatterns to recognize magic search - * predicate. - @Override - public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( - final StatementPattern sp, final BindingSet bindings) - throws QueryEvaluationException { - - // no check against the nativeJoins property here because we are simply - // using the native execution model to take care of magic searches. - - if (log.isDebugEnabled()) { - log.debug("evaluating statement pattern:\n" + sp); - } - - IStep query = createNativeQuery(sp); - - if (query == null) { - return new EmptyIteration<BindingSet, QueryEvaluationException>(); - } - - return execute(query); - - } - */ /** * Translate top-level JOINs into native bigdata programs for execution. @@ -953,20 +928,20 @@ // } // } - if (log.isDebugEnabled()) { - for (IPredicate<ISPO> tail : tails) { - IAccessPathExpander<ISPO> expander = tail.getAccessPathExpander(); - if (expander != null) { - IAccessPath<ISPO> accessPath = database.getSPORelation() - .getAccessPath(tail); - accessPath = expander.getAccessPath(accessPath); - IChunkedOrderedIterator<ISPO> it = accessPath.iterator(); - while (it.hasNext()) { - log.debug(it.next().toString(database)); - } - } - } - } +// if (log.isDebugEnabled()) { +// for (IPredicate<ISPO> tail : tails) { +// IAccessPathExpander<ISPO> expander = tail.getAccessPathExpander(); +// if (expander != null) { +// IAccessPath<ISPO> accessPath = database.getSPORelation() +// .getAccessPath(tail); +// accessPath = expander.getAccessPath(accessPath); +// IChunkedOrderedIterator<ISPO> it = accessPath.iterator(); +// while (it.hasNext()) { +// log.debug(it.next().toString(database)); +// } +// } +// } +// } /* * Collect a set of variables required beyond just the join (i.e. @@ -1843,6 +1818,46 @@ } } +// /** +// * Override evaluation of StatementPatterns to recognize magic search +// * predicate. +// */ +// @Override +// public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( +// final StatementPattern sp, final BindingSet bindings) +// throws QueryEvaluationException { +// +// if (log.isDebugEnabled()) { +// log.debug("evaluating statement pattern:\n" + sp); +// } +// +// // check for magic search +// final Var predVar = sp.getPredicateVar(); +// final Value predValue = getVarValue(predVar, bindings); +// if (BD.SEARCH.equals(predValue)) { +// final Var ovar = sp.getObjectVar(); +// final Value oval = getVarValue(ovar, bindings); +// if (oval == null) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object must be bound."); +// } +// if (!(oval instanceof Literal)) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object must be literal."); +// } +// final Literal lit = (Literal) oval; +// if (lit.getDatatype() != null) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object is datatype literal."); +// } +// return search(sp.getSubjectVar(), lit.getLanguage(), +// lit.getLabel(), bindings, sp.getScope()); +// } +// +// return super.evaluate(sp, bindings); +// +// } + /** * Override evaluation of StatementPatterns to recognize magic search * predicate. @@ -1852,34 +1867,28 @@ final StatementPattern sp, final BindingSet bindings) throws QueryEvaluationException { + // no check against the nativeJoins property here because we are simply + // using the native execution model to take care of magic searches. + if (log.isDebugEnabled()) { log.debug("evaluating statement pattern:\n" + sp); } - // check for magic search - final Var predVar = sp.getPredicateVar(); - final Value predValue = getVarValue(predVar, bindings); - if (BD.SEARCH.equals(predValue)) { - final Var ovar = sp.getObjectVar(); - final Value oval = getVarValue(ovar, bindings); - if (oval == null) { - throw new QueryEvaluationException(BD.SEARCH - + " : object must be bound."); - } - if (!(oval instanceof Literal)) { - throw new QueryEvaluationException(BD.SEARCH - + " : object must be literal."); - } - final Literal lit = (Literal) oval; - if (lit.getDatatype() != null) { - throw new QueryEvaluationException(BD.SEARCH - + " : object is datatype literal."); - } - return search(sp.getSubjectVar(), lit.getLanguage(), - lit.getLabel(), bindings, sp.getScope()); + final IStep query = createNativeQuery(sp); + + if (query == null) { + return new EmptyIteration<BindingSet, QueryEvaluationException>(); } + + try { - return super.evaluate(sp, bindings); + return execute(query); + + } catch (Exception ex) { + + throw new QueryEvaluationException(ex); + + } } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -34,7 +34,8 @@ // } @Override - public SailRepositoryConnection getConnection() throws RepositoryException { + public BigdataSailRepositoryConnection getConnection() + throws RepositoryException { try { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -97,6 +97,8 @@ suite.addTestSuite(TestDescribe.class); + suite.addTestSuite(TestMultiGraphs.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -99,8 +99,17 @@ * You'll get the same answer whether you run with Bigdata or Sesame. */ if (true) { - sail = getSail(); - repo = new BigdataSailRepository((BigdataSail) sail); + + final BigdataSail bdSail = getSail(); + sail = bdSail; + + if (bdSail.getDatabase().isQuads() == false) { + bdSail.__tearDownUnitTest(); + return; + } + + repo = new BigdataSailRepository(bdSail); + } else { sail = new MemoryStore(); repo = new SailRepository(sail); @@ -156,17 +165,17 @@ "select ?p ?o " + "WHERE { " + - " ?s rdf:type ns:Person . " + - " ?s ?p ?o . " + +// " ?s rdf:type ns:Person . " + + " ns:Mike ?p ?o . " + "}"; final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); - while (result.hasNext()) { - System.err.println(result.next()); - } +// while (result.hasNext()) { +// System.err.println(result.next()); +// } Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { @@ -181,20 +190,8 @@ new BindingImpl("p", RDFS.LABEL), new BindingImpl("o", l1), })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); -// compare(result, solution); + compare(result, solution); } @@ -216,9 +213,9 @@ cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); - while (result.hasNext()) { - System.err.println(result.next()); - } +// while (result.hasNext()) { +// System.err.println(result.next()); +// } Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { @@ -233,20 +230,8 @@ new BindingImpl("p", RDFS.LABEL), new BindingImpl("o", l1), })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); -// compare(result, solution); + compare(result, solution); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |