From: <mrp...@us...> - 2011-01-20 02:05:28
|
Revision: 4135 http://bigdata.svn.sourceforge.net/bigdata/?rev=4135&view=rev Author: mrpersonick Date: 2011-01-20 02:05:21 +0000 (Thu, 20 Jan 2011) Log Message: ----------- working through tck failures Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/SubqueryOp.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/CompareBOp.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTree.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTreeBuilder.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/SameTermBOp.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -737,7 +737,26 @@ return sb.toString(); } + + public static String toString2(final BOp bop) { + String s = toString(bop); + s = s.replaceAll("com.bigdata.bop.controller.", ""); + s = s.replaceAll("com.bigdata.bop.join.", ""); + s = s.replaceAll("com.bigdata.bop.solutions.", ""); + s = s.replaceAll("com.bigdata.bop.rdf.filter.", ""); + s = s.replaceAll("com.bigdata.bop.", ""); + s = s.replaceAll("com.bigdata.rdf.sail.", ""); + s = s.replaceAll("com.bigdata.rdf.spo.", ""); +// s = s.replaceAll("com.bigdata.bop..", ""); +// s = s.replaceAll("com.bigdata.bop..", ""); +// s = s.replaceAll("com.bigdata.bop..", ""); +// s = s.replaceAll("com.bigdata.bop..", ""); +// s = s.replaceAll("com.bigdata.bop..", ""); + return s; + + } + private static void toString(final BOp bop, final StringBuilder sb, final int indent) { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/SubqueryOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/SubqueryOp.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/SubqueryOp.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -158,6 +158,18 @@ return new FutureTask<Void>(new ControllerTask(this, context)); } + + public String toString() { + + final StringBuilder sb = new StringBuilder(super.toString()); + sb.append("\n{\n"); + final PipelineOp subquery = (PipelineOp) + getRequiredProperty(Annotations.SUBQUERY); + sb.append(BOpUtility.toString(subquery)); + sb.append("\n}"); + return sb.toString(); + + } /** * Evaluates the arguments of the operator as subqueries. The arguments are Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/CompareBOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/CompareBOp.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/CompareBOp.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -98,12 +98,18 @@ return _accept(left.compareTo(right)); } - if (!IVUtility.canNumericalCompare(left)) - throw new NotNumericalException("cannot numerical compare: " + left); + if (!IVUtility.canNumericalCompare(left) || + !IVUtility.canNumericalCompare(right)) { + if (op == CompareOp.EQ) { + return false; + } else if (op == CompareOp.NE) { + return true; + } else { + throw new NotNumericalException("cannot numerical compare: " + + left + " " + op + " " + right); + } + } - if (!IVUtility.canNumericalCompare(right)) - throw new NotNumericalException("cannot numerical compare: " + right); - return _accept(IVUtility.numericalCompare(left, right)); } Added: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/SameTermBOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/SameTermBOp.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/SameTermBOp.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -0,0 +1,87 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. 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 +*/ + +package com.bigdata.rdf.internal.constraints; + +import java.util.Map; + +import org.openrdf.query.algebra.Compare.CompareOp; + +import com.bigdata.bop.BOp; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.IValueExpression; +import com.bigdata.bop.NV; +import com.bigdata.bop.PipelineOp; +import com.bigdata.bop.constraint.BOpConstraint; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.internal.IVUtility; + +/** + * Compare two terms for exact equality. + */ +public class SameTermBOp extends BOpConstraint { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Required shallow copy constructor. + */ + public SameTermBOp(final BOp[] values, + final Map<String, Object> annotations) { + super(values, annotations); + } + + /** + * Required deep copy constructor. + */ + public SameTermBOp(final SameTermBOp op) { + super(op); + } + + public SameTermBOp(final IValueExpression<IV> left, + final IValueExpression<IV> right) { + + super(new BOp[] { left, right }, null); + + if (left == null || right == null) + throw new IllegalArgumentException(); + + } + + public boolean accept(final IBindingSet s) { + + final IV left = ((IValueExpression<IV>) get(0)).get(s); + final IV right = ((IValueExpression<IV>) get(1)).get(s); + + if (left == null || right == null) + return true; // not yet bound. + + return left.equals(right); + + } + +} Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl3.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -29,6 +29,7 @@ import org.openrdf.query.algebra.Join; import org.openrdf.query.algebra.LeftJoin; import org.openrdf.query.algebra.MathExpr; +import org.openrdf.query.algebra.MathExpr.MathOp; import org.openrdf.query.algebra.MultiProjection; import org.openrdf.query.algebra.Not; import org.openrdf.query.algebra.Or; @@ -41,15 +42,13 @@ import org.openrdf.query.algebra.Regex; import org.openrdf.query.algebra.SameTerm; import org.openrdf.query.algebra.StatementPattern; +import org.openrdf.query.algebra.StatementPattern.Scope; import org.openrdf.query.algebra.TupleExpr; import org.openrdf.query.algebra.UnaryTupleOperator; import org.openrdf.query.algebra.Union; import org.openrdf.query.algebra.ValueConstant; import org.openrdf.query.algebra.ValueExpr; import org.openrdf.query.algebra.Var; -import org.openrdf.query.algebra.Compare.CompareOp; -import org.openrdf.query.algebra.MathExpr.MathOp; -import org.openrdf.query.algebra.StatementPattern.Scope; import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl; import org.openrdf.query.algebra.evaluation.iterator.FilterIterator; import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; @@ -61,12 +60,12 @@ import com.bigdata.bop.IConstant; import com.bigdata.bop.IConstraint; import com.bigdata.bop.IPredicate; +import com.bigdata.bop.IPredicate.Annotations; import com.bigdata.bop.IValueExpression; import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; import com.bigdata.bop.NV; import com.bigdata.bop.PipelineOp; -import com.bigdata.bop.IPredicate.Annotations; import com.bigdata.bop.ap.Predicate; import com.bigdata.bop.constraint.AND; import com.bigdata.bop.constraint.BOUND; @@ -84,15 +83,16 @@ import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.constraints.CompareBOp; import com.bigdata.rdf.internal.constraints.MathBOp; +import com.bigdata.rdf.internal.constraints.SameTermBOp; import com.bigdata.rdf.lexicon.LexiconRelation; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.sail.BigdataSail.Options; import com.bigdata.rdf.sail.sop.SOp; import com.bigdata.rdf.sail.sop.SOp2BOpUtility; import com.bigdata.rdf.sail.sop.SOpTree; +import com.bigdata.rdf.sail.sop.SOpTree.SOpGroup; import com.bigdata.rdf.sail.sop.SOpTreeBuilder; import com.bigdata.rdf.sail.sop.UnsupportedOperatorException; -import com.bigdata.rdf.sail.sop.SOpTree.SOpGroup; import com.bigdata.rdf.spo.DefaultGraphSolutionExpander; import com.bigdata.rdf.spo.ExplicitSPOFilter; import com.bigdata.rdf.spo.ISPO; @@ -118,7 +118,6 @@ import com.bigdata.striterator.Dechunkerator; import com.bigdata.striterator.DistinctFilter; import com.bigdata.striterator.IChunkedOrderedIterator; -import com.bigdata.util.concurrent.Haltable; /** * Extended to rewrite Sesame {@link TupleExpr}s onto native {@link Rule}s and @@ -516,6 +515,59 @@ } + @Override + public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( + final Filter filter, final BindingSet bs) + throws QueryEvaluationException { + + if (!nativeJoins) { + // Use Sesame 2 evaluation + return super.evaluate(filter, bs); + } + + if (filter.getArg() instanceof StatementPattern) { + // no need to run a query for this, a simple access path scan will do + return super.evaluate(filter, bs); + } + + if (log.isInfoEnabled()) { + log.info("evaluating top-level Filter operator"); + } + + try { + + return evaluateNatively(filter, bs); + + } catch (UnsupportedOperatorException ex) { + + if (allowSesameQueryEvaluation) { + + // Use Sesame 2 evaluation + + log.warn("could not evaluate natively, using Sesame evaluation"); + + if (log.isInfoEnabled()) { + log.info(ex.getOperator()); + } + + // turn off native joins for the remainder, we can't do + // partial execution + nativeJoins = false; + + // defer to Sesame + return super.evaluate(filter, bs); + + } else { + + // allow the query to fail + throw new UnsupportedOperatorException(ex); + + } + + } + + } + CloseableIteration<BindingSet, QueryEvaluationException> evaluateNatively(final TupleExpr tupleExpr, final BindingSet bs) throws QueryEvaluationException, UnsupportedOperatorException { @@ -706,7 +758,7 @@ queryEngine, queryHints); if (log.isInfoEnabled()) - log.info(BOpUtility.toString(query)); + log.info("\n"+BOpUtility.toString2(query)); } @@ -737,6 +789,11 @@ result = new FilterIterator(f, result, this); } } + +// System.err.println("results"); +// while (result.hasNext()) { +// System.err.println(result.next()); +// } return result; @@ -1832,10 +1889,13 @@ toValueExpression(sameTerm.getLeftArg()); final IValueExpression<IV> iv2 = toValueExpression(sameTerm.getRightArg()); - return new CompareBOp(iv1, iv2, CompareOp.EQ); + return new SameTermBOp(iv1, iv2); } - private IConstraint toConstraint(Compare compare) { + private IConstraint toConstraint(final Compare compare) { + if (!database.isInlineLiterals()) { + throw new UnsupportedOperatorException(compare); + } final IValueExpression<IV> iv1 = toValueExpression(compare.getLeftArg()); final IValueExpression<IV> iv2 = Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -382,7 +382,7 @@ public static final String NEW_EVAL_STRATEGY = BigdataSail.class.getPackage() .getName()+ ".newEvalStrategy"; - public static final String DEFAULT_NEW_EVAL_STRATEGY = "false"; + public static final String DEFAULT_NEW_EVAL_STRATEGY = "true"; /** * Option as to whether or not to allow Sesame evaluation of queries @@ -396,8 +396,6 @@ public static final String DEFAULT_ALLOW_SESAME_QUERY_EVALUATION = "false"; - - } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -598,27 +598,35 @@ final Collection<IConstraint> constraints = new LinkedList<IConstraint>(); - /* - * Peek through the predicate's args to find its variables. Use - * these to attach constraints to the join based on the variables - * that make their first appearance in this tail. - */ - for (BOp arg : pred.args()) { - if (arg instanceof IVariable<?>) { - final IVariable<?> v = (IVariable<?>) arg; - /* - * We do a remove because we don't ever need to run these - * constraints again during subsequent joins once they have - * been run once at the initial appearance of the variable. - * - * @todo revisit this when we dynamically re-order running - * joins - */ - if (constraintsByVar.containsKey(v)) - constraints.addAll(constraintsByVar.remove(v)); - } +// /* +// * Peek through the predicate's args to find its variables. Use +// * these to attach constraints to the join based on the variables +// * that make their first appearance in this tail. +// */ +// for (BOp arg : pred.args()) { +// if (arg instanceof IVariable<?>) { +// final IVariable<?> v = (IVariable<?>) arg; +// /* +// * We do a remove because we don't ever need to run these +// * constraints again during subsequent joins once they have +// * been run once at the initial appearance of the variable. +// * +// * @todo revisit this when we dynamically re-order running +// * joins +// */ +// if (constraintsByVar.containsKey(v)) +// constraints.addAll(constraintsByVar.remove(v)); +// } +// } + + // just add all the constraints to the very last tail for now + if (i == (order.length-1) && rule.getConstraintCount() > 0) { + final Iterator<IConstraint> it = rule.getConstraints(); + while (it.hasNext()) { + constraints.add(it.next()); + } } - + // annotations for this join. final List<NV> anns = new LinkedList<NV>(); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTree.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTree.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTree.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -153,6 +153,10 @@ return SOpTree.this; } + public boolean isRoot() { + return group == 0; + } + } public class SOpGroups implements Iterable<SOpGroup> { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTreeBuilder.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTreeBuilder.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOpTreeBuilder.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -234,7 +234,8 @@ } else if (arg instanceof Join) { collectSOps(sops, (Join) arg, rslj, g, pg); } else if (arg instanceof LeftJoin) { - collectSOps(sops, (LeftJoin) arg, rslj, groupId.incrementAndGet(), g); +// collectSOps(sops, (LeftJoin) arg, rslj, groupId.incrementAndGet(), g); + collectSOps(sops, (LeftJoin) arg, rslj, g, pg); } else { throw new UnsupportedOperatorException(arg); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2011-01-19 22:42:44 UTC (rev 4134) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2011-01-20 02:05:21 UTC (rev 4135) @@ -212,6 +212,29 @@ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/basic/manifest#spoo-1",//BOOM // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/graph/manifest#dawg-graph-05", + + /* + * working through the new query engine failures + */ + + // please someone explain this shit to me +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-12" + + // this is that weird "well designed" optional shit P = A OPT (B OPT C) where A and C share variables not in B +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#nested-opt-1" + + // where do we put the !bound(?e) constraint??? +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/bound/manifest#dawg-bound-query-001" + + // "a" and "a"^^xsd:string have different term ids? also bnodes are different +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/open-world/manifest#open-eq-07" + + // help, non-optional subquery?? wtf +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest#filter-scope-1" + + // this uncovers an obvious bug in our SubqueryOp +// "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-001" + }); /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |