From: <mrp...@us...> - 2010-08-20 16:14:20
|
Revision: 3453 http://bigdata.svn.sourceforge.net/bigdata/?rev=3453&view=rev Author: mrpersonick Date: 2010-08-20 16:14:13 +0000 (Fri, 20 Aug 2010) Log Message: ----------- fixed compile errors Modified Paths: -------------- 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/spo/SPOStarJoin.java Modified: 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/MagicPredicate.java 2010-08-19 21:07:19 UTC (rev 3452) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/MagicPredicate.java 2010-08-20 16:14:13 UTC (rev 3453) @@ -38,6 +38,7 @@ import com.bigdata.bop.IPredicate; import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; +import com.bigdata.bop.ap.Predicate; import com.bigdata.rdf.internal.IV; import com.bigdata.relation.accesspath.IElementFilter; import com.bigdata.relation.rule.ISolutionExpander; @@ -55,71 +56,16 @@ * @todo This is specific to the RDF and models an SPO or SPOC tuple. It can not * be used for the lexicon tuples or other kinds of relations. */ -public class MagicPredicate implements IPredicate<IMagicTuple> { +public class MagicPredicate extends Predicate<IMagicTuple> { protected static final Logger log = Logger.getLogger(MagicPredicate.class); -// public MagicPredicate copy() { -// -// return new MagicPredicate(this, relationName); -// -// } - /** * */ private static final long serialVersionUID = 1396017399712849975L; - private final String[] relationName; - - private final int partitionId; - /** - * The terms (variables or constants) associated with this predicate. - */ - private final List<IVariableOrConstant<IV>> terms; - - private final IElementFilter constraint; - - private final ISolutionExpander expander; - - public String getOnlyRelationName() { - - if (relationName.length != 1) - throw new IllegalStateException(); - - return relationName[0]; - - } - - public String getRelationName(int index) { - - return relationName[index]; - - } - - final public int getRelationCount() { - - return relationName.length; - - } - - final public int getPartitionId() { - - return partitionId; - - } - - /** - * The arity is determined by the number of terms supplied in the ctor. - */ - public final int arity() { - - return terms.size(); - - } - - /** * Partly specified ctor. No constraint is specified. No expander is * specified. * @@ -171,387 +117,282 @@ IVariableOrConstant<IV>... terms// ) { - if (relationName == null) - throw new IllegalArgumentException(); - - for (int i = 0; i < relationName.length; i++) { - - if (relationName[i] == null) - throw new IllegalArgumentException(); - - } + super(terms, relationName[0], partitionId, false, constraint, expander); - if (relationName.length == 0) - throw new IllegalArgumentException(); - - if (partitionId < -1) - throw new IllegalArgumentException(); - - this.relationName = relationName; - - this.partitionId = partitionId; - - this.constraint = constraint; /// MAY be null. - - this.expander = expander;// MAY be null. - - this.terms = Arrays.asList(terms); - } - /** - * Copy constructor overrides the relation name(s). - * - * @param relationName - * The new relation name(s). - */ - protected MagicPredicate(MagicPredicate src, String[] relationName) { - - if (relationName == null) - throw new IllegalArgumentException(); - - for(int i=0; i<relationName.length; i++) { - - if (relationName[i] == null) - throw new IllegalArgumentException(); - - } - - if (relationName.length == 0) - throw new IllegalArgumentException(); - - this.partitionId = src.partitionId; - - this.relationName = relationName; // override. - - this.constraint = src.constraint; - - this.expander = src.expander; - - this.terms = new LinkedList<IVariableOrConstant<IV>>(); - - this.terms.addAll(src.terms); - - } - - /** - * Copy constructor sets the index partition identifier. - * - * @param partitionId - * The index partition identifier. - * - * @throws IllegalArgumentException - * if the index partition identified is a negative integer. - * @throws IllegalStateException - * if the index partition identifier was already specified. - */ - protected MagicPredicate(final MagicPredicate src, final int partitionId) { - - //@todo uncomment the other half of this test to make it less paranoid. - if (src.partitionId != -1 ) {//&& this.partitionId != partitionId) { - - throw new IllegalStateException(); - - } - - if (partitionId < 0) { - - throw new IllegalArgumentException(); - - } - - this.relationName = src.relationName; - - this.partitionId = partitionId; - - this.constraint = src.constraint; - - this.expander = src.expander; - - this.terms = new LinkedList<IVariableOrConstant<IV>>(); - - this.terms.addAll(src.terms); - - } - - public final IVariableOrConstant<IV> get(int index) { - - return terms.get(index); - - } - - public final IConstant<IV> get(final IMagicTuple e, final int index) { - - return new Constant<IV>(e.getTerm(index)); - - } - -// /** -// * Return true iff all terms of the predicate are bound (vs -// * variables). -// */ -// final public boolean isFullyBound() { +// public final IConstant<IV> get(final IMagicTuple e, final int index) { // +// return new Constant<IV>(e.getTerm(index)); +// +// } +// +//// /** +//// * Return true iff all terms of the predicate are bound (vs +//// * variables). +//// */ +//// final public boolean isFullyBound() { +//// +//// for (IVariableOrConstant<IV> term : terms) { +//// +//// if (term.isVar()) { +//// +//// return false; +//// +//// } +//// +//// } +//// +//// return true; +//// +//// } +// +// public boolean isFullyBound(final IKeyOrder<IMagicTuple> keyOrder) { +// +// return getVariableCount(keyOrder) == 0; +// +// } +// +// public int getVariableCount(final IKeyOrder<IMagicTuple> keyOrder) { +// int nunbound = 0; +// final int keyArity = keyOrder.getKeyArity(); +// for (int keyPos = 0; keyPos < keyArity; keyPos++) { +// final int index = keyOrder.getKeyOrder(keyPos); +// final IVariableOrConstant<?> t = get(index); +// if (t == null || t.isVar()) { +// nunbound++; +// } +// } +// return nunbound; +// } +// +// final public int getVariableCount() { +// +// int i = 0; +// // for (IVariableOrConstant<IV> term : terms) { // // if (term.isVar()) { // -// return false; +// i++; // // } // // } // +// return i; +// +// } +// +// public Iterator<IVariable<?>> getVariables() { +// +// final Set<IVariable<?>> vars = new HashSet<IVariable<?>>(); +// +// for (int i = 0; i < arity(); i++) { +// if (get(i).isVar()) { +// vars.add((IVariable<?>) get(i)); +// } +// } +// +// return vars.iterator(); +// +// } +// +// public MagicPredicate asBound(IBindingSet bindingSet) { +// +// final IVariableOrConstant<IV>[] newTerms = +// new IVariableOrConstant[this.terms.size()]; +// +// int i = 0; +// for (IVariableOrConstant<IV> term : this.terms) { +// IVariableOrConstant<IV> newTerm; +// if (term.isVar() && bindingSet.isBound((IVariable<IV>) term)) { +// newTerm = bindingSet.get((IVariable<IV>) term); +// } else { +// newTerm = term; +// } +// newTerms[i++] = newTerm; +// } +// +// return new MagicPredicate(relationName, partitionId, +// constraint, expander, newTerms); +// +// } +// +// public MagicPredicate setRelationName(String[] relationName) { +// +// return new MagicPredicate(this, relationName); +// +// } +// +// public MagicPredicate setPartitionId(int partitionId) { +// +// return new MagicPredicate(this, partitionId); +// +// } +// +// public IMagicTuple toMagicTuple() { +// +// final IV[] terms = new IV[this.terms.size()]; +// int i = 0; +// for (IVariableOrConstant<IV> term : this.terms) { +// if (term.isVar()) { +// throw new RuntimeException("predicate not fully bound"); +// } else { +// terms[i++] = term.get(); +// } +// } +// +// return new MagicTuple(terms); +// +// } +// +// public String toString() { +// +// return toString(null); +// +// } +// +// public String toString(IBindingSet bindingSet) { +// +// StringBuilder sb = new StringBuilder(); +// +// sb.append("("); +// +// sb.append(Arrays.toString(relationName)); +// +// sb.append(", "); +// +// for (IVariableOrConstant<IV> term : terms) { +// +// sb.append(term.isConstant() || bindingSet == null +// || !bindingSet.isBound((IVariable) term) ? term.toString() +// : bindingSet.get((IVariable) term)); +// +// sb.append(", "); +// +// } +// +// if (terms.size() > 0) { +// +// sb.setLength(sb.length()-2); +// +// } +// +// sb.append("))"); +// +// if (constraint != null || expander != null +// || partitionId != -1) { +// +// /* +// * Something special, so do all this stuff. +// */ +// +// boolean first = true; +// +// sb.append("["); +// +// if(constraint!=null) { +// if(!first) sb.append(", "); +// sb.append(constraint.toString()); +// first = false; +// } +// +// if(expander!=null) { +// if(!first) sb.append(", "); +// sb.append(expander.toString()); +// first = false; +// } +// +// if(partitionId!=-1) { +// if(!first) sb.append(", "); +// sb.append("partitionId="+partitionId); +// first = false; +// } +// +// sb.append("]"); +// +// } +// +// return sb.toString(); +// +// } +// +// final public boolean isOptional() { +// +// return false; +// +// } +// +// final public IElementFilter getConstraint() { +// +// return constraint; +// +// } +// +// final public ISolutionExpander getSolutionExpander() { +// +// return expander; +// +// } +// +// public boolean equals(final Object other) { +// +// if (this == other) +// return true; +// +// if (!(other instanceof IPredicate<?>)) +// return false; +// +// final IPredicate<?> o = (IPredicate<?>) other; +// +// final int arity = arity(); +// +// if(arity != o.arity()) return false; +// +// for(int i=0; i<arity; i++) { +// +// final IVariableOrConstant<?> x = get(i); +// +// final IVariableOrConstant<?> y = o.get(i); +// +// if (x != y && !(x.equals(y))) { +// +// return false; +// +// } +// +// } +// // return true; +// +// } // +// public int hashCode() { +// +// int h = hash; +// +// if (h == 0) { +// +// final int n = arity(); +// +// for (int i = 0; i < n; i++) { +// +// h = 31 * h + get(i).hashCode(); +// +// } +// +// hash = h; +// +// } +// +// return h; +// // } +// +// /** +// * Caches the hash code. +// */ +// private int hash = 0; - public boolean isFullyBound(final IKeyOrder<IMagicTuple> keyOrder) { - - return getVariableCount(keyOrder) == 0; - - } - - public int getVariableCount(final IKeyOrder<IMagicTuple> keyOrder) { - int nunbound = 0; - final int keyArity = keyOrder.getKeyArity(); - for (int keyPos = 0; keyPos < keyArity; keyPos++) { - final int index = keyOrder.getKeyOrder(keyPos); - final IVariableOrConstant<?> t = get(index); - if (t == null || t.isVar()) { - nunbound++; - } - } - return nunbound; - } - - final public int getVariableCount() { - - int i = 0; - - for (IVariableOrConstant<IV> term : terms) { - - if (term.isVar()) { - - i++; - - } - - } - - return i; - - } - - public Iterator<IVariable<?>> getVariables() { - - final Set<IVariable<?>> vars = new HashSet<IVariable<?>>(); - - for (int i = 0; i < arity(); i++) { - if (get(i).isVar()) { - vars.add((IVariable<?>) get(i)); - } - } - - return vars.iterator(); - - } - - public MagicPredicate asBound(IBindingSet bindingSet) { - - final IVariableOrConstant<IV>[] newTerms = - new IVariableOrConstant[this.terms.size()]; - - int i = 0; - for (IVariableOrConstant<IV> term : this.terms) { - IVariableOrConstant<IV> newTerm; - if (term.isVar() && bindingSet.isBound((IVariable<IV>) term)) { - newTerm = bindingSet.get((IVariable<IV>) term); - } else { - newTerm = term; - } - newTerms[i++] = newTerm; - } - - return new MagicPredicate(relationName, partitionId, - constraint, expander, newTerms); - - } - - public MagicPredicate setRelationName(String[] relationName) { - - return new MagicPredicate(this, relationName); - - } - - public MagicPredicate setPartitionId(int partitionId) { - - return new MagicPredicate(this, partitionId); - - } - - public IMagicTuple toMagicTuple() { - - final IV[] terms = new IV[this.terms.size()]; - int i = 0; - for (IVariableOrConstant<IV> term : this.terms) { - if (term.isVar()) { - throw new RuntimeException("predicate not fully bound"); - } else { - terms[i++] = term.get(); - } - } - - return new MagicTuple(terms); - - } - - public String toString() { - - return toString(null); - - } - - public String toString(IBindingSet bindingSet) { - - StringBuilder sb = new StringBuilder(); - - sb.append("("); - - sb.append(Arrays.toString(relationName)); - - sb.append(", "); - - for (IVariableOrConstant<IV> term : terms) { - - sb.append(term.isConstant() || bindingSet == null - || !bindingSet.isBound((IVariable) term) ? term.toString() - : bindingSet.get((IVariable) term)); - - sb.append(", "); - - } - - if (terms.size() > 0) { - - sb.setLength(sb.length()-2); - - } - - sb.append("))"); - - if (constraint != null || expander != null - || partitionId != -1) { - - /* - * Something special, so do all this stuff. - */ - - boolean first = true; - - sb.append("["); - - if(constraint!=null) { - if(!first) sb.append(", "); - sb.append(constraint.toString()); - first = false; - } - - if(expander!=null) { - if(!first) sb.append(", "); - sb.append(expander.toString()); - first = false; - } - - if(partitionId!=-1) { - if(!first) sb.append(", "); - sb.append("partitionId="+partitionId); - first = false; - } - - sb.append("]"); - - } - - return sb.toString(); - - } - - final public boolean isOptional() { - - return false; - - } - - final public IElementFilter getConstraint() { - - return constraint; - - } - - final public ISolutionExpander getSolutionExpander() { - - return expander; - - } - - public boolean equals(final Object other) { - - if (this == other) - return true; - - if (!(other instanceof IPredicate<?>)) - return false; - - final IPredicate<?> o = (IPredicate<?>) other; - - final int arity = arity(); - - if(arity != o.arity()) return false; - - for(int i=0; i<arity; i++) { - - final IVariableOrConstant<?> x = get(i); - - final IVariableOrConstant<?> y = o.get(i); - - if (x != y && !(x.equals(y))) { - - return false; - - } - - } - - return true; - - } - - public int hashCode() { - - int h = hash; - - if (h == 0) { - - final int n = arity(); - - for (int i = 0; i < n; i++) { - - h = 31 * h + get(i).hashCode(); - - } - - hash = h; - - } - - return h; - - } - - /** - * Caches the hash code. - */ - private int hash = 0; - } Modified: 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/spo/SPOStarJoin.java 2010-08-19 21:07:19 UTC (rev 3452) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOStarJoin.java 2010-08-20 16:14:13 UTC (rev 3453) @@ -29,7 +29,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Set; - import com.bigdata.bop.Constant; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IVariable; @@ -71,9 +70,13 @@ */ public SPOStarJoin(final SPOPredicate pred) { - this(pred.relationName, pred.partitionId, pred.s(), Var.var(), - Var.var(), pred.c(), pred.isOptional(), - pred.getConstraint(), pred.getSolutionExpander()); + this(new String[] { pred.getOnlyRelationName() }, pred.getPartitionId(), + pred.s(), // s + (IVariableOrConstant<IV>) Var.var(), // p + (IVariableOrConstant<IV>) Var.var(), // o + pred.c(), // c + pred.isOptional(), pred.getConstraint(), + pred.getSolutionExpander()); } @@ -88,10 +91,12 @@ public SPOStarJoin(final String relationName, final IVariableOrConstant<IV> s) { - this(new String[] { relationName }, -1/* partitionId */, s, - Var.var(), Var.var(), - null/* c */, false/* optional */, null/* constraint */, - null/* expander */); + this(new String[] { relationName }, -1/* partitionId */, + s, + (IVariableOrConstant<IV>) Var.var(), // p + (IVariableOrConstant<IV>) Var.var(), // o + null, // c + false/* optional */, null/* constraint */, null/* expander */); } @@ -186,43 +191,29 @@ @Override public SPOPredicate asBound(IBindingSet bindingSet) { - SPOPredicate pred = super.asBound(bindingSet); - - SPOStarJoin starJoin = new SPOStarJoin(pred.relationName, - pred.partitionId, pred.s, pred.p, pred.o, pred.c, pred.optional, - pred.constraint, pred.expander); - + final SPOStarJoin starJoin = (SPOStarJoin) super.asBound(bindingSet); for (IStarConstraint starConstraint : starConstraints) { - starJoin.addStarConstraint(starConstraint.asBound(bindingSet)); - } - return starJoin; } - protected StringBuilder toStringBuilder(final IBindingSet bindingSet) { + @Override + public String toString(final IBindingSet bindingSet) { - StringBuilder sb = super.toStringBuilder(bindingSet); + final StringBuilder sb = new StringBuilder(super.toString(bindingSet)); if (starConstraints.size() > 0) { - sb.append("star["); - for (IStarConstraint sc : starConstraints) { - sb.append(sc); - sb.append(","); - } - sb.setCharAt(sb.length()-1, ']'); - } - return sb; + return sb.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-09-29 23:35:43
|
Revision: 3688 http://bigdata.svn.sourceforge.net/bigdata/?rev=3688&view=rev Author: mrpersonick Date: 2010-09-29 23:35:37 +0000 (Wed, 29 Sep 2010) Log Message: ----------- changed filters to work with ISolution instead of ISPO Modified Paths: -------------- 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/rules/DoNotAddFilter.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/NoAxiomFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java Modified: 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/inf/RdfTypeRdfsResourceFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -12,6 +12,7 @@ import com.bigdata.rdf.spo.ISPO; import com.bigdata.rdf.spo.SPOFilter; import com.bigdata.rdf.vocab.Vocabulary; +import com.bigdata.relation.rule.eval.ISolution; /** * Filter matches <code>(x rdf:type rdfs:Resource). @@ -57,9 +58,9 @@ } - final ISPO spo = (ISPO) o; + final ISolution solution = (ISolution) o; - return accept(spo); + return accept((ISPO) solution.get()); } Modified: 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/DoNotAddFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/DoNotAddFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -34,6 +34,7 @@ import com.bigdata.rdf.spo.ISPO; import com.bigdata.rdf.spo.SPOFilter; import com.bigdata.rdf.vocab.Vocabulary; +import com.bigdata.relation.rule.eval.ISolution; /** * Filter keeps matched triple patterns generated OUT of the database. @@ -121,15 +122,17 @@ } public boolean isValid(Object o) { - + if (!canAccept(o)) { return true; } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: 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/ExplicitSPOFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/ExplicitSPOFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -32,6 +32,7 @@ import com.bigdata.rdf.model.StatementEnum; import com.bigdata.relation.accesspath.IElementFilter; +import com.bigdata.relation.rule.eval.ISolution; /** * Filter matches only {@link StatementEnum#Explicit} {@link ISPO}s. @@ -66,8 +67,10 @@ } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: 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/InGraphBinarySearchFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -11,6 +11,7 @@ import com.bigdata.bop.constraint.INBinarySearch; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.model.BigdataURI; +import com.bigdata.relation.rule.eval.ISolution; /** * "IN" filter for the context position based on a sorted long[] of the @@ -86,8 +87,10 @@ } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: 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/InGraphHashSetFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphHashSetFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -9,6 +9,7 @@ import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.store.IRawTripleStore; +import com.bigdata.relation.rule.eval.ISolution; /** * "IN" filter for the context position based on a native long hash set @@ -72,8 +73,10 @@ } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: 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/InferredSPOFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InferredSPOFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -33,6 +33,7 @@ import com.bigdata.rdf.model.StatementEnum; import com.bigdata.relation.accesspath.IElementFilter; +import com.bigdata.relation.rule.eval.ISolution; /** * Filter matches only {@link StatementEnum#Inferred} statements. @@ -69,8 +70,10 @@ } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: 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/NoAxiomFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/NoAxiomFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -31,6 +31,7 @@ import java.io.ObjectStreamException; import com.bigdata.rdf.model.StatementEnum; +import com.bigdata.relation.rule.eval.ISolution; /** * A filter that matches explicit or inferred statements but not those whose @@ -66,8 +67,10 @@ } - return accept((ISPO) o); + final ISolution solution = (ISolution) o; + return accept((ISPO) solution.get()); + } private boolean accept(final ISPO o) { Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java 2010-09-29 22:50:32 UTC (rev 3687) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java 2010-09-29 23:35:37 UTC (rev 3688) @@ -1,6 +1,7 @@ package com.bigdata.rdf.spo; import com.bigdata.relation.accesspath.IElementFilter; +import com.bigdata.relation.rule.eval.ISolution; public abstract class SPOFilter<E extends ISPO> implements IElementFilter<E> { @@ -11,8 +12,16 @@ public boolean canAccept(final Object o) { - return o instanceof ISPO; + if (o instanceof ISolution) { + + ISolution solution = (ISolution) o; + + return solution.get() instanceof ISPO; + + } + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-09-30 14:55:05
|
Revision: 3694 http://bigdata.svn.sourceforge.net/bigdata/?rev=3694&view=rev Author: mrpersonick Date: 2010-09-30 14:54:59 +0000 (Thu, 30 Sep 2010) Log Message: ----------- rolling back changes to filters to handle solutions Modified Paths: -------------- 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/rules/DoNotAddFilter.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/NoAxiomFilter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java Modified: 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/inf/RdfTypeRdfsResourceFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/RdfTypeRdfsResourceFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -58,10 +58,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO spo) { Modified: 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/DoNotAddFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/DoNotAddFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -132,10 +132,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: 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/ExplicitSPOFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/ExplicitSPOFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -67,10 +67,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: 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/InGraphBinarySearchFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphBinarySearchFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -87,10 +87,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: 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/InGraphHashSetFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InGraphHashSetFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -73,10 +73,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: 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/InferredSPOFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/InferredSPOFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -70,10 +70,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: 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/NoAxiomFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/NoAxiomFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -67,10 +67,8 @@ } - final ISolution solution = (ISolution) o; + return accept((ISPO) o); - return accept((ISPO) solution.get()); - } private boolean accept(final ISPO o) { Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java 2010-09-30 14:18:41 UTC (rev 3693) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOFilter.java 2010-09-30 14:54:59 UTC (rev 3694) @@ -1,7 +1,6 @@ package com.bigdata.rdf.spo; import com.bigdata.relation.accesspath.IElementFilter; -import com.bigdata.relation.rule.eval.ISolution; public abstract class SPOFilter<E extends ISPO> implements IElementFilter<E> { @@ -12,16 +11,8 @@ public boolean canAccept(final Object o) { - if (o instanceof ISolution) { - - ISolution solution = (ISolution) o; - - return solution.get() instanceof ISPO; - - } + return o instanceof ISPO; - return false; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2011-01-13 21:25:55
|
Revision: 4092 http://bigdata.svn.sourceforge.net/bigdata/?rev=4092&view=rev Author: mrpersonick Date: 2011-01-13 21:25:49 +0000 (Thu, 13 Jan 2011) Log Message: ----------- changing the default time zone and precision for decoding date/times Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DateTimeExtension.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataValueFactoryImpl.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DateTimeExtension.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DateTimeExtension.java 2011-01-13 20:58:04 UTC (rev 4091) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DateTimeExtension.java 2011-01-13 21:25:49 UTC (rev 4092) @@ -109,8 +109,9 @@ */ final long l = iv.getDelegate().longValue(); - final GregorianCalendar c = - new GregorianCalendar(TimeZone.getTimeZone("GMT")); + final GregorianCalendar c = new GregorianCalendar( +// TimeZone.getTimeZone("GMT") + ); c.setTimeInMillis(l); try { Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataValueFactoryImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataValueFactoryImpl.java 2011-01-13 20:58:04 UTC (rev 4091) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/model/BigdataValueFactoryImpl.java 2011-01-13 21:25:49 UTC (rev 4092) @@ -271,7 +271,13 @@ // null/* languageCode */, createURI(arg0.getXMLSchemaType() // .toString())); - return new BigdataLiteralImpl(this, arg0.toString(), + String s = arg0.toString(); + final int i = s.lastIndexOf('.'); + if (i >= 0) { + s = s.substring(0, i); + } + + return new BigdataLiteralImpl(this, s, null/* languageCode */, createURI(XMLDatatypeUtil.qnameToURI( arg0.getXMLSchemaType()).stringValue())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2011-02-11 18:59:48
|
Revision: 4193 http://bigdata.svn.sourceforge.net/bigdata/?rev=4193&view=rev Author: thompsonbry Date: 2011-02-11 18:59:41 +0000 (Fri, 11 Feb 2011) Log Message: ----------- Added various classes to support reporting of static, dynamic, and type errors per SPARQL, XPath, and XQuery specs. Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlDynamicErrorException.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlStaticErrorException.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlTypeErrorException.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/W3CQueryLanguageException.java Added: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlDynamicErrorException.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlDynamicErrorException.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlDynamicErrorException.java 2011-02-11 18:59:41 UTC (rev 4193) @@ -0,0 +1,61 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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 Feb 11, 2011 + */ + +package com.bigdata.rdf.error; + + +/** + * A SPARQL static analysis error. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class SparqlDynamicErrorException extends W3CQueryLanguageException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * @param errorCode + * The four digit error code. + */ + public SparqlDynamicErrorException(int errorCode) { + + super(LanguageFamily.SP, ErrorCategory.DY, errorCode, null/* msg */); + + } + + static protected String toURI(int errorCode) { + + return W3CQueryLanguageException.toURI(LanguageFamily.SP, + ErrorCategory.DY, errorCode); + + } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlDynamicErrorException.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlStaticErrorException.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlStaticErrorException.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlStaticErrorException.java 2011-02-11 18:59:41 UTC (rev 4193) @@ -0,0 +1,59 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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 Feb 11, 2011 + */ + +package com.bigdata.rdf.error; + +/** + * A SPARQL dynamic (runtime) error. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class SparqlStaticErrorException extends W3CQueryLanguageException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * @param errorCode + * The four digit error code. + */ + public SparqlStaticErrorException(int errorCode) { + + super(LanguageFamily.SP, ErrorCategory.ST, errorCode, null/* msg */); + + } + + static protected String toURI(int errorCode) { + + return W3CQueryLanguageException.toURI(LanguageFamily.SP, + ErrorCategory.ST, errorCode); + + } +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlStaticErrorException.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlTypeErrorException.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlTypeErrorException.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlTypeErrorException.java 2011-02-11 18:59:41 UTC (rev 4193) @@ -0,0 +1,77 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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 Feb 11, 2011 + */ + +package com.bigdata.rdf.error; + +/** + * A SPARQL type error. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class SparqlTypeErrorException extends W3CQueryLanguageException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Generic type error. + */ + static public String SPARQL_TYPE_ERROR_0000 = toURI(0); + + /** + * Generic SPARQL type error. + * + * @see #SPARQL_TYPE_ERROR_0000 + */ + public SparqlTypeErrorException() { + + super(LanguageFamily.SP, ErrorCategory.TY, 0/* errorCode */, + SPARQL_TYPE_ERROR_0000); + + } + + /** + * @param errorCode + * The four digit error code. + */ + public SparqlTypeErrorException(int errorCode) { + + super(LanguageFamily.SP, ErrorCategory.TY, errorCode, null/* msg */); + + } + + static protected String toURI(int errorCode) { + + return W3CQueryLanguageException.toURI(LanguageFamily.SP, + ErrorCategory.TY, errorCode); + + } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/SparqlTypeErrorException.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/W3CQueryLanguageException.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/W3CQueryLanguageException.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/W3CQueryLanguageException.java 2011-02-11 18:59:41 UTC (rev 4193) @@ -0,0 +1,159 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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 Feb 11, 2011 + */ + +package com.bigdata.rdf.error; + +import java.util.Formatter; + +/** + * Exception Base class for errors defined by the W3C for XQuery, XPath, and + * SPARQL. + * + * @see http://www.w3.org/TR/xquery/#errors + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class W3CQueryLanguageException extends RuntimeException { + + /** + * Namespace for the error URIs. + */ + protected static final transient String err = "http://www.w3.org/2005/xqt-errors"; + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** Language family for errors. */ + public static enum LanguageFamily { + /** + * XQuery + */ + XQ, + /** + * XPath + */ + XP, + /** + * SPARQL + */ + SP + } + + /** Error category. */ + public static enum ErrorCategory { + /** Static analysis error. */ + ST, + /** Dynamic (runtime) error. */ + DY, + /** Type error. */ + TY + }; + + /** + * The {@link LanguageFamily}. + */ + public final LanguageFamily languageFamily; + + /** + * The {@link ErrorCategory}. + */ + public final ErrorCategory errorCategory; + + /** + * The four digit error code. + */ + public final int errorCode; + + /** + * + * @param languageFamily + * The {@link LanguageFamily}. + * @param errorCategory + * The {@link ErrorCategory}. + * @param errorCode + * The four digit error code. + * @param msg + * The <em>URI</em> corresponding to the error. Frequently used + * errors should use + * {@link #toURI(LanguageFamily, ErrorCategory, int)} to define + * the URI statically to avoid heap churn. + */ + public W3CQueryLanguageException(LanguageFamily languageFamily, + ErrorCategory errorCategory, int errorCode, String msg) { + + super(msg == null ? toURI(languageFamily, errorCategory, errorCode) + : msg); + + this.languageFamily = languageFamily; + + this.errorCategory = errorCategory; + + this.errorCode = errorCode; + + } + + /** + * Return the URI for the given error. This is used to avoid the runtime + * creation of strings for frequently thrown errors, such as type errors. + * Various subclasses use this method to declare concrete URIs which are + * then passed into their constructors for specific kinds of errors. + * + * @param languageFamily + * The {@link LanguageFamily}. + * @param errorCategory + * The {@link ErrorCategory}. + * @param errorCode + * The four digit error code. + * + * @return The URI. + */ + static protected String toURI(LanguageFamily languageFamily, + ErrorCategory errorCategory, int errorCode) { + + if (errorCode >= 10000 || errorCode < 0) + throw new IllegalArgumentException(); + + final StringBuffer sb = new StringBuffer(4); + + final Formatter f = new Formatter(sb); + + f.format("%04d", errorCode); + + return err + languageFamily + errorCategory + sb.toString(); + + } + + // public static void main(String[] x) { + // + // System.err.println(toURI(LanguageFamily.SP,ErrorCategory.TY,120)); + // + // } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/error/W3CQueryLanguageException.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2011-02-22 23:39:21
|
Revision: 4229 http://bigdata.svn.sourceforge.net/bigdata/?rev=4229&view=rev Author: mrpersonick Date: 2011-02-22 23:39:14 +0000 (Tue, 22 Feb 2011) Log Message: ----------- refactor constraints -> value expressions Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/OwlSameAsPropertiesExpandingIterator.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/EBVBOp.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/rules/FastClosure.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/rules/RejectAnythingSameAsItself.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure11.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure13.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlInverseOf1.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1b.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs2.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs3.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty1.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty2.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs05.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs07.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs09.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs11.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/Constraint.java Removed Paths: ------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ValueExpressionConstraint.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/OwlSameAsPropertiesExpandingIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/OwlSameAsPropertiesExpandingIterator.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/OwlSameAsPropertiesExpandingIterator.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -13,7 +13,8 @@ import com.bigdata.bop.IVariable; import com.bigdata.bop.IVariableOrConstant; import com.bigdata.bop.Var; -import com.bigdata.bop.constraint.BOpConstraint; +import com.bigdata.bop.constraint.BooleanValueExpression; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.joinGraph.IEvaluationPlan; import com.bigdata.bop.joinGraph.IEvaluationPlanFactory; import com.bigdata.bop.joinGraph.fast.DefaultEvaluationPlanFactory2; @@ -28,8 +29,8 @@ import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.store.AbstractTripleStore; import com.bigdata.relation.accesspath.IAccessPath; +import com.bigdata.relation.rule.IAccessPathExpander; import com.bigdata.relation.rule.IRule; -import com.bigdata.relation.rule.IAccessPathExpander; import com.bigdata.relation.rule.QueryOptions; import com.bigdata.relation.rule.Rule; import com.bigdata.relation.rule.eval.ActionEnum; @@ -119,8 +120,8 @@ new SPOPredicate(SPO, _sameS, _p, _sameO) }, QueryOptions.DISTINCT, // distinct // constraints on the rule. - new IConstraint[] { new RejectSameAsSelf(head.s(), head - .p(), head.o()) }); + new IConstraint[] { Constraint.wrap(new RejectSameAsSelf(head.s(), head + .p(), head.o())) }); runQuery(rule); } @@ -151,8 +152,8 @@ sameAsSelfExpander) }, QueryOptions.DISTINCT, // distinct // constraints on the rule. - new IConstraint[] { new RejectSameAsSelf(head.s(), head - .p(), head.o()) }); + new IConstraint[] { Constraint.wrap(new RejectSameAsSelf(head.s(), head + .p(), head.o())) }); runQuery(rule); } @@ -183,8 +184,8 @@ sameAsSelfExpander) }, QueryOptions.DISTINCT, // distinct // constraints on the rule. - new IConstraint[] { new RejectSameAsSelf(head.s(), head - .p(), head.o()) }); + new IConstraint[] { Constraint.wrap(new RejectSameAsSelf(head.s(), head + .p(), head.o())) }); runQuery(rule); } @@ -215,8 +216,8 @@ new SPOPredicate(SPO, _s, _p, _o) }, QueryOptions.DISTINCT, // distinct // constraints on the rule. - new IConstraint[] { new RejectSameAsSelf(head.s(), head - .p(), head.o()) }); + new IConstraint[] { Constraint.wrap(new RejectSameAsSelf(head.s(), head + .p(), head.o())) }); runQuery(rule); } @@ -495,9 +496,14 @@ } }; - private class RejectSameAsSelf extends BOpConstraint { + private class RejectSameAsSelf extends BooleanValueExpression { - public RejectSameAsSelf(final IVariableOrConstant<IV> _s, + /** + * + */ + private static final long serialVersionUID = -7877904606067597254L; + + public RejectSameAsSelf(final IVariableOrConstant<IV> _s, final IVariableOrConstant<IV> _p, final IVariableOrConstant<IV> _o) { @@ -505,7 +511,7 @@ } - public boolean accept(final IBindingSet bindings) { + public Boolean get(final IBindingSet bindings) { final IV sVal = getValue((IVariableOrConstant)get(0/*_s*/), bindings); final IV pVal = getValue((IVariableOrConstant)get(1/*_p*/), bindings); final IV oVal = getValue((IVariableOrConstant)get(2/*_o*/), bindings); Copied: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/Constraint.java (from rev 4219, branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ValueExpressionConstraint.java) =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/Constraint.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/Constraint.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -0,0 +1,106 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2011. 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.apache.log4j.Logger; + +import com.bigdata.bop.BOp; +import com.bigdata.bop.IBindingSet; +import com.bigdata.bop.IConstraint; +import com.bigdata.bop.IValueExpression; +import com.bigdata.rdf.error.SparqlTypeErrorException; +import com.bigdata.rdf.internal.IV; + +/** + * BOpConstraint that wraps a {@link EBVBOp}, which itself computes the + * effective boolean value of an IValueExpression. + */ +public class Constraint extends com.bigdata.bop.constraint.Constraint { + + /** + * + */ + private static final long serialVersionUID = -5796492538735372727L; + + protected static final Logger log = Logger.getLogger(Constraint.class); + + /** + * Convenience method to generate a constraint from a value expression. + */ + public static IConstraint wrap(final IValueExpression<IV> ve) { + if (ve instanceof EBVBOp) + return new Constraint((EBVBOp) ve); + else + return new Constraint(new EBVBOp(ve)); + } + + + public Constraint(final EBVBOp x) { + + this(new BOp[] { x }, null/*annocations*/); + + } + + /** + * Required shallow copy constructor. + */ + public Constraint(final BOp[] args, + final Map<String, Object> anns) { + super(args, anns); + } + + /** + * Required deep copy constructor. + */ + public Constraint(final Constraint op) { + super(op); + } + + @Override + public EBVBOp get(final int i) { + return (EBVBOp) super.get(i); + } + + public boolean accept(final IBindingSet bs) { + + try { + + // evaluate the EBV operator + return get(0).get(bs).booleanValue(); + + } catch (SparqlTypeErrorException ex) { + + // trap the type error and filter out the solution + if (log.isInfoEnabled()) + log.info("discarding solution due to type error: " + bs); + return false; + + } + + } + +} Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/EBVBOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/EBVBOp.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/EBVBOp.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -37,8 +37,7 @@ * Calculates the "effective boolean value" of an IValueExpression. See the * SPARQL spec for details. */ -public class EBVBOp extends ValueExpressionBOp - implements IValueExpression<IV> { +public class EBVBOp extends ValueExpressionBOp { /** * Deleted: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ValueExpressionConstraint.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ValueExpressionConstraint.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/ValueExpressionConstraint.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -1,109 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2011. 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.apache.log4j.Logger; - -import com.bigdata.bop.BOp; -import com.bigdata.bop.IBindingSet; -import com.bigdata.bop.IConstraint; -import com.bigdata.bop.IValueExpression; -import com.bigdata.bop.constraint.BOpConstraint; -import com.bigdata.rdf.error.SparqlTypeErrorException; -import com.bigdata.rdf.internal.IV; - -/** - * BOpConstraint that wraps a {@link EBVBOp}, which itself computes the - * effective boolean value of an IValueExpression. - */ -public class ValueExpressionConstraint extends BOpConstraint { - - /** - * - */ - private static final long serialVersionUID = -7068219781217676085L; - - protected static final Logger log = Logger.getLogger(ValueExpressionConstraint.class); - - /** - * Convenience method to generate a constraint from a value expression. - */ - public static IConstraint wrap(final IValueExpression<IV> ve) { - return new ValueExpressionConstraint(new EBVBOp(ve)); - } - - - public ValueExpressionConstraint(final EBVBOp x) { - - this(new BOp[] { x }, null/*annocations*/); - - } - - /** - * Required shallow copy constructor. - */ - public ValueExpressionConstraint(final BOp[] args, - final Map<String, Object> anns) { - - super(args, anns); - - if (args.length != 1 || args[0] == null) - throw new IllegalArgumentException(); - - } - - /** - * Required deep copy constructor. - */ - public ValueExpressionConstraint(final ValueExpressionConstraint op) { - super(op); - } - - @Override - public EBVBOp get(final int i) { - return (EBVBOp) super.get(i); - } - - public boolean accept(final IBindingSet bs) { - - try { - - // evaluate the EBV operator - return get(0).get(bs).booleanValue(); - - } catch (SparqlTypeErrorException ex) { - - // trap the type error and filter out the solution - if (log.isInfoEnabled()) - log.info("discarding solution due to type error: " + bs); - return false; - - } - - } - -} Modified: 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/IRISUtils.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/magic/IRISUtils.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -32,6 +32,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; + import org.apache.log4j.Logger; import org.deri.iris.api.IProgramOptimisation.Result; import org.deri.iris.api.basics.ILiteral; @@ -45,8 +46,7 @@ import org.deri.iris.builtins.BuiltinsFactory; import org.deri.iris.optimisations.magicsets.MagicSets; import org.deri.iris.terms.TermFactory; -import com.bigdata.rdf.internal.IV; -import com.bigdata.rdf.internal.IVUtility; + import com.bigdata.bop.Constant; import com.bigdata.bop.IConstant; import com.bigdata.bop.IConstraint; @@ -55,6 +55,8 @@ import com.bigdata.bop.IVariableOrConstant; import com.bigdata.bop.NV; import com.bigdata.bop.Var; +import com.bigdata.bop.constraint.BooleanValueExpression; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.EQ; import com.bigdata.bop.constraint.EQConstant; import com.bigdata.bop.constraint.INBinarySearch; @@ -631,8 +633,14 @@ * @return * the bigdata constraint */ - private static IConstraint convertToBigdataConstraint(ILiteral literal) { + private static IConstraint convertToBigdataConstraint(final ILiteral literal) { + return Constraint.wrap(convertToBigdataVE(literal)); + + } + + private static BooleanValueExpression convertToBigdataVE(final ILiteral literal) { + ITuple tuple = literal.getAtom().getTuple(); org.deri.iris.api.basics.IPredicate p = literal.getAtom().getPredicate(); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/FastClosure.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/FastClosure.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/FastClosure.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -10,6 +10,7 @@ import com.bigdata.bop.IConstraint; import com.bigdata.bop.IVariable; import com.bigdata.bop.bindingSet.ArrayBindingSet; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NEConstant; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.store.AbstractTripleStore; @@ -279,7 +280,7 @@ program.addStep(tmp.specialize(// noBindings,// new IConstraint[] { // - new NEConstant(p, owlSameAs) // + Constraint.wrap(new NEConstant(p, owlSameAs)) // }// )); @@ -297,7 +298,7 @@ program.addStep(tmp.specialize(// noBindings,// new IConstraint[] { // - new NEConstant(p, owlSameAs) // + Constraint.wrap(new NEConstant(p, owlSameAs)) // }// )); Modified: 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/rules/MatchRule.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/MatchRule.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -11,6 +11,7 @@ import com.bigdata.bop.IPredicate; import com.bigdata.bop.IVariable; import com.bigdata.bop.NV; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.INBinarySearch; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.spo.ExplicitSPOFilter; @@ -59,7 +60,7 @@ .getConstant(RDFS.SUBCLASSOF), cls) // }, new IConstraint[] { - new INBinarySearch(var("p"), preds) // p IN preds + Constraint.wrap(new INBinarySearch(var("p"), preds)) // p IN preds }); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RejectAnythingSameAsItself.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RejectAnythingSameAsItself.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RejectAnythingSameAsItself.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -30,22 +30,19 @@ import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IConstant; import com.bigdata.bop.IVariable; -import com.bigdata.bop.constraint.BOpConstraint; +import com.bigdata.bop.constraint.BooleanValueExpression; /** * Rejects (x y z) iff x==z and y==owl:sameAs, where x, y, and z are variables. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ -public class RejectAnythingSameAsItself extends BOpConstraint { +public class RejectAnythingSameAsItself extends BooleanValueExpression { /** - * - */ - private static final long serialVersionUID = 1L; + * + */ + private static final long serialVersionUID = -44020295153412258L; - /** + /** * Required shallow copy constructor. */ public RejectAnythingSameAsItself(final BOp[] values, @@ -79,7 +76,7 @@ } @SuppressWarnings("unchecked") - public boolean accept(final IBindingSet bindingSet) { + public Boolean get(final IBindingSet bindingSet) { // get binding for "x". final IConstant<Long> s = bindingSet.get((IVariable<?>) get(0)/* s */); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure11.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure11.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure11.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -28,6 +28,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -65,7 +66,7 @@ new SPOPredicate(relationName,var("a"), vocab.getConstant(RDFS.DOMAIN), var("b"))// }, new IConstraint[] { - new NE(var("y"),var("a")) + Constraint.wrap(new NE(var("y"),var("a"))) }); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure13.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure13.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleFastClosure13.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -28,6 +28,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -65,7 +66,7 @@ new SPOPredicate(relationName,var("a"), vocab.getConstant(RDFS.RANGE), var("b"))// }, new IConstraint[] { - new NE(var("y"),var("a")) + Constraint.wrap(new NE(var("y"),var("a"))) }); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlInverseOf1.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlInverseOf1.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlInverseOf1.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -30,6 +30,7 @@ import org.openrdf.model.vocabulary.OWL; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -63,7 +64,7 @@ new SPOPredicate(relationName,var("a"), vocab.getConstant(OWL.INVERSEOF), var("b")),// }, new IConstraint[] { - new NE(var("a"),var("b")) + Constraint.wrap(new NE(var("a"),var("b"))) } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -30,6 +30,7 @@ import org.openrdf.model.vocabulary.OWL; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -63,7 +64,7 @@ new SPOPredicate(relationName,var("x"), vocab.getConstant(OWL.SAMEAS), var("y"))// }, new IConstraint[] { - new NE(var("x"),var("y")) + Constraint.wrap(new NE(var("x"),var("y"))) } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1b.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1b.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs1b.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -30,6 +30,7 @@ import org.openrdf.model.vocabulary.OWL; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -64,9 +65,9 @@ new SPOPredicate(relationName,var("x"), vocab.getConstant(OWL.SAMEAS), var("y")),// new SPOPredicate(relationName,var("y"), vocab.getConstant(OWL.SAMEAS), var("z"))// }, new IConstraint[] { - new NE(var("x"),var("y")), - new NE(var("y"),var("z")), - new NE(var("x"),var("z")), + Constraint.wrap(new NE(var("x"),var("y"))), + Constraint.wrap(new NE(var("y"),var("z"))), + Constraint.wrap(new NE(var("x"),var("z"))), } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs2.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs2.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs2.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -29,6 +29,7 @@ import org.openrdf.model.vocabulary.OWL; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.bop.constraint.NEConstant; import com.bigdata.rdf.spo.SPOPredicate; @@ -68,8 +69,8 @@ * Reject (y sameAs z) as the head. */ // new RejectAnythingSameAsItself(var("y"),var("a"),var("z"),vocab.getConstant(OWL.SAMEAS)) - new NEConstant(var("a"),vocab.getConstant(OWL.SAMEAS)), - new NE(var("x"),var("y")) + Constraint.wrap(new NEConstant(var("a"),vocab.getConstant(OWL.SAMEAS))), + Constraint.wrap(new NE(var("x"),var("y"))) } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs3.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs3.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlSameAs3.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -30,6 +30,7 @@ import org.openrdf.model.vocabulary.OWL; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.bop.constraint.NEConstant; import com.bigdata.rdf.spo.SPOPredicate; @@ -67,8 +68,8 @@ * Reject (z sameAs y) as the head. */ // new RejectAnythingSameAsItself(var("z"),var("a"),var("y"),vocab.getConstant(OWL.SAMEAS)) - new NEConstant(var("a"),vocab.getConstant(OWL.SAMEAS)), - new NE(var("x"),var("y")) + Constraint.wrap(new NEConstant(var("a"),vocab.getConstant(OWL.SAMEAS))), + Constraint.wrap(new NE(var("x"),var("y"))) } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty1.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty1.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty1.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -31,6 +31,7 @@ import org.openrdf.model.vocabulary.RDF; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -66,9 +67,9 @@ new SPOPredicate(relationName,var("x"), var("a"), var("y")),// new SPOPredicate(relationName,var("y"), var("a"), var("z"))// }, new IConstraint[] { - new NE(var("x"),var("y")), - new NE(var("y"),var("z")), - new NE(var("x"),var("z")), + Constraint.wrap(new NE(var("x"),var("y"))), + Constraint.wrap(new NE(var("y"),var("z"))), + Constraint.wrap(new NE(var("x"),var("z"))), } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty2.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty2.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleOwlTransitiveProperty2.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -32,6 +32,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -66,7 +67,7 @@ new SPOPredicate(relationName,var("a"), vocab.getConstant(RDF.TYPE), vocab.getConstant(OWL.TRANSITIVEPROPERTY)),// new SPOPredicate(relationName,var("b"), vocab.getConstant(RDFS.SUBPROPERTYOF), var("a"))// }, new IConstraint[] { - new NE(var("a"),var("b")), + Constraint.wrap(new NE(var("a"),var("b"))), } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs05.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs05.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs05.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -26,6 +26,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -57,8 +58,8 @@ new SPOPredicate(relationName,var("v"), vocab.getConstant(RDFS.SUBPROPERTYOF), var("x")) // }, new IConstraint[] { - new NE(var("u"),var("v")), - new NE(var("v"),var("x")) + Constraint.wrap(new NE(var("u"),var("v"))), + Constraint.wrap(new NE(var("v"),var("x"))) }); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs07.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs07.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs07.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -26,6 +26,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -55,7 +56,7 @@ new SPOPredicate(relationName,var("u"), var("a"), var("y"))// }, new IConstraint[] { - new NE(var("a"),var("b")) + Constraint.wrap(new NE(var("a"),var("b"))) } ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs09.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs09.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs09.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -27,6 +27,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -55,7 +56,7 @@ new SPOPredicate(relationName,var("v"), vocab.getConstant(RDF.TYPE), var("u"))// }, new IConstraint[] { - new NE(var("u"),var("x")) + Constraint.wrap(new NE(var("u"),var("x"))) }); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs11.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs11.java 2011-02-22 23:38:00 UTC (rev 4228) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/rules/RuleRdfs11.java 2011-02-22 23:39:14 UTC (rev 4229) @@ -26,6 +26,7 @@ import org.openrdf.model.vocabulary.RDFS; import com.bigdata.bop.IConstraint; +import com.bigdata.bop.constraint.Constraint; import com.bigdata.bop.constraint.NE; import com.bigdata.rdf.spo.SPOPredicate; import com.bigdata.rdf.vocab.Vocabulary; @@ -59,8 +60,8 @@ new SPOPredicate(relationName,var("v"), vocab.getConstant(RDFS.SUBCLASSOF), var("x")) // }, new IConstraint[] { - new NE(var("u"),var("v")), - new NE(var("v"),var("x")) + Constraint.wrap(new NE(var("u"),var("v"))), + Constraint.wrap(new NE(var("v"),var("x"))) }); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2011-03-07 21:13:16
|
Revision: 4278 http://bigdata.svn.sourceforge.net/bigdata/?rev=4278&view=rev Author: thompsonbry Date: 2011-03-07 21:13:10 +0000 (Mon, 07 Mar 2011) Log Message: ----------- Reconciled some things about RangeBOp evaluation with MikeP. RangeBOp#asBound(...) now traps type errors and SPOPredicate#asBound(...) does not. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RangeBOp.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RangeBOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RangeBOp.java 2011-03-07 19:58:52 UTC (rev 4277) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/constraints/RangeBOp.java 2011-03-07 21:13:10 UTC (rev 4278) @@ -57,9 +57,11 @@ public interface Annotations extends ImmutableBOp.Annotations { String VAR = (RangeBOp.class.getName() + ".var").intern(); - + + /** The inclusive lower bound. */ String FROM = (RangeBOp.class.getName() + ".from").intern(); + /** The exclusive upper bound. */ String TO = (RangeBOp.class.getName() + ".to").intern(); } @@ -160,35 +162,49 @@ final public RangeBOp asBound(final IBindingSet bs) { -// log.debug("getting the asBound value"); - - final IV from = from().get(bs); - -// log.debug("from: " + from); + IV from, to; + try { + // log.debug("getting the asBound value"); - // sort of like Var.get(), which returns null when the variable - // is not yet bound - if (from == null) + from = from().get(bs); + + // log.debug("from: " + from); + + // sort of like Var.get(), which returns null when the variable + // is not yet bound + if (from == null) + return this; + + to = to().get(bs); + + // log.debug("to: " + to); + + // sort of like Var.get(), which returns null when the variable + // is not yet bound + if (to == null) + return this; + + } catch (SparqlTypeErrorException ex) { + + /* + * Ignore. If the variables in the RangeBOp value expressions are + * not fully bound or has the wrong dynamic type then the range bop + * can not be evaluated yet. + */ + return this; + + } - final IV to = to().get(bs); - -// log.debug("to: " + to); - - // sort of like Var.get(), which returns null when the variable - // is not yet bound - if (to == null) - return this; - - // Note: defer clone() until everything is bound. - final RangeBOp asBound = (RangeBOp) this.clone(); - - asBound._setProperty(Annotations.FROM, new Constant(from)); - asBound._setProperty(Annotations.TO, new Constant(to)); - - return asBound; - - } + // Note: defer clone() until everything is bound. + final RangeBOp asBound = (RangeBOp) this.clone(); + + asBound._setProperty(Annotations.FROM, new Constant(from)); + asBound._setProperty(Annotations.TO, new Constant(to)); + + return asBound; + + } final public boolean isFullyBound() { Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java 2011-03-07 19:58:52 UTC (rev 4277) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java 2011-03-07 21:13:10 UTC (rev 4278) @@ -512,6 +512,7 @@ } + @Override public byte[] getToKey(final IKeyBuilder keyBuilder, final IPredicate<ISPO> predicate) { 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 2011-03-07 19:58:52 UTC (rev 4277) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOPredicate.java 2011-03-07 21:13:10 UTC (rev 4278) @@ -322,37 +322,13 @@ if (rangeBOp == null) return tmp; - try { + /* + * Attempt to evaluate the RangeBOp. + */ + final RangeBOp asBound = rangeBOp.asBound(bindingSet); - /* - * Attempt to evaluate the RangeBOp. - */ - final RangeBOp asBound = rangeBOp.asBound(bindingSet); + tmp._setProperty(Annotations.RANGE, asBound); - tmp._setProperty(Annotations.RANGE, asBound); - - } catch (SparqlTypeErrorException.UnboundVarException ex) { - - /* - * If there was an unbound variable in the RangeBOp annotation then - * we will drop the RangeBOp. - * - * FIXME I have modified SPOPredicate#asBound(...) to trap type - * errors arising from attempts to evaluate a RangeBOp when some - * variable(s) are not bound. This presumes that the RangeBOp is in - * addition to (not instead of) the value expression from which the - * RangeBOp constraint was derived. Verify with MikeP. - * - * I am not sure that this is the right thing to do, but it allows - * the RTO to run. It may be that the underlying problem is making - * the PartitionedJoinGroup aware of the RangeBOp such that we do - * not attempt evaluation orders which would cause the RangeBOP to - * throw a type error. This gets into the area of alternative query - * plans rather than just alternative join orderings. - */ - - } - return tmp; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2011-05-18 13:04:01
|
Revision: 4515 http://bigdata.svn.sourceforge.net/bigdata/?rev=4515&view=rev Author: thompsonbry Date: 2011-05-18 13:03:50 +0000 (Wed, 18 May 2011) Log Message: ----------- Updated the JustificationIterator code a bit, reduced the maximum amount of data that it will buffer on the heap to keep down the heap pressure, removed the "timeout" logic, and modified it to run a FutureTask on the ExecutorService associated with the IIndexManager rather than using its own local singled-threaded executor service. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/IJustificationIterator.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/JustificationIterator.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/JustificationWriter.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/IJustificationIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/IJustificationIterator.java 2011-05-17 18:46:55 UTC (rev 4514) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/IJustificationIterator.java 2011-05-18 13:03:50 UTC (rev 4515) @@ -27,8 +27,6 @@ package com.bigdata.rdf.inf; -import org.apache.log4j.Logger; - import com.bigdata.striterator.IChunkedIterator; /** @@ -39,6 +37,4 @@ */ public interface IJustificationIterator extends IChunkedIterator<Justification> { - final Logger log = Logger.getLogger(IJustificationIterator.class); - } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/JustificationIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/JustificationIterator.java 2011-05-17 18:46:55 UTC (rev 4514) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/inf/JustificationIterator.java 2011-05-18 13:03:50 UTC (rev 4515) @@ -30,17 +30,17 @@ import java.util.NoSuchElementException; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.log4j.Logger; + import com.bigdata.btree.IIndex; import com.bigdata.btree.IRangeQuery; import com.bigdata.btree.ITupleIterator; +import com.bigdata.journal.IIndexManager; import com.bigdata.rawstore.Bytes; import com.bigdata.relation.accesspath.IElementFilter; -import com.bigdata.util.concurrent.DaemonThreadFactory; /** * Iterator visits {@link Justification}s reading from the justification index. @@ -55,10 +55,13 @@ */ public class JustificationIterator implements IJustificationIterator { + private static final transient Logger log = Logger + .getLogger(JustificationIterator.class); + /** * The maximum #of statements that will be buffered by the iterator. */ - public static final transient int MAXIMUM_CAPACITY = 100 * Bytes.kilobyte32; + private static final transient int MAXIMUM_CAPACITY = 10 * Bytes.kilobyte32; // was 100k private boolean open = true; @@ -96,31 +99,37 @@ /** * The source iterator reading on the selected justification index. */ - private ITupleIterator src; + private ITupleIterator<?> src; +// /** +// * The executor service for the {@link Reader} (iff the {@link Reader} runs +// * asynchronously). +// */ +// private final ExecutorService readService; + /** - * The executor service for the {@link Reader} (iff the {@link Reader} runs - * asynchronously). + * The future for the {@link Reader} and <code>null</code> if a synchronous + * read was performed (fully buffered read in the caller's thread). */ - private final ExecutorService readService; - + private final FutureTask<Object> ft; + /** * Set to true iff an asynchronous {@link Reader} is used AND there is * nothing more to be read. */ - private AtomicBoolean readerDone = new AtomicBoolean(false); + private final AtomicBoolean readerDone = new AtomicBoolean(false); /** * The minimum desirable chunk size for {@link #nextChunk()}. */ - final int MIN_CHUNK_SIZE = 50000; + static private final int MIN_CHUNK_SIZE = 100; - /** - * If NO results show up within this timeout then {@link #nextChunk()} will - * throw a {@link RuntimeException} to abort the reader - the probably cause - * is a network outage. - */ - final long TIMEOUT = 3000; +// /** +// * If NO results show up within this timeout then {@link #nextChunk()} will +// * throw a {@link RuntimeException} to abort the reader - the probably cause +// * is a network outage. +// */ +// static private final long TIMEOUT = Long.MAX_VALUE; /** * Create an iterator reading from the justifications index. @@ -133,26 +142,29 @@ * value is used - this gives you control when you really, really * want to have something fully buffered, e.g., for an in-memory * self-join. - * @param async - * When true, asynchronous read-ahead will be used to refill the - * buffer as it becomes depleted. When false, read-ahead will be - * synchronous (this is useful when you want to read at most N - * statements from the index). */ - public JustificationIterator(IIndex ndx, int capacity, boolean async) { + public JustificationIterator(final IIndexManager indexManager, + final IIndex ndx, int capacity) { - assert ndx != null; - - assert capacity >= 0; + if (indexManager == null) + throw new IllegalArgumentException(); + if (ndx == null) + throw new IllegalArgumentException(); + + if (capacity < 0) + throw new IllegalArgumentException(); + /* - * The range count. - * - * Note: The range count is generally an upper bound rather than an - * exact value. + * When true, asynchronous read-ahead will be used to refill the buffer + * as it becomes depleted. When false, read-ahead will be synchronous + * (this is useful when you want to read at most N statements from the + * index). */ + boolean async = true; - final long rangeCount = ndx.rangeCount(null,null); + // The fast range count (upper bound) + final long rangeCount = ndx.rangeCount(); if (capacity == 0) { @@ -171,6 +183,7 @@ } else { + // Otherwise use the range count (upper bound). capacity = (int) rangeCount; } @@ -204,7 +217,7 @@ } - if( rangeCount < 1000) { + if (rangeCount < 100) { // Disable async reads if we are not reading much data. @@ -224,29 +237,25 @@ this.capacity = capacity; - this.src = ndx.rangeIterator(null, null,0/*capacity*/,IRangeQuery.KEYS,null/*filter*/); + this.src = ndx.rangeIterator(null/* fromKey */, null/* toKey */, + 0/* capacity */, IRangeQuery.KEYS, null/* filter */); this.buffer = new ArrayBlockingQueue<Justification>(capacity); if (async) { - /* - * FIXME provide an API to run this on an existing executorService - * just like we do for proxied asynchronous iterators. - */ - readService = Executors.newSingleThreadExecutor(new DaemonThreadFactory - (getClass().getName()+".readService")); + // wrap reader as Future + ft = new FutureTask<Object>(new Reader()); + + // submit for asynchronous read ahead + indexManager.getExecutorService().submit(ft); - readService.submit(new Reader()); - } else { - /* - * Pre-fill the buffer. - */ + // Fill the buffer (synchronous). - readService = null; - + ft = null; + fillBuffer(); } @@ -270,7 +279,7 @@ while (src.hasNext()) { - Justification t = (Justification)src.next().getObject(); + final Justification t = (Justification)src.next().getObject(); try { @@ -310,16 +319,15 @@ assertOpen(); - if (readService != null) { + if (ft != null) { // This method MUST NOT be invoked when using the async reader. - throw new AssertionError(); } try { - // log.info("(Re-)filling buffer: remainingCapacity=" + // if(log.isDebugEnabled()) log.debug("(Re-)filling buffer: remainingCapacity=" // + buffer.remainingCapacity()); while (src.hasNext() && buffer.remainingCapacity() > 0) { @@ -347,8 +355,8 @@ } finally { - if (log.isInfoEnabled()) - log.info("(Re-)filled buffer: size=" + buffer.size() + if (log.isDebugEnabled()) + log.debug("(Re-)filled buffer: size=" + buffer.size() + ", remainingCapacity=" + buffer.remainingCapacity() + ", done=" + !src.hasNext()); @@ -368,16 +376,14 @@ * the underlying iterator. */ - if (readService != null) { + if (ft != null) { // async reader - so wait on it. - awaitReader(); } else { // sync reader - so fill the buffer in this thread. - fillBuffer(); } @@ -385,15 +391,13 @@ if (buffer.isEmpty()) { // the buffer is still empty, so the iterator is exhausted. - return false; } } - // at least one SPO in the buffer. - + // at least one Justification in the buffer. return true; } @@ -439,30 +443,29 @@ } - if (readService != null) { + if (ft != null) { // make sure that we fill the buffer before we deliver a chunk. - awaitReader(); } // there are at least this many in the buffer. - final int n = buffer.size(); // allocate the array. + final Justification[] stmts = new Justification[n]; - Justification[] stmts = new Justification[n]; - for (int i = 0; i < n; i++) { stmts[i] = next(); } - log.info("chunkSize=" + n + ", nchunks=" + nchunks + ", #read(caller)=" - + numReadByCaller + ", #read(src)=" + numBuffered); + if (log.isDebugEnabled()) + log.debug("chunkSize=" + n + ", nchunks=" + nchunks + + ", #read(caller)=" + numReadByCaller + ", #read(src)=" + + numBuffered); return stmts; @@ -480,7 +483,7 @@ */ private void awaitReader() { - if (readService == null) { + if (ft == null) { /* * This method MUST NOT be invoked unless you are using the async @@ -491,7 +494,7 @@ } - final long begin = System.currentTimeMillis(); +// final long begin = System.currentTimeMillis(); /* * Wait for at least N records to show up. @@ -503,6 +506,18 @@ try { + /* + * TODO This uses a Thread.sleep() to avoid a lock ordering + * problem because we did not have access to the lock used + * internally by the blocking queue when this code was written. + * However, we now have incorporated at least one JSR166 + * blocking queue class which can use the caller's lock. That + * makes it possible to setup conditions which can be awaited + * for full/not-full, etc., but you have to be careful not to + * violate the manner in which the lock signal/notify semantics + * are used internally by the blocking queue implementation. + */ + Thread.sleep(10/*ms*/); } catch (InterruptedException ex) { @@ -511,14 +526,14 @@ } - long elapsed = System.currentTimeMillis() - begin; +// final long elapsed = System.currentTimeMillis() - begin; +// +// if (elapsed > TIMEOUT && buffer.isEmpty()) { +// +// throw new RuntimeException("Timeout after " + elapsed + "ms"); +// +// } - if (elapsed > TIMEOUT && buffer.isEmpty()) { - - throw new RuntimeException("Timeout after " + elapsed + "ms"); - - } - } } @@ -539,40 +554,37 @@ if (!open) { // Already closed. - return; } - log.info("Closing iterator"); + log.debug("Closing iterator"); open = false; - if (readService != null) { + if (ft != null) { - // immediate shutdown. - readService.shutdownNow(); + // terminate the Reader. + ft.cancel(true/* mayInterruptIfRunning */); - try { +// try { +// +// readService.awaitTermination(500, TimeUnit.MILLISECONDS); +// +// } catch (InterruptedException e) { +// +// log.warn("Read service did not terminate: " + e); +// +// } - readService.awaitTermination(500, TimeUnit.MILLISECONDS); - - } catch (InterruptedException e) { - - log.warn("Read service did not terminate: " + e); - - } - } // discard buffer. - buffer.clear(); buffer = null; // discard the source iterator. - src = null; } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/JustificationWriter.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/JustificationWriter.java 2011-05-17 18:46:55 UTC (rev 4514) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/JustificationWriter.java 2011-05-18 13:03:50 UTC (rev 4515) @@ -40,8 +40,8 @@ * Incremented as a side-effect for each justification * actually written on the justification index. */ - public JustificationWriter(AbstractTripleStore dst, - IChunkedIterator<Justification> src, AtomicLong nwritten) { + public JustificationWriter(final AbstractTripleStore dst, + final IChunkedIterator<Justification> src, final AtomicLong nwritten) { this.dst = dst; Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2011-05-17 18:46:55 UTC (rev 4514) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2011-05-18 13:03:50 UTC (rev 4515) @@ -3208,8 +3208,9 @@ if (justify) { final IJustificationIterator jitr = new JustificationIterator( + getIndexManager(), getSPORelation().getJustificationIndex(), - 0/* capacity */, true/* async */); + 0/* capacity */); tasks.add(new JustificationWriter(dst, jitr, nwrittenj)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |