From: <tho...@us...> - 2010-09-29 15:48:43
|
Revision: 3678 http://bigdata.svn.sourceforge.net/bigdata/?rev=3678&view=rev Author: thompsonbry Date: 2010-09-29 15:48:34 +0000 (Wed, 29 Sep 2010) Log Message: ----------- Cleaned up the use of the "constraint" annotation. The code should now use INDEX_LOCAL_FILTER or ACCESS_PATH_FILTER everywhere. Cleaned up a lot of the SPOPredicate and MagicPredicate constructors. Reconciled some changes in the striterators package. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/architecture/query-cost-model.xls branches/QUADS_QUERY_BRANCH/bigdata/src/architecture/segment math.xls branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.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/ap/filter/BOpFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpTupleFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/DistinctFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/SameVariableConstraintFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/notes.txt branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/btree/filter/TupleFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/counters/CounterSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractArrayBuffer.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractUnsynchronizedArrayBuffer.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AccessPath.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IAccessPath.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IElementFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/SolutionFilter.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/DistributedJoinTask.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/UnsynchronizedSolutionBuffer.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/striterator/ChunkedWrappedIterator.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicate.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicateAccessPath.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/relation/rule/eval/TestDefaultEvaluationPlan.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/AbstractSPOBuffer.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/BackchainTypeResourceIterator.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/IRISUtils.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/MagicIndexWriter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/MagicPredicate.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/MagicRelation.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rio/AsynchronousStatementBufferFactory.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/BackchainAccessPath.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/DoNotAddFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/MatchRule.java 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/ExplicitSPOFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphHashSetFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InferredSPOFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/NamedGraphSolutionExpander.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/NoAxiomFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOArrayIterator.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOIndexWriter.java 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/SPORelation.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOStarJoin.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/magic/TestIRIS.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/magic/TestMagicStore.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOPredicate.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/spo/TestSPOStarJoin.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/ExclusionFilter.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/Filter.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/Filterator.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/Striterator.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/UniquenessFilter.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/ElementFilter.java branches/QUADS_QUERY_BRANCH/ctc-striterators/src/java/cutthecrap/utils/striterators/IFilterTest.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/architecture/query-cost-model.xls =================================================================== (Binary files differ) Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/architecture/segment math.xls =================================================================== (Binary files differ) Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -175,12 +175,15 @@ * @see Annotations#MUTATION */ boolean isMutation(); - + /** * The timestamp or transaction identifier on which the operator will read * or write. * * @see Annotations#TIMESTAMP + * + * @throws IllegalStateException + * if {@link Annotations#TIMESTAMP} was not specified. */ long getTimestamp(); @@ -238,7 +241,7 @@ /** * The timestamp (or transaction identifier) used by this operator if it - * reads or writes on the database. + * reads or writes on the database (no default). * * @see #MUTATION */ 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-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -287,7 +287,7 @@ } /** deep copy the arguments. */ - static private BOp[] deepCopy(final BOp[] a) { + static protected BOp[] deepCopy(final BOp[] a) { final BOp[] t = new BOp[a.length]; for (int i = 0; i < a.length; i++) { t[i] = a[i] == null ? null : a[i].clone(); @@ -311,7 +311,7 @@ * containing an ontology or some conditional assertions with a query * plan. */ - static private Map<String,Object> deepCopy(final Map<String,Object> a) { + static protected Map<String,Object> deepCopy(final Map<String,Object> a) { // allocate map. final Map<String, Object> t = new LinkedHashMap<String, Object>(a .size()); 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 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -211,7 +211,7 @@ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(Object arg0) { + public boolean isValid(Object arg0) { return arg0 instanceof BOp; } }); @@ -314,7 +314,7 @@ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(Object arg0) { + public boolean isValid(Object arg0) { return arg0 instanceof IVariable<?>; } }); @@ -338,7 +338,7 @@ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(final Object arg0) { + public boolean isValid(final Object arg0) { return arg0 instanceof IVariable<?>; } }); 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-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IPredicate.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -41,6 +41,7 @@ import com.bigdata.mdi.PartitionLocator; import com.bigdata.relation.IRelation; 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; @@ -95,33 +96,36 @@ */ String OPTIONAL = "optional"; - /** - * Constraints on the elements read from the relation. - * - * @deprecated This is being replaced by two classes of filters. One - * which is always evaluated local to the index and one - * which is evaluated in the JVM in which the access path is - * evaluated once the {@link ITuple}s have been resolved to - * elements of the relation. - */ - String CONSTRAINT = "constraint"; +// /** +// * Constraints on the elements read from the relation. +// * +// * @deprecated This is being replaced by two classes of filters. One +// * which is always evaluated local to the index and one +// * which is evaluated in the JVM in which the access path is +// * evaluated once the {@link ITuple}s have been resolved to +// * elements of the relation. +// * <p> +// * This was historically an {@link IElementFilter}, which is +// * an {@link IFilterTest}. {@link #INDEX_LOCAL_FILTER} is an +// * {@link IFilter}. You can wrap the {@link IFilterTest} as +// * an {@link IFilter} using {@link ElementFilter}. +// */ +// String CONSTRAINT = "constraint"; /** - * An optional {@link BOpFilterBase} that will be evaluated local to the - * to the index. When the index is remote, the filter will be sent to - * the node on which the index resides and evaluated there. This makes - * it possible to efficiently filter out tuples which are not of - * interest for a given access path. + * An optional {@link IFilter} that will be evaluated local to the to + * the index. When the index is remote, the filter will be sent to the + * node on which the index resides and evaluated there. This makes it + * possible to efficiently filter out tuples which are not of interest + * for a given access path. * <p> * Note: The filter MUST NOT change the type of data visited by the * iterator - it must remain an {@link ITupleIterator}. An attempt to * change the type of the visited objects will result in a runtime - * exception. + * exception. This filter must be "aware" of the reuse of tuples within + * tuple iterators. See {@link BOpTupleFilter}, {@link TupleFilter} and + * {@link ElementFilter} for starting points. * <p> - * Note: This filter must be "aware" of the reuse of tuples within tuple - * iterators. See {@link BOpTupleFilter} and {@link TupleFilter} for - * starting points. - * <p> * You can chain {@link BOpFilterBase} filters by nesting them inside of * one another. You can chain {@link FilterBase} filters together as * well. @@ -337,20 +341,36 @@ */ public ISolutionExpander<E> getSolutionExpander(); +// /** +// * An optional constraint on the visitable elements. +// * +// * @see Annotations#CONSTRAINT +// * +// * @deprecated This is being replaced by two classes of filters. One which +// * is always evaluated local to the index and one which is +// * evaluated in the JVM in which the access path is evaluated +// * once the {@link ITuple}s have been resolved to elements of +// * the relation. +// */ +// public IElementFilter<E> getConstraint(); + /** - * An optional constraint on the visitable elements. + * Return the optional filter to be evaluated local to the index. * - * @see Annotations#CONSTRAINT - * - * @deprecated This is being replaced by two classes of filters. One which - * is always evaluated local to the index and one which is - * evaluated in the JVM in which the access path is evaluated - * once the {@link ITuple}s have been resolved to elements of - * the relation. + * @see Annotations#INDEX_LOCAL_FILTER */ - public IElementFilter<E> getConstraint(); + public IFilter getIndexLocalFilter(); /** + * Return the optional filter to be evaluated once tuples have been + * converted into relation elements by the access path (local to the + * caller). + * + * @see Annotations#ACCESS_PATH_FILTER + */ + public IFilter getAccessPathFilter(); + + /** * Return the {@link IKeyOrder} assigned to this {@link IPredicate} by the * query optimizer. * 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-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/Predicate.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -28,6 +28,7 @@ package com.bigdata.bop.ap; +import java.util.Iterator; import java.util.Map; import cern.colt.Arrays; @@ -42,12 +43,14 @@ import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; import com.bigdata.bop.NV; -import com.bigdata.btree.ITuple; -import com.bigdata.journal.ITx; +import com.bigdata.relation.accesspath.ElementFilter; import com.bigdata.relation.accesspath.IElementFilter; import com.bigdata.relation.rule.ISolutionExpander; import com.bigdata.striterator.IKeyOrder; +import cutthecrap.utils.striterators.FilterBase; +import cutthecrap.utils.striterators.IFilter; + /** * A generic implementation of an immutable {@link IPredicate}. * @@ -81,20 +84,31 @@ } /** - * Simplified ctor. - * - * @param values - * The values (order is important!). - * @param relationName - * Identifies the relation to be queried. + * Variable argument version of the shallow constructor. + * @param vars + * @param annotations */ - public Predicate(final IVariableOrConstant<?>[] values, - final String relationName) { - - this(values, relationName, -1/* partitionId */, false/* optional */, - null/* constraint */, null/* expander */, ITx.READ_COMMITTED); - + public Predicate(final BOp[] vars, final NV... annotations) { + + super(vars, NV.asMap(annotations)); + } + +// /** +// * Simplified ctor. +// * +// * @param values +// * The values (order is important!). +// * @param relationName +// * Identifies the relation to be queried. +// */ +// public Predicate(final IVariableOrConstant<?>[] values, +// final String relationName) { +// +// this(values, relationName, -1/* partitionId */, false/* optional */, +// null/* constraint */, null/* expander */, ITx.READ_COMMITTED); +// +// } /** * @@ -121,7 +135,8 @@ new NV(Annotations.RELATION_NAME,new String[]{relationName}),// new NV(Annotations.PARTITION_ID,partitionId),// new NV(Annotations.OPTIONAL,optional),// - new NV(Annotations.CONSTRAINT,constraint),// + new NV(Annotations.INDEX_LOCAL_FILTER, + ElementFilter.newInstance(constraint)),// new NV(Annotations.EXPANDER,expander),// new NV(Annotations.TIMESTAMP, timestamp) })); @@ -204,21 +219,33 @@ } - /** - * - * @deprecated This is being replaced by two classes of filters. One which - * is always evaluated local to the index and one which is - * evaluated in the JVM in which the access path is evaluated - * once the {@link ITuple}s have been resolved to elements of - * the relation. - */ - @SuppressWarnings("unchecked") - final public IElementFilter<E> getConstraint() { +// /** +// * +// * @deprecated This is being replaced by two classes of filters. One which +// * is always evaluated local to the index and one which is +// * evaluated in the JVM in which the access path is evaluated +// * once the {@link ITuple}s have been resolved to elements of +// * the relation. +// */ +// @SuppressWarnings("unchecked") +// final public IElementFilter<E> getConstraint() { +// +// return (IElementFilter<E>) getProperty(Annotations.CONSTRAINT); +// +// } - return (IElementFilter<E>) getProperty(Annotations.CONSTRAINT); + final public IFilter getIndexLocalFilter() { + return (IFilter) getProperty(Annotations.INDEX_LOCAL_FILTER); + } + final public IFilter getAccessPathFilter() { + + return (IFilter) getProperty(Annotations.ACCESS_PATH_FILTER); + + } + @SuppressWarnings("unchecked") final public ISolutionExpander<E> getSolutionExpander() { @@ -362,6 +389,96 @@ } + public Predicate<E> setTimestamp(final long timestamp) { + + final Predicate<E> tmp = this.clone(); + + tmp.setProperty(Annotations.TIMESTAMP, timestamp); + + return tmp; + + } + + /** + * Add an {@link Annotations#INDEX_LOCAL_FILTER}. When there is a filter for + * the named property, the filters are combined. Otherwise the filter is + * set. + * + * @param filter + * The filter. + * + * @return The new predicate to which that filter was added. + */ + public Predicate<E> addIndexLocalFilter(final IFilter filter) { + + final Predicate<E> tmp = this.clone(); + + tmp.addFilter(Annotations.INDEX_LOCAL_FILTER, filter); + + return tmp; + + } + + /** + * Add an {@link Annotations#INDEX_LOCAL_FILTER}. When there is a filter for + * the named property, the filters are combined. Otherwise the filter is + * set. + * + * @param filter + * The filter. + * + * @return The new predicate to which that filter was added. + */ + public Predicate<E> addAccessPathFilter(final IFilter filter) { + + final Predicate<E> tmp = this.clone(); + + tmp.addFilter(Annotations.ACCESS_PATH_FILTER, filter); + + return tmp; + + } + + /** + * Private method used to add a filter. When there is a filter for the named + * property, the filters are combined. Otherwise the filter is set. DO NOT + * use this outside of the copy-on-write helper methods. + * + * @param name + * The property name. + * @param filter + * The filter. + */ + private void addFilter(final String name, final IFilter filter) { + + if (filter == null) + throw new IllegalArgumentException(); + + final IFilter current = (IFilter) getProperty(name); + + if (current == null) { + + /* + * Set the filter. + */ + setProperty(Annotations.INDEX_LOCAL_FILTER, filter); + + } else { + + /* + * Wrap the filter. + */ + setProperty(Annotations.INDEX_LOCAL_FILTER, new FilterBase() { + + @Override + protected Iterator filterOnce(Iterator src, Object context) { + return src; + } + }.addFilter(current).addFilter(filter)); + } + + } + public String toString() { return toString(null/* bindingSet */); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -98,7 +98,7 @@ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(Object obj) { + public boolean isValid(Object obj) { return BOpFilter.this.isValid(obj); } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpTupleFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpTupleFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/BOpTupleFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -40,6 +40,8 @@ import com.bigdata.btree.filter.TupleFilter; import com.bigdata.btree.filter.TupleFilter.TupleFilterator; +import cutthecrap.utils.striterators.IFilterTest; + /** * <p> * Filter supporting {@link ITupleIterator}s. @@ -99,6 +101,34 @@ super(args, annotations); } +// /** +// * Convenience method wraps the {@link IFilterTest} as a +// * {@link BOpTupleFilter}. +// * +// * @param test +// * The test (optional). +// * +// * @return The filter wrapping the test -or- <code>null</code> if the +// * argument is <code>null</code>. +// */ +// @SuppressWarnings("unchecked") +// public static BOpFilterBase newInstance(final IFilterTest test) { +// +// if (test == null) { +// // No test. No filter. +// return null; +// } +// +// return new BOpTupleFilter(new BOp[0]/*filters*/,null/*annotations*/) { +// private static final long serialVersionUID = 1L; +// @Override +// protected boolean isValid(ITuple obj) { +// return test.isValid(obj); +// } +// }; +// +// } + @Override final protected Iterator filterOnce(Iterator src, final Object context) { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/DistinctFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/DistinctFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/DistinctFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -94,14 +94,14 @@ private final LinkedHashSet members; public DistinctFilterImpl() { - + members = new LinkedHashSet(getInitialCapacity(), getLoadFactor()); } @SuppressWarnings("unchecked") @Override - protected boolean isValid(Object obj) { + public boolean isValid(Object obj) { return members.add(obj); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/SameVariableConstraintFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/SameVariableConstraintFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/ap/filter/SameVariableConstraintFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -94,7 +94,7 @@ } @Override - protected boolean isValid(Object obj) { + public boolean isValid(Object obj) { return filter.accept(obj); 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-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/Rule2BOpUtility.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -69,8 +69,6 @@ * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ - * - * FIXME Implement Rule2BOpUtility. */ public class Rule2BOpUtility { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/notes.txt =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/notes.txt 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/notes.txt 2010-09-29 15:48:34 UTC (rev 3678) @@ -508,45 +508,64 @@ Here is what I have not done yet: -Write unit tests to sanity check these changes. +- Striterator unit tests. -done. Replace (I)FilterConstructor with IFilter. FilterConstructor -implemented clone. I am not sure that I can recall why. Presumably -because a cloned would have a distinct filter chain. We can not -easily override clone() on FilterBase because of all the derived -versions. We could have a deep copy constructor pattern, which is -what I did for the BOpBase class and then use that for clone. +- Bop-erator tests. -Write unit tests at the IPredicate/AccessPath level to use stackable -filters (for the LOCAL and REMOTE access paths). Write unit tests for -correct range counts with and without local/remote filters. Write -unit tests for caching of those range counts. +- MGC: All of the Filterators need to use deferred prefetch. Prefetch + during the constructor causes problems when we are stacking filters + using FilterBase. (This is also true for the ITuple filters). -- The stacking of the BOpFilters may be counter intuitive or just - wrong. +- BT: Write unit tests at the IPredicate/AccessPath level to use + stackable filters (for the LOCAL and REMOTE access paths). Write + unit tests for correct range counts with and without local/remote + filters. Write unit tests for caching of those range counts. -- TestPredicateAccessPath#test_localFilter() does not report the - correct tuples. This is weirdness with reuse of the same backing - Tuple object. See TupleFilter and BOpFilter. The filter that is - being applied in the unit test does not protect against the tuple - reuse. It would be best to automatically wrap such asserts. E.g., - BOpTupleFilter. It would also be good to catch runtime type - problems with this. E.g., if the source iterator is ITupleFilter - then it is an error to wrap with BOpFilter. You must use - BOpTupleFilter instead. - - Write BOp versions for TupleResolver, ... -- All of the Filterators need to use deferred prefetch. Prefetch - during the constructor causes problems when we are stacking filters - using FilterBase. +- done. IPredicate#getConstraint() must go (issues remain with + BackchainAccessPath). -IPredicate#getConstraint() must go. This will require touching the -backchainer classes. The (SPO|Magic)Predicate contructors should also -be touched up since they will otherwise DROP the local and remote -filters. +- The (SPO|Magic)Predicate contructors must be touched up. -Reconcile IElementFilter and implementations. + - They assume an IElementFilter (IFilterTest). However, the filters + are now specified with IFilter. + - Those constructor will DROP the local and remote filters unless + the logic is modified. + + - When used remotely, IElementFilter must do ITuple.getObject() and + MUST be wrapped using ElementFilter to be "Tuple" aware (problem + with Tuple reference reuse inside the ITupleIterators). + + - Reconcile IElementFilter and implementations. IElementFilter was + transparently wrapped by AccessPath to resolve the ITuple to the + element before applying the filter. If IElementFilter is used in + contexts other than the index then all implementations must be + modified to conditionally resolve the element while filtering. + + - IPredicates created from a Relation MUST use the timestamp of that + relation NOT READ_COMMITTED. Remove the default timestamp + annotation. Make this required where it is used so we can track + all of this down. + +MikeP: + + - BackchainAccessPath. Are the index local or access path filters + ever used here? If they are then this code needs to be modified. + + - The timestamp on which the backchain access path will read MUST be + passed through to the IPredicate constructors. + + - Leave C as an anonymous variable when it will not be used, not + null. + + - Replace NamedGraph and DefaultGraph access paths per the decision + tree and cost model. + + - Set the TIMESTAMP on the predicate. + + - Additional SPOPredicate and Predicate constructor cleanup. + Reconcile the com.bigdata.striterators package. Can we get rid of it? Incrementally? Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/btree/filter/TupleFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/btree/filter/TupleFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/btree/filter/TupleFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -56,16 +56,19 @@ private static final long serialVersionUID = 1L; protected static transient final Logger log = Logger.getLogger(TupleFilter.class); - -// /** -// * Optional state specified by the ctor. -// */ -// protected Object state; - + public TupleFilter() { + this(null/* state */); + } + public TupleFilter(final Object state) { + + super(state); + + } + @SuppressWarnings("unchecked") @Override public ITupleIterator<E> filterOnce(final Iterator src,Object context) { @@ -73,21 +76,14 @@ return new TupleFilter.TupleFilterator((ITupleIterator) src, context, this); } -/* - public Iterator filterOnce(Iterator src, Object context) { - return new TupleFilter.Filterator((ITupleIterator) src); + abstract protected boolean isValid(ITuple<E> tuple); - } -*/ - abstract protected boolean isValid(ITuple<E> tuple); - /** * Implementation class knows how to avoid side-effects from the reuse of * the same {@link Tuple} instance by the base {@link ITupleIterator} impls. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ * @param <E> */ static public class TupleFilterator<E> implements ITupleIterator<E> { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/counters/CounterSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/counters/CounterSet.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/counters/CounterSet.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -361,7 +361,7 @@ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(Object val) { + public boolean isValid(Object val) { final ICounter counter = (ICounter) val; Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractArrayBuffer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractArrayBuffer.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractArrayBuffer.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -119,7 +119,7 @@ if (filter != null) { - if(!filter.accept(e)) { + if(!filter.isValid(e)) { // rejected by the filter. Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractUnsynchronizedArrayBuffer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractUnsynchronizedArrayBuffer.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AbstractUnsynchronizedArrayBuffer.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -139,7 +139,7 @@ if (filter != null && filter.canAccept(e)) { - return filter.accept(e); + return filter.isValid(e); } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AccessPath.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AccessPath.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/AccessPath.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -124,7 +124,16 @@ protected final int chunkCapacity; protected final int fullyBufferedReadThreshold; + /** + * <code>true</code> iff the {@link IPredicate}is fully bound. + */ private final boolean isFullyBoundForKey; + + /** + * <code>true</code> iff there is a filter for the access path (either local + * or remote). + */ + private final boolean hasFilter; /** * <code>true</code> iff all elements in the predicate which are required @@ -399,6 +408,9 @@ this.accessPathFilter = (BOpFilterBase) predicate .getProperty(IPredicate.Annotations.ACCESS_PATH_FILTER); + // true iff there is a filter (either local or remote). + this.hasFilter = (indexLocalFilter != null || accessPathFilter != null); + final IKeyBuilder keyBuilder = ndx.getIndexMetadata() .getTupleSerializer().getKeyBuilder(); @@ -408,41 +420,6 @@ } -// /** -// * Align the predicate's {@link IElementFilter} constraint with -// * {@link ITupleFilter} so that the {@link IElementFilter} can be evaluated -// * close to the data by an {@link ITupleIterator}. -// * -// * @author <a href="mailto:tho...@us...">Bryan Thompson</a> -// * @version $Id$ -// * @param <R> -// * The generic type of the elements presented to the filter. -// */ -// public static class ElementFilter<R> extends TupleFilter<R> { -// -// private static final long serialVersionUID = 1L; -// -// private final IElementFilter<R> constraint; -// -// public ElementFilter(final IElementFilter<R> constraint) { -// -// if (constraint == null) -// throw new IllegalArgumentException(); -// -// this.constraint = constraint; -// -// } -// -// public boolean isValid(final ITuple<R> tuple) { -// -// final R obj = (R) tuple.getObject(); -// -// return constraint.accept( obj ); -// -// } -// -// } - public String toString() { return getClass().getName() @@ -1148,19 +1125,12 @@ } - /** - * Note: When there is a {@link IPredicate#getConstraint()} on the - * {@link IPredicate} the exact range count will apply that constraint as a - * filter during traversal. However, the constraint is ignored for the fast - * range count. - */ final public long rangeCount(final boolean exact) { assertInitialized(); long n = 0L; - final boolean hasFilter = (indexLocalFilter != null || accessPathFilter != null); if (exact) { /* Added: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/ElementFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/ElementFilter.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/ElementFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -0,0 +1,89 @@ +/** + +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 Sep 29, 2010 + */ + +package com.bigdata.relation.accesspath; + +import com.bigdata.btree.ITuple; +import com.bigdata.btree.ITupleIterator; +import com.bigdata.btree.filter.ITupleFilter; +import com.bigdata.btree.filter.TupleFilter; + +import cutthecrap.utils.striterators.IFilter; + +/** + * Align the predicate's {@link IElementFilter} constraint with + * {@link ITupleFilter} so that the {@link IElementFilter} can be evaluated + * close to the data by an {@link ITupleIterator}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + * @param <R> + * The generic type of the elements presented to the filter. + */ +public class ElementFilter<R> extends TupleFilter<R> { + + private static final long serialVersionUID = 1L; + + private final IElementFilter<R> test; + + /** + * Helper method conditionally wraps the <i>test</i>. + * + * @param <R> + * @param test + * The test. + * + * @return The wrapper test -or- <code>null</code> iff the <i>test</i> is + * <code>null</code>. + */ + public static <R> IFilter newInstance(final IElementFilter<R> test) { + + if (test == null) + return null; + + return new ElementFilter<R>(test); + + } + + public ElementFilter(final IElementFilter<R> test) { + + if (test == null) + throw new IllegalArgumentException(); + + this.test = test; + + } + + public boolean isValid(final ITuple<R> tuple) { + + final R obj = (R) tuple.getObject(); + + return test.isValid(obj); + + } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/ElementFilter.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IAccessPath.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IAccessPath.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IAccessPath.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -39,6 +39,8 @@ import com.bigdata.striterator.IChunkedOrderedIterator; import com.bigdata.striterator.IKeyOrder; +import cutthecrap.utils.striterators.IFilter; + /** * An abstraction for efficient reads on an {@link IRelation} using the index * selected by an {@link IPredicate} constraint. Like their {@link #iterator()}, @@ -71,14 +73,20 @@ * empty (there may be "deleted" index entries within the key range). */ public boolean isEmpty(); - + /** * Return the maximum #of elements spanned by the {@link IPredicate}. + * <p> + * Note: When there is an {@link IFilter} on the {@link IPredicate} the + * exact range count MUST apply that {@link IFilter}, which means that it + * will be required to traverse the index counting tuples which pass the + * {@link IFilter}. However, {@link IFilter}s are ignored for the fast + * range count. * * @param exact - * When <code>true</code>, the result will be an exact count - * and may require a key-range scan. When <code>false</code>, - * the result will be an upper bound IFF delete markers are + * When <code>true</code>, the result will be an exact count and + * may require a key-range scan. When <code>false</code>, the + * result will be an upper bound IFF delete markers are * provisioned for the backing index (delete markers are required * for transactions and for scale-out indices). * Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IElementFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IElementFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/accesspath/IElementFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -30,30 +30,25 @@ import java.io.Serializable; -import cutthecrap.utils.striterators.IFilter; +import cutthecrap.utils.striterators.IFilterTest; /** * Filter for accepting or rejecting visited elements. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ - * - * @todo Can we replace this with an interface declared by CTC with isValid() or - * just the CTC {@link IFilter} so we allow non-filtering striterators to - * be applied as well? */ -public interface IElementFilter<E> extends // BOp, - Serializable { +public interface IElementFilter<E> extends IFilterTest, Serializable { - /** - * True iff the argument is matched by the filter. - * - * @param e - * An element. - * - * @return true iff the element is accepted by the filter. - */ - public boolean accept(E e); +// /** +// * True iff the argument is matched by the filter. +// * +// * @param e +// * An element. +// * +// * @return true iff the element is accepted by the filter. +// */ +// public boolean isValid(E e); /** * Return true iff this this filter can be used on the specified object @@ -61,7 +56,7 @@ * <p> * Note: This was added to make it possible filter out cases where the * runtime type system was throwing a {@link ClassCastException} in the - * {@link #accept(Object)} implementation. + * {@link #isValid(Object)} implementation. * * @param o * An object of some type. Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/SolutionFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/SolutionFilter.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/SolutionFilter.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -26,14 +26,25 @@ this.delegate = delegate; } - - public boolean accept(final ISolution<E> solution) { - final E e = solution.get(); + public boolean isValid(final Object o) { - return delegate.accept( e ); + return delegate.isValid(o); + } + + /* + * Note: The old implementation is below. Based on it, the canAccept() + * method was not (and still is not) being invoked for SolutionFilter. + */ +// public boolean accept(final ISolution<E> solution) { +// +// final E e = solution.get(); +// +// return delegate.accept( e ); +// } + public boolean canAccept(final Object o) { if (!(o instanceof ISolution<?>)) { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/DistributedJoinTask.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/DistributedJoinTask.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/DistributedJoinTask.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -1128,7 +1128,7 @@ return new Striterator(cache.values().iterator()).addFilter(new Filter(){ private static final long serialVersionUID = 1L; @Override - protected boolean isValid(final Object e) { + public boolean isValid(final Object e) { /* * Filter out any tasks which are not done or which had an * error. Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/UnsynchronizedSolutionBuffer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/UnsynchronizedSolutionBuffer.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/rule/eval/pipeline/UnsynchronizedSolutionBuffer.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -90,7 +90,7 @@ final ISolution solution = joinNexus.newSolution(rule, bindingSet); - if (solutionFilter == null || solutionFilter.accept(solution)) { + if (solutionFilter == null || solutionFilter.isValid(solution)) { a[naccepted++] = solution; Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/striterator/ChunkedWrappedIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/striterator/ChunkedWrappedIterator.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/striterator/ChunkedWrappedIterator.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -121,11 +121,6 @@ * @param filter * Optional filter. When non-<code>null</code> only elements * accepted by the filter will be visited by this iterator. - * <p> - * Note: This filter will be applied on the client side after - * tuples have already been resolved to relation elements. Where - * possible, you are better off passing the filter into the - * source iterator running on the server(s). */ @SuppressWarnings("unchecked") public ChunkedWrappedIterator(final Iterator<E> src, final int chunkSize, @@ -153,9 +148,9 @@ private static final long serialVersionUID = 1L; - protected boolean isValid(final Object arg0) { + public boolean isValid(final Object arg0) { - return filter.accept((E) arg0); + return filter.isValid((E) arg0); }} ) Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicate.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicate.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicate.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -38,6 +38,7 @@ import com.bigdata.bop.IPredicate; import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; +import com.bigdata.bop.NV; import com.bigdata.bop.Var; /** @@ -77,9 +78,10 @@ final Var<Long> u = Var.var("u"); - final IPredicate<?> p1 = new Predicate( - new IVariableOrConstant[] { u, c1, c2 }, relation); - + final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { + u, c1, c2 }, new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); + if (log.isInfoEnabled()) log.info(p1.toString()); @@ -103,7 +105,9 @@ final Var<Long> v = Var.var("v"); final IPredicate<?> p1 = new Predicate( - new IVariableOrConstant[] { u, c1, v }, relation); + new IVariableOrConstant[] { u, c1, v }, + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); if (log.isInfoEnabled()) log.info(p1.toString()); @@ -131,10 +135,12 @@ final Var<Long> u = Var.var("u"); final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { u, c1, c2 }, - relation); + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); final IPredicate<?> p2 = new Predicate(new IVariableOrConstant[] { u, c3, c4 }, - relation); + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); if (log.isInfoEnabled()) { @@ -157,9 +163,10 @@ final Var<Long> u = Var.var("u"); - final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { u, c1, c2 }, - relation); - + final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { u, + c1, c2 }, new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); + assertEquals("arity", 3, p1.arity()); // verify variables versus constants. @@ -246,9 +253,10 @@ final Var<Long> u = Var.var("u"); - final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { u, c1, c2 }, - relation); - + final IPredicate<?> p1 = new Predicate(new IVariableOrConstant[] { u, + c1, c2 }, new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation })); + assertEquals("arity", 3, p1.arity()); // verify variables versus constants. Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicateAccessPath.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicateAccessPath.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/ap/TestPredicateAccessPath.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -172,9 +172,10 @@ public void test_nothingBound() { // nothing bound. - final IAccessPath<E> accessPath = rel - .getAccessPath(new Predicate<E>(new IVariableOrConstant[] { - Var.var("name"), Var.var("value") }, namespace)); + final IAccessPath<E> accessPath = rel.getAccessPath(new Predicate<E>( + new BOp[] { Var.var("name"), Var.var("value") }, new NV( + IPredicate.Annotations.RELATION_NAME, + new String[] { namespace }))); // verify the range count. assertEquals(5, accessPath.rangeCount(true/* exact */)); @@ -215,7 +216,9 @@ final IAccessPath<E> accessPath = rel.getAccessPath(new Predicate<E>( new IVariableOrConstant[] { new Constant<String>("Mary"), - Var.var("value") }, namespace)); + Var.var("value") }, new NV( + Predicate.Annotations.RELATION_NAME, + new String[] { namespace }))); // verify the range count. assertEquals(2, accessPath.rangeCount(true/* exact */)); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/relation/rule/eval/TestDefaultEvaluationPlan.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/relation/rule/eval/TestDefaultEvaluationPlan.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/relation/rule/eval/TestDefaultEvaluationPlan.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -41,12 +41,14 @@ import com.bigdata.bop.IConstraint; import com.bigdata.bop.IPredicate; import com.bigdata.bop.IVariableOrConstant; +import com.bigdata.bop.NV; import com.bigdata.bop.Var; import com.bigdata.bop.ap.Predicate; import com.bigdata.btree.keys.ISortKeyBuilder; import com.bigdata.config.IValidator; import com.bigdata.io.IStreamSerializer; import com.bigdata.journal.IIndexManager; +import com.bigdata.journal.ITx; import com.bigdata.mdi.PartitionLocator; import com.bigdata.relation.IMutableRelation; import com.bigdata.relation.IRelation; @@ -105,6 +107,7 @@ public void test_lubmQuery8() { final String relation = "spo"; + final long timestamp = ITx.READ_COMMITTED; final Constant<?> rdfType = new Constant<String>("rdfType"); final Constant<?> Department = new Constant<String>("Department"); @@ -117,31 +120,41 @@ final IPredicate<?> pred0 = new Predicate(// new IVariableOrConstant[] {// Var.var("y"), rdfType, Department },// - relation// + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation }),// + new NV(Predicate.Annotations.TIMESTAMP,timestamp)// ); final IPredicate<?> pred1 = new Predicate(// new IVariableOrConstant[] {// Var.var("x"), rdfType, Student },// - relation// + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation }),// + new NV(Predicate.Annotations.TIMESTAMP,timestamp)// ); final IPredicate<?> pred2 = new Predicate( // new IVariableOrConstant[] {// Var.var("x"), memberOf, Var.var("y") },// - relation// + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation }),// + new NV(Predicate.Annotations.TIMESTAMP,timestamp)// ); final IPredicate<?> pred3 = new Predicate(// new IVariableOrConstant[] {// Var.var("y"), subOrganizationOf, University0 },// - relation// + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation }),// + new NV(Predicate.Annotations.TIMESTAMP,timestamp)// ); final IPredicate<?> pred4 = new Predicate(// new IVariableOrConstant[] {// Var.var("x"), emailAddress, Var.var("z") }, - relation// + new NV(Predicate.Annotations.RELATION_NAME, + new String[] { relation }),// + new NV(Predicate.Annotations.TIMESTAMP,timestamp)// ); final IRule rule = new Rule(getName(), null/* head */, Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/AbstractSPOBuffer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/AbstractSPOBuffer.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/AbstractSPOBuffer.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -186,7 +186,7 @@ assert stmt != null; - if (filter != null && filter.accept(stmt)) { + if (filter != null && filter.isValid(stmt)) { /* * Note: Do not store statements (or justifications) matched by the Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/BackchainTypeResourceIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/BackchainTypeResourceIterator.java 2010-09-29 15:36:55 UTC (rev 3677) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/BackchainTypeResourceIterator.java 2010-09-29 15:48:34 UTC (rev 3678) @@ -274,7 +274,7 @@ private static final long serialVersionUID = 1L; - protected boolean isValid(Object arg0) { + public boolean isValid(Object arg0) { final SPO o = (SPO) arg0; Modified: branches/QUADS_QUERY_BRANCH/bigdat... [truncated message content] |