From: <mrp...@us...> - 2011-04-07 23:11:03
|
Revision: 4380 http://bigdata.svn.sourceforge.net/bigdata/?rev=4380&view=rev Author: mrpersonick Date: 2011-04-07 23:10:56 +0000 (Thu, 07 Apr 2011) Log Message: ----------- modified to allow single optional tails with optional scope filters Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/join/PipelineJoin.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/SOp2BOpUtility.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/join/PipelineJoin.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/join/PipelineJoin.java 2011-04-07 15:24:39 UTC (rev 4379) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/join/PipelineJoin.java 2011-04-07 23:10:56 UTC (rev 4380) @@ -1714,6 +1714,11 @@ * binding set(s) to the sink join task(s), but the * original binding set still must pass any constraint * on the join. + * + * Note: Changed this back to the other semantics: + * optional joins need not pass the constraints when + * no binding sets were accepted. Use conditional + * routing op after the join instead. */ // Thread-local buffer iff optional sink is in use. @@ -1727,12 +1732,12 @@ final IBindingSet bs = bindingSets[bindex]; - if (constraints != null) { - if(!BOpUtility.isConsistent(constraints, bs)) { - // Failed by the constraint on the join. - continue; - } - } +// if (constraints != null) { +// if(!BOpUtility.isConsistent(constraints, bs)) { +// // Failed by the constraint on the join. +// continue; +// } +// } if (log.isTraceEnabled()) log @@ -2130,19 +2135,19 @@ for (IBindingSet bset : bindingSets) { // #of binding sets accepted. - naccepted++; +// naccepted++; - /* #of elements accepted for this binding set. - * - * Note: We count binding sets as accepted before we - * apply the constraints. This has the effect that - * an optional join which produces solutions that - * are then rejected by a FILTER associated with the - * optional predicate WILL NOT pass on the original - * solution even if ALL solutions produced by the - * join are rejected by the filter. - */ - this.naccepted[bindex]++; +// /* #of elements accepted for this binding set. +// * +// * Note: We count binding sets as accepted before we +// * apply the constraints. This has the effect that +// * an optional join which produces solutions that +// * are then rejected by a FILTER associated with the +// * optional predicate WILL NOT pass on the original +// * solution even if ALL solutions produced by the +// * join are rejected by the filter. +// */ +// this.naccepted[bindex]++; /* * Clone the binding set since it is tested for each @@ -2171,8 +2176,11 @@ // Accept this binding set. unsyncBuffer.add(bset); -// // #of binding sets accepted. -// naccepted++; + // #of binding sets accepted. + naccepted++; + + // #of elements accepted for this binding set. + this.naccepted[bindex]++; // #of output solutions generated. stats.outputSolutions.increment(); 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-04-07 15:24:39 UTC (rev 4379) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java 2011-04-07 23:10:56 UTC (rev 4380) @@ -626,10 +626,20 @@ } public static PipelineOp join(final QueryEngine queryEngine, - PipelineOp left, Predicate pred, final AtomicInteger idFactory, - final Properties queryHints) { + final PipelineOp left, final Predicate pred, + final AtomicInteger idFactory, final Properties queryHints) { return join(queryEngine, left, pred, null, + idFactory, queryHints); + + } + + public static PipelineOp join(final QueryEngine queryEngine, + final PipelineOp left, final Predicate pred, + final Collection<IConstraint> constraints, + final AtomicInteger idFactory, final Properties queryHints) { + + return join(queryEngine, left, pred, constraints, new BOpContextBase(queryEngine), idFactory, queryHints); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOp2BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOp2BOpUtility.java 2011-04-07 15:24:39 UTC (rev 4379) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/sop/SOp2BOpUtility.java 2011-04-07 23:10:56 UTC (rev 4380) @@ -133,13 +133,43 @@ */ private static boolean isSingleOptional(final SOpGroup sopGroup) { - if (sopGroup.size() == 1 && sopGroup.getChildren() == null) { - final SOp sop = sopGroup.getSingletonSOp(); - return (sop.getOperator() instanceof StatementPattern) && - sop.isRightSideLeftJoin(); + if (log.isDebugEnabled()) { + log.debug("testing for single optional:\n" + sopGroup); } - return false; + // if the group has subqueries it's not a single optional group + if (sopGroup.getChildren() != null) { + if (log.isDebugEnabled()) { + log.debug("group has children, not single optional"); + } + return false; + } + + int numPredicates = 0; + for (SOp sop : sopGroup) { + if (sop.getOperator() instanceof StatementPattern) { + // if any predicate is not rslj we're not a single optional group + if (!sop.isRightSideLeftJoin()) { + if (log.isDebugEnabled()) { + log.debug("sop not rslj, not single optional"); + } + return false; + } + numPredicates++; + } + } + if (log.isDebugEnabled()) { + log.debug("group has numPredicates=" + numPredicates); + } + return numPredicates == 1; + +// if (sopGroup.size() == 1 && sopGroup.getChildren() == null) { +// final SOp sop = sopGroup.getSingletonSOp(); +// return (sop.getOperator() instanceof StatementPattern) && +// sop.isRightSideLeftJoin(); +// } +// return false; + } private static boolean isOptional(final SOpGroup sopGroup) { @@ -253,15 +283,22 @@ continue; if (isSingleOptional(child)) { - final SOp sop = child.getSingletonSOp(); - final BOp bop = sop.getBOp(); - Predicate pred = (Predicate) bop.setProperty( + Predicate pred = null; + final Collection<IConstraint> constraints = new LinkedList<IConstraint>(); + for (SOp sop : child) { + final BOp bop = sop.getBOp(); + if (bop instanceof IConstraint) { + constraints.add((IConstraint) bop); + } else if (bop instanceof Predicate) { + pred = (Predicate) bop; + } + } + pred = (Predicate) pred.setProperty( IPredicate.Annotations.OPTIONAL, Boolean.TRUE); pred = pred.setBOpId(idFactory.incrementAndGet()); left = Rule2BOpUtility.join( - queryEngine, left, pred, - idFactory, - queryHints); + queryEngine, left, pred, constraints, + idFactory, queryHints); } else { if (useHashJoin(queryHints)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |