|
From: <tho...@us...> - 2010-10-01 16:02:04
|
Revision: 3714
http://bigdata.svn.sourceforge.net/bigdata/?rev=3714&view=rev
Author: thompsonbry
Date: 2010-10-01 16:01:57 +0000 (Fri, 01 Oct 2010)
Log Message:
-----------
Added BOpBase#setProperty() and #setUnboundProperty().
Added an expander pattern for an empty access path and hooked it into the named graph decision tree.
Modified Paths:
--------------
branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java
branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IPredicate.java
branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java
branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java
branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java
branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java
Added Paths:
-----------
branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/EmptyAccessPathExpander.java
Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -412,7 +412,7 @@
* @param value
* The value.
*/
- protected void setProperty(final String name, final Object value) {
+ protected void _setProperty(final String name, final Object value) {
annotations.put(name,value);
@@ -429,11 +429,56 @@
* @param name
* The name.
*/
- protected void clearProperty(final String name) {
+ protected void _clearProperty(final String name) {
annotations.remove(name);
}
+
+ /**
+ * Unconditionally sets the property.
+ *
+ * @param name
+ * The name.
+ * @param value
+ * The value.
+ *
+ * @return A copy of this {@link BOp} on which the property has been set.
+ */
+ public BOpBase setProperty(final String name, final Object value) {
+
+ final BOpBase tmp = this.clone();
+
+ tmp._setProperty(name, value);
+
+ return tmp;
+
+ }
+
+ /**
+ * Conditionally sets the property.
+ *
+ * @param name
+ * The name.
+ * @param value
+ * The value.
+ *
+ * @return A copy of this {@link BOp} on which the property has been set.
+ *
+ * @throws IllegalStateException
+ * if the property is already set.
+ */
+ public BOpBase setUnboundProperty(final String name, final Object value) {
+
+ final BOpBase tmp = this.clone();
+
+ if (tmp.annotations.put(name, value) != null)
+ throw new IllegalStateException("Already set: name=" + name
+ + ", value=" + value);
+
+ return tmp;
+
+ }
public int getId() {
Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IPredicate.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IPredicate.java 2010-10-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IPredicate.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -44,7 +44,6 @@
import com.bigdata.relation.accesspath.AccessPath;
import com.bigdata.relation.accesspath.ElementFilter;
import com.bigdata.relation.accesspath.IAccessPath;
-import com.bigdata.relation.accesspath.IElementFilter;
import com.bigdata.relation.rule.IRule;
import com.bigdata.relation.rule.ISolutionExpander;
import com.bigdata.relation.rule.eval.IEvaluationPlan;
@@ -76,6 +75,9 @@
*
* FIXME Change this to be a scalar value. It is currently an array for
* backwards compatibility.
+ *
+ * @see https://sourceforge.net/apps/trac/bigdata/ticket/180 (Migrate
+ * the RDFS inference and truth maintenance logic to BOPs)
*/
String RELATION_NAME = "relationName";
@@ -155,9 +157,22 @@
String ACCESS_PATH_FILTER = "accessPathFilter";
/**
- * Expander pattern.
+ * Access path expander pattern. This allows you to wrap or replace the
+ * {@link IAccessPath}.
+ * <p>
+ * Note: You MUST be extremely careful when using this feature in
+ * scale-out. Access path expanders in scale-out are logically
+ * consistent with used with a {@link #REMOTE_ACCESS_PATH}, but remote
+ * access paths often lack the performance of a local access path.
+ * <p>
+ * In order for the expander to be consistent with a local access path
+ * it MUST NOT rewrite the predicate in such a manner as to read on data
+ * onto found on the shard onto which the predicate was mapped during
+ * query evaluation.
+ *
+ * @see ISolutionExpander
*/
- String EXPANDER = "expander";
+ String ACCESS_PATH_EXPANDER = "accessPathExpander";
/**
* The partition identifier -or- <code>-1</code> if the predicate does
@@ -335,7 +350,7 @@
*
* @return The {@link ISolutionExpander}.
*
- * @see Annotations#EXPANDER
+ * @see Annotations#ACCESS_PATH_EXPANDER
*
* @todo replace with {@link ISolutionExpander#getAccessPath(IAccessPath)},
* which is the only method declared by {@link ISolutionExpander}.
Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java 2010-10-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -148,7 +148,7 @@
new NV(Annotations.OPTIONAL,optional),//
new NV(Annotations.INDEX_LOCAL_FILTER,
ElementFilter.newInstance(constraint)),//
- new NV(Annotations.EXPANDER,expander),//
+ new NV(Annotations.ACCESS_PATH_EXPANDER,expander),//
new NV(Annotations.TIMESTAMP, timestamp)
}));
@@ -197,7 +197,7 @@
// throw new UnsupportedOperationException();
final Predicate<E> tmp = this.clone();
- tmp.setProperty(Annotations.RELATION_NAME, relationName);
+ tmp._setProperty(Annotations.RELATION_NAME, relationName);
return tmp;
@@ -260,7 +260,7 @@
@SuppressWarnings("unchecked")
final public ISolutionExpander<E> getSolutionExpander() {
- return (ISolutionExpander<E>) getProperty(Annotations.EXPANDER);
+ return (ISolutionExpander<E>) getProperty(Annotations.ACCESS_PATH_EXPANDER);
}
@@ -374,7 +374,7 @@
final Predicate<E> tmp = this.clone();
- tmp.setProperty(Annotations.KEY_ORDER, keyOrder);
+ tmp._setProperty(Annotations.KEY_ORDER, keyOrder);
return tmp;
@@ -391,7 +391,7 @@
final Predicate<E> tmp = this.clone();
- tmp.setProperty(Annotations.PARTITION_ID, partitionId);
+ tmp._setProperty(Annotations.PARTITION_ID, partitionId);
return tmp;
@@ -401,7 +401,7 @@
final Predicate<E> tmp = this.clone();
- tmp.setProperty(Annotations.BOP_ID, bopId);
+ tmp._setProperty(Annotations.BOP_ID, bopId);
return tmp;
@@ -411,7 +411,7 @@
final Predicate<E> tmp = this.clone();
- tmp.setProperty(Annotations.TIMESTAMP, timestamp);
+ tmp._setProperty(Annotations.TIMESTAMP, timestamp);
return tmp;
@@ -479,14 +479,14 @@
/*
* Set the filter.
*/
- setProperty(Annotations.INDEX_LOCAL_FILTER, filter);
+ _setProperty(Annotations.INDEX_LOCAL_FILTER, filter);
} else {
/*
* Wrap the filter.
*/
- setProperty(Annotations.INDEX_LOCAL_FILTER, new FilterBase() {
+ _setProperty(Annotations.INDEX_LOCAL_FILTER, new FilterBase() {
@Override
protected Iterator filterOnce(Iterator src, Object context) {
@@ -511,7 +511,7 @@
for(String name : names) {
- tmp.clearProperty(name);
+ tmp._clearProperty(name);
}
Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java 2010-10-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -79,6 +79,7 @@
import com.bigdata.relation.IRelation;
import com.bigdata.relation.accesspath.ElementFilter;
import com.bigdata.relation.accesspath.IElementFilter;
+import com.bigdata.relation.rule.EmptyAccessPathExpander;
import com.bigdata.relation.rule.IProgram;
import com.bigdata.relation.rule.IRule;
import com.bigdata.relation.rule.IStep;
@@ -107,7 +108,7 @@
* <p>
* Note: When enabled, the {@link NamedGraphSolutionExpander} and
* {@link DefaultGraphSolutionExpander} must be stripped from the
- * {@link IPredicate.Annotations#EXPANDER}. In the long term, we will simply
+ * {@link IPredicate.Annotations#ACCESS_PATH_EXPANDER}. In the long term, we will simply
* no longer generate them in {@link BigdataEvaluationStrategyImpl}.
* <p>
* Note: If you want to test just the named graph stuff, then the default
@@ -349,12 +350,11 @@
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.
+ * constraints again during subsequent joins once they have
+ * been run once at the initial appearance of the variable.
*
- * FIXME revisit this when we dynamically re-order running
- * joins
+ * @todo revisit this when we dynamically re-order running
+ * joins
*/
if (constraintsByVar.containsKey(v))
constraints.addAll(constraintsByVar.remove(v));
@@ -406,7 +406,7 @@
* the long term it will simply not be generated.)
*/
pred = pred
- .clearAnnotations(new String[] { IPredicate.Annotations.EXPANDER });
+ .clearAnnotations(new String[] { IPredicate.Annotations.ACCESS_PATH_EXPANDER });
switch (scope) {
case NAMED_CONTEXTS:
@@ -532,21 +532,16 @@
/*
* The data set is empty (no graphs). Return a join backed by an
* empty access path.
- *
- * Note: Since the join could be optional or part of an optional
- * join group, we can not just drop it. Instead we need to return a
- * join against an empty access path. Since the join could also
- * "select" for some subset of variables, it seems that we really
- * need to modify PipelineJoin to recognize an annotation indicating
- * an empty access path. It can then substitute the empty access
- * path when processing the source binding sets. There should be
- * unit tests for this.
- *
- * FIXME Return PipelineJoin with an EMPTY ACCESS PATH.
*/
-
- throw new UnsupportedOperationException();
-
+
+ // force an empty access path for this predicate.
+ pred = (Predicate) pred.setUnboundProperty(
+ IPredicate.Annotations.ACCESS_PATH_EXPANDER,
+ EmptyAccessPathExpander.INSTANCE);
+
+ return new PipelineJoin(new BOp[] { left, pred }, anns
+ .toArray(new NV[anns.size()]));
+
} else if (summary.nknown == 1) {
/*
Added: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/EmptyAccessPathExpander.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/EmptyAccessPathExpander.java (rev 0)
+++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/EmptyAccessPathExpander.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -0,0 +1,67 @@
+/**
+
+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
+*/
+/*
+ * Created on Oct 1, 2010
+ */
+
+package com.bigdata.relation.rule;
+
+import com.bigdata.relation.accesspath.EmptyAccessPath;
+import com.bigdata.relation.accesspath.IAccessPath;
+
+/**
+ * An "expander" which replaces the access path with an {@link EmptyAccessPath}.
+ *
+ * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
+ * @version $Id$
+ */
+public class EmptyAccessPathExpander<E> implements ISolutionExpander<E> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static transient final EmptyAccessPathExpander INSTANCE = new EmptyAccessPathExpander();
+
+ public IAccessPath<E> getAccessPath(IAccessPath<E> accessPath) {
+
+ return new EmptyAccessPath<E>(accessPath.getPredicate(), accessPath
+ .getKeyOrder());
+
+ }
+
+ public boolean runFirst() {
+
+ return false;
+
+ }
+
+ public boolean backchain() {
+
+ return false;
+
+ }
+
+}
Property changes on: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/EmptyAccessPathExpander.java
___________________________________________________________________
Added: svn:keywords
+ Id Date Revision Author HeadURL
Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java
===================================================================
--- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java 2010-10-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -189,7 +189,7 @@
// expander);
super(new IVariableOrConstant[] { s, p, o }, //
new NV(Annotations.RELATION_NAME, new String[]{relationName}), //
- new NV(Annotations.EXPANDER, expander));
+ new NV(Annotations.ACCESS_PATH_EXPANDER, expander));
}
@@ -216,7 +216,7 @@
super(new IVariableOrConstant[] { s, p, o }, //
new NV(Annotations.RELATION_NAME, new String[]{relationName}), //
new NV(Annotations.OPTIONAL, optional), //
- new NV(Annotations.EXPANDER, expander));
+ new NV(Annotations.ACCESS_PATH_EXPANDER, expander));
}
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-01 15:36:09 UTC (rev 3713)
+++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-01 16:01:57 UTC (rev 3714)
@@ -1522,7 +1522,7 @@
// free text search expander or named graphs expander
if (expander != null)
- anns.add(new NV(IPredicate.Annotations.EXPANDER, expander));
+ anns.add(new NV(IPredicate.Annotations.ACCESS_PATH_EXPANDER, expander));
// timestamp
anns.add(new NV(IPredicate.Annotations.TIMESTAMP, database
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|