Update of /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22601/src/java/com/bigdata/rdf/inf Modified Files: RuleRdfs09.java RuleRdfs13.java RuleRdfs08.java InferenceEngine.java Rule.java RuleRdf01.java RuleRdfs11.java RuleRdfs03.java RuleRdfs02.java RuleRdfs06.java RuleRdfs10.java RuleRdfs12.java RuleRdfs05.java RuleRdfs07.java Added Files: AbstractRuleRdfs_6_8_10_12_13.java package.html AbstractRuleRdfs_2_3_7_9.java AbstractRuleRdfs_5_11.java Removed Files: AbstractRuleRdfs511.java AbstractRuleRdfs2379.java AbstractRuleRdfs68101213.java Log Message: testing SAIL and lubm, including adding BTree#removeAll(), touching up some inferences, making it possible to load different RDF interchange formats, and adding JOIN ordering based on the sesame optimizer and the actual triple pattern selectivity in the data. Index: RuleRdfs08.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs08.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs08.java 31 Jan 2007 04:11:50 -0000 1.1 --- RuleRdfs08.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 44,48 **** package com.bigdata.rdf.inf; ! public class RuleRdfs08 extends AbstractRuleRdfs68101213 { public RuleRdfs08(InferenceEngine store, Var u, Var v, Var x) { --- 44,48 ---- package com.bigdata.rdf.inf; ! public class RuleRdfs08 extends AbstractRuleRdfs_6_8_10_12_13 { public RuleRdfs08(InferenceEngine store, Var u, Var v, Var x) { Index: RuleRdfs07.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs07.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RuleRdfs07.java 13 Apr 2007 20:37:04 -0000 1.2 --- RuleRdfs07.java 18 Apr 2007 17:29:07 -0000 1.3 *************** *** 45,53 **** /** * <pre> ! * <a rdfs:subPropertyOf b> AND <u a y> IMPLIES <u b y> * </pre> */ ! public class RuleRdfs07 extends AbstractRuleRdfs2379 { public RuleRdfs07( InferenceEngine store, Var a, Var b, Var u, Var y ) { --- 45,56 ---- /** + * rdfs7: * <pre> ! * triple(?u,?b,?y) :- ! * triple(?a,rdfs:subPropertyOf,?b), ! * triple(?u,?a,?y). * </pre> */ ! public class RuleRdfs07 extends AbstractRuleRdfs_2_3_7_9 { public RuleRdfs07( InferenceEngine store, Var a, Var b, Var u, Var y ) { *************** *** 67,69 **** } ! } \ No newline at end of file --- 70,72 ---- } ! } Index: RuleRdfs06.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs06.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs06.java 31 Jan 2007 04:11:50 -0000 1.1 --- RuleRdfs06.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 44,48 **** package com.bigdata.rdf.inf; ! public class RuleRdfs06 extends AbstractRuleRdfs68101213 { public RuleRdfs06(InferenceEngine store, Var u, Var v, Var x) { --- 44,58 ---- package com.bigdata.rdf.inf; ! /** ! * rdfs6: ! * <pre> ! * triple( ?u rdfs:subPropertyOf ?u ) :- ! * triple( ?u rdf:type rdf:Property ). ! * </pre> ! * ! * @author <a href="mailto:tho...@us...">Bryan Thompson</a> ! * @version $Id$ ! */ ! public class RuleRdfs06 extends AbstractRuleRdfs_6_8_10_12_13 { public RuleRdfs06(InferenceEngine store, Var u, Var v, Var x) { Index: RuleRdfs12.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs12.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs12.java 31 Jan 2007 04:11:50 -0000 1.1 --- RuleRdfs12.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 44,48 **** package com.bigdata.rdf.inf; ! public class RuleRdfs12 extends AbstractRuleRdfs68101213 { public RuleRdfs12(InferenceEngine store, Var u, Var v, Var x) { --- 44,48 ---- package com.bigdata.rdf.inf; ! public class RuleRdfs12 extends AbstractRuleRdfs_6_8_10_12_13 { public RuleRdfs12(InferenceEngine store, Var u, Var v, Var x) { Index: RuleRdfs13.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs13.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs13.java 31 Jan 2007 04:11:50 -0000 1.1 --- RuleRdfs13.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 44,48 **** package com.bigdata.rdf.inf; ! public class RuleRdfs13 extends AbstractRuleRdfs68101213 { public RuleRdfs13(InferenceEngine store, Var u, Var v, Var x) { --- 44,48 ---- package com.bigdata.rdf.inf; ! public class RuleRdfs13 extends AbstractRuleRdfs_6_8_10_12_13 { public RuleRdfs13(InferenceEngine store, Var u, Var v, Var x) { Index: RuleRdfs09.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs09.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RuleRdfs09.java 13 Apr 2007 20:37:04 -0000 1.4 --- RuleRdfs09.java 18 Apr 2007 17:29:07 -0000 1.5 *************** *** 46,56 **** import com.bigdata.rdf.KeyOrder; - /** * <pre> * <u rdfs:subClassOf x> AND <v rdf:type u> IMPLIES <v rdf:type x> * </pre> */ ! public class RuleRdfs09 extends AbstractRuleRdfs2379 { public RuleRdfs09( InferenceEngine store, Var u, Var x, Var v ) { --- 46,61 ---- import com.bigdata.rdf.KeyOrder; /** + * rdfs9: + * <pre> + * triple(?v,rdf:type,?x) :- + * triple(?u,rdfs:subClassOf,?x), + * triple(?v,rdf:type,?u). + * </pre> * <pre> * <u rdfs:subClassOf x> AND <v rdf:type u> IMPLIES <v rdf:type x> * </pre> */ ! public class RuleRdfs09 extends AbstractRuleRdfs_2_3_7_9 { public RuleRdfs09( InferenceEngine store, Var u, Var x, Var v ) { *************** *** 64,67 **** --- 69,77 ---- } + /** + * Overriden to be two bound (more selective), but otherwise also returning + * data in POS order. The query is formed from triple(?v,rdf:type,stmt1.s) + * and expressed in POS order as { rdf:type, stmt1.s, ?v }. + */ protected SPO[] getStmts2( SPO stmt1 ) { --- AbstractRuleRdfs2379.java DELETED --- Index: RuleRdfs05.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs05.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs05.java 31 Jan 2007 05:23:20 -0000 1.1 --- RuleRdfs05.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 55,59 **** * </pre> */ ! public class RuleRdfs05 extends AbstractRuleRdfs511 { public RuleRdfs05(InferenceEngine store,Var u, Var v, Var x) { --- 55,59 ---- * </pre> */ ! public class RuleRdfs05 extends AbstractRuleRdfs_5_11 { public RuleRdfs05(InferenceEngine store,Var u, Var v, Var x) { Index: RuleRdf01.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdf01.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RuleRdf01.java 14 Apr 2007 13:33:51 -0000 1.8 --- RuleRdf01.java 18 Apr 2007 17:29:07 -0000 1.9 *************** *** 47,51 **** import com.bigdata.rdf.KeyOrder; ! public class RuleRdf01 extends AbstractRuleRdf { --- 47,58 ---- import com.bigdata.rdf.KeyOrder; ! /** ! * Rdf1: ! * ! * <pre> ! * triple(?v rdf:type rdf:Property) :- ! * triple( ?u ?v ?x ). ! * </pre> ! */ public class RuleRdf01 extends AbstractRuleRdf { *************** *** 65,68 **** --- 72,89 ---- long lastP = -1; + /* + * This is essentially doing a "select distinct predicate". + * + * FIXME there should be a lighter weight way of achieving this result. + * One way would be to create a "predicates" index that had each + * distinct predicate (further denormalizing the schema and requiring + * maintenance). Another approach is to restart the iterator each time a + * predicate [p] is found by computing the fromKey as [p+1] thereby + * skipping over all intervening statements in the index (consider how + * to distribute that query in parallel). + * + * @todo write a test for this rule and then write an optimized variant + * using the incremented toKey approach. + */ IEntryIterator it = store.getPOSIndex().rangeIterator(null,null); Index: RuleRdfs02.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs02.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs02.java 31 Jan 2007 15:52:54 -0000 1.1 --- RuleRdfs02.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 46,50 **** ! public class RuleRdfs02 extends AbstractRuleRdfs2379 { public RuleRdfs02( InferenceEngine store, Var a, Var x, Var u, Var y ) { --- 46,50 ---- ! public class RuleRdfs02 extends AbstractRuleRdfs_2_3_7_9 { public RuleRdfs02( InferenceEngine store, Var a, Var x, Var u, Var y ) { --- NEW FILE: package.html --- <html> <head> <title>RDFS+ Inference Engine</title> </head> <body> <p> This package provides an eager closure inference engine for most of the RDF and RDFS entailments and can be used to realize entailments for owl:sameAs, owl:equivilentClass, and owl:equivilentProperty. </p> <p> The following entailment rules are NOT implemented. In general, these tends to conclude relatively useless information and lead to a large expansion of the KB. <ul> <li>rdf2</li> <li>rdfs1</li> <li>rdfs4a</li> <li>rdfs4b</li> </ul> </p> </body> </html> --- AbstractRuleRdfs511.java DELETED --- Index: InferenceEngine.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/InferenceEngine.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** InferenceEngine.java 14 Apr 2007 13:33:51 -0000 1.14 --- InferenceEngine.java 18 Apr 2007 17:29:07 -0000 1.15 *************** *** 71,82 **** * </pre> * ! * where s, p, and or are identifiers for RDF values in the terms index. ! * Facts are stored either in the long-term database or in a per-query answer ! * set. * <p> * A rule always has the form: * * <pre> ! * pred :- pred*. * </pre> * --- 71,81 ---- * </pre> * ! * where s, p, and or are identifiers for RDF values in the terms index. Facts ! * are stored either in the long-term database or in a per-query answer set. * <p> * A rule always has the form: * * <pre> ! * pred :- pred*. * </pre> * *************** *** 113,119 **** * * <pre> ! * triple(?v,rdf:type,?x) :- ! * triple(?u,rdfs:subClassOf,?x), ! * triple(?v,rdf:type,?u). * </pre> * --- 112,118 ---- * * <pre> ! * triple(?v,rdf:type,?x) :- ! * triple(?u,rdfs:subClassOf,?x), ! * triple(?v,rdf:type,?u). * </pre> * *************** *** 121,131 **** * * <pre> ! * triple(?u,rdfs:subClassOf,?x) :- ! * triple(?u,rdfs:subClassOf,?v), ! * triple(?v,rdf:subClassOf,?x). * </pre> * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class InferenceEngine extends TripleStore { --- 120,139 ---- * * <pre> ! * triple(?u,rdfs:subClassOf,?x) :- ! * triple(?u,rdfs:subClassOf,?v), ! * triple(?v,rdf:subClassOf,?x). * </pre> * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ + * + * @todo experiment with use of a bloom filter + * + * @todo provide fixed point transitive closure for "chain" rules (subClassOf) + * + * @todo examine ways to prune the search space and avoid re-triggering rules or + * being more selective with rule triple patterns as a consequence of new + * entailments (avoid re-computing all entailments already proven in each + * pass). */ public class InferenceEngine extends TripleStore { *************** *** 209,212 **** --- 217,222 ---- * * @see #rdfType and friends which are initialized by this method. + * + * @todo make this into a batch operation. */ protected void setupIds() { *************** *** 309,312 **** --- 319,325 ---- * big win for the batch oriented parser and would probably eliminate * even more duplicates in the context of the inference engine. + * + * @todo support closure of a document against an ontology and then bulk + * load the result into the store. */ public void fullForwardClosure() { *************** *** 395,401 **** + ", entailments=" + nnew + ", #stmts1=" + ruleStats.stmts1 + ", #stmts2=" ! + ruleStats.stmts2 + ", #stmtsExaminedPerSec=" ! + stmtsPerSec ! ); } --- 408,414 ---- + ", entailments=" + nnew + ", #stmts1=" + ruleStats.stmts1 + ", #stmts2=" ! + ruleStats.stmts2 + ", #subqueries=" ! + ruleStats.numSubqueries ! + ", #stmtsExaminedPerSec=" + stmtsPerSec); } *************** *** 473,476 **** --- 486,490 ---- log.info("Computed closure of store in " + + round + " rounds and " + elapsed + "ms yeilding " --- AbstractRuleRdfs68101213.java DELETED --- --- NEW FILE: AbstractRuleRdfs_2_3_7_9.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ package com.bigdata.rdf.inf; import java.util.Arrays; import com.bigdata.rdf.KeyOrder; public abstract class AbstractRuleRdfs_2_3_7_9 extends AbstractRuleRdf { public AbstractRuleRdfs_2_3_7_9 ( InferenceEngine store, Triple head, Pred[] body ) { super( store, head, body ); } public Stats apply( final Stats stats, final SPOBuffer buffer) { final long computeStart = System.currentTimeMillis(); // in SPO order. SPO[] stmts1 = getStmts1(); stats.stmts1 += stmts1.length; /* For example, rdfs7: * * triple(?u,?b,?y) :- * triple(?a,rdfs:subPropertyOf,?b), * triple(?u,?a,?y). */ /* * Subquery is one bound: ?u:a:?y. * * Since stmt1.s := stmt2.p, we only execute N distinct subqueries for N * distinct values of stmt1.s. This works because stmts1 is in SPO * order, so the subject values are clustered into an ascending order. * * Note: I have observed very little or _possibly_ a slight negative * impact on performance from the attempt to reuse subqueries for the * same subject. Presumably this is because the subjects are already * mostly distinct, so we just pay for the cost of sorting them and do * not normally get a reduction in the #of subqueries. The alternative * is to have getStmts1() return the statements without sorting them so * that they will be in POS order since that is the index that we are * querying. The conditional tests on lastS here are still Ok, it is * just much less likely that we will ever reuse a subquery. */ long lastS = NULL; SPO[] stmts2 = null; for (int i = 0; i < stmts1.length; i++) { SPO stmt1 = stmts1[i]; if(lastS==NULL || lastS!=stmt1.s) { lastS = stmt1.s; // Subquery on the POS index using stmt2.p := stmt1.s. stmts2 = getStmts2(stmt1); stats.stmts2 += stmts2.length; stats.numSubqueries++; } for (int j = 0; j < stmts2.length; j++) { buffer.add(buildStmt3(stmt1, stmts2[j])); stats.numComputed++; } } stats.computeTime += System.currentTimeMillis() - computeStart; return stats; } /** * The default behavior is to use POS index to match body[0] with one bound * (the predicate). The statements are buffered and then sorted into SPO * order. */ final protected SPO[] getStmts1() { // use the POS index to look up the matches for body[0], the more // constrained triple byte[] fromKey = store.keyBuilder.statement2Key(body[0].p.id, NULL, NULL); byte[] toKey = store.keyBuilder.statement2Key(body[0].p.id + 1, NULL, NULL); SPO[] stmts = store.getStatements(store.getPOSIndex(), KeyOrder.POS, fromKey, toKey); /* * Sort into SPO order. * * Note: you can comment this out to compare with POS order. The JOIN * is still correct, but the logic to reuse subqueries in apply() is * mostly defeated when the statements are not sorted into SPO order. */ Arrays.sort(stmts,SPOComparator.INSTANCE); return stmts; } /** * A one bound subquery using the POS index with the subject of stmt1 as the * predicate of body[1]. The object and subject positions in the subquery * are unbound. * * @see RuleRdfs09#getStmts2(SPO) */ protected SPO[] getStmts2(SPO stmt1) { /* * The subject from stmt1 is in the predicate position for this query. */ byte[] fromKey = store.keyBuilder.statement2Key(stmt1.s, NULL, NULL); byte[] toKey = store.keyBuilder.statement2Key(stmt1.s + 1, NULL, NULL); return store.getStatements(store.getPOSIndex(), KeyOrder.POS, fromKey, toKey); } protected abstract SPO buildStmt3( SPO stmt1, SPO stmt2 ); } --- NEW FILE: AbstractRuleRdfs_5_11.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ package com.bigdata.rdf.inf; import java.util.Arrays; import com.bigdata.rdf.KeyOrder; import com.bigdata.rdf.TripleStore; /** * Abstract rule for chain triple patterns where the object position in the * first triple pattern is the same variable as the subject position in the * second triple pattern and where the predicate is bound to the same constant * for both triple patterns and also appears in the predicate position in the * entailed triple. * * <pre> * triple(?u,C,?x) :- * triple(?u,C,?v), * triple(?v,C,?x). * </pre> * * where C is a constant. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class AbstractRuleRdfs_5_11 extends AbstractRuleRdf { public AbstractRuleRdfs_5_11 ( InferenceEngine store, Triple head, Pred[] body ) { super( store, head, body ); } public Stats apply( final Stats stats, SPOBuffer buffer) { final long computeStart = System.currentTimeMillis(); // the predicate is fixed for all parts of the rule. final long p = head.p.id; // the key for that predicate. final byte[] pkey = store.keyBuilder.statement2Key(p, 0, 0); // the successor of that key. final byte[] pkey1 = store.keyBuilder.statement2Key(p+1, 0, 0); /* * Query for the 1st part of the rule. * * Note that it does not matter which half of the rule we execute * first since they are both 2-unbound with the same predicate bound * and will therefore have exactly the same results. * * Further note that we can perform a self-join on the returned * triples without going back to the database. */ // in POS order. final SPO[] stmts1 = store.getStatements(store.getPOSIndex(), KeyOrder.POS, pkey, pkey1); stats.stmts1 += stmts1.length; // in SPO order. Arrays.sort(stmts1,SPOComparator.INSTANCE); // a clone of the answer set // SPO[] stmts2 = stmts1.clone(); // final SPO[] stmts2 = stmts1; // stats.stmts2 += stmts2.length; // self-join using binary search. for (int i = 0; i < stmts1.length; i++) { SPO left = stmts1[i]; // printStatement(stmts1[i]); /* * Search for the index of the first statement having left.s as its * subject. Note that the object is NULL, so this should always * return a negative index which we then convert to the insert * position. The insert position is the first index at which a * matching statement would be found. We then scan statements from * that point. As soon as there is no match (and it may be that * there is no match even on the first statement tested) we break * out of the inner loop and continue with the outer loop. */ int j = Arrays.binarySearch(stmts1, new SPO(left.o, p, TripleStore.NULL), SPOComparator.INSTANCE); if (j < 0) { // Convert the position to obtain the insertion point. j = -j - 1; } // process only the stmts with left.s as their subject. for (; j < stmts1.length; j++) { if (left.o != stmts1[j].s) break; buffer.add(new SPO(left.s, p, stmts1[j].o)); stats.numComputed++; } } stats.computeTime += System.currentTimeMillis() - computeStart; return stats; } } Index: Rule.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/Rule.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Rule.java 14 Apr 2007 13:33:51 -0000 1.6 --- Rule.java 18 Apr 2007 17:29:07 -0000 1.7 *************** *** 46,49 **** --- 46,50 ---- import com.bigdata.btree.BTree; import com.bigdata.rdf.TempTripleStore; + import com.bigdata.rdf.TripleStore; *************** *** 86,89 **** --- 87,98 ---- final public Pred[] body; + /** + * The 64-bit long integer that represents an unassigned term identifier + * + * @todo use this throughout rather than "0" since the value should really + * be an <em>unsigned long</em>. + */ + final public long NULL = TripleStore.NULL; + public Rule(InferenceEngine store, Pred head, Pred[] body) { *************** *** 146,149 **** --- 155,166 ---- /** + * If the rule performs a JOIN, this is the #of distinct queries that + * are made for the 2nd triple pattern. For some rules, we can reorder + * the results from the first triple pattern in order to reduce the #of + * subqueries. + */ + public int numSubqueries; + + /** * #of statements considered. */ Index: RuleRdfs10.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs10.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs10.java 31 Jan 2007 04:11:50 -0000 1.1 --- RuleRdfs10.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 44,48 **** package com.bigdata.rdf.inf; ! public class RuleRdfs10 extends AbstractRuleRdfs68101213 { public RuleRdfs10(InferenceEngine store, Var u, Var v, Var x) { --- 44,48 ---- package com.bigdata.rdf.inf; ! public class RuleRdfs10 extends AbstractRuleRdfs_6_8_10_12_13 { public RuleRdfs10(InferenceEngine store, Var u, Var v, Var x) { Index: RuleRdfs11.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs11.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RuleRdfs11.java 14 Apr 2007 13:33:51 -0000 1.4 --- RuleRdfs11.java 18 Apr 2007 17:29:07 -0000 1.5 *************** *** 55,59 **** * </pre> */ ! public class RuleRdfs11 extends AbstractRuleRdfs511 { public RuleRdfs11(InferenceEngine store,Var u, Var v, Var x) { --- 55,59 ---- * </pre> */ ! public class RuleRdfs11 extends AbstractRuleRdfs_5_11 { public RuleRdfs11(InferenceEngine store,Var u, Var v, Var x) { --- NEW FILE: AbstractRuleRdfs_6_8_10_12_13.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ package com.bigdata.rdf.inf; import com.bigdata.btree.IEntryIterator; import com.bigdata.rdf.KeyOrder; public class AbstractRuleRdfs_6_8_10_12_13 extends AbstractRuleRdf { public AbstractRuleRdfs_6_8_10_12_13 ( InferenceEngine store, Triple head, Triple body ) { super(store, head, new Pred[] { body }); } public Stats apply( final Stats stats, final SPOBuffer buffer) { final long computeStart = System.currentTimeMillis(); byte[] startKey = store.keyBuilder.statement2Key ( body[0].p.id, body[0].o.id, 0 ); byte[] endKey = store.keyBuilder.statement2Key ( body[0].p.id, body[0].o.id+1, 0 ); IEntryIterator it = store.getPOSIndex().rangeIterator(startKey, endKey); while ( it.hasNext() ) { it.next(); stats.stmts1++; SPO stmt = new SPO(KeyOrder.POS, store.keyBuilder, it.getKey()); // @todo review -- should this be substituting stmt.s in each case? long _s = head.s.isVar() ? stmt.s : head.s.id; long _p = head.p.isVar() ? stmt.s : head.p.id; long _o = head.o.isVar() ? stmt.s : head.o.id; buffer.add( new SPO(_s, _p, _o) ); stats.numComputed++; } stats.computeTime += System.currentTimeMillis() - computeStart; return stats; } } Index: RuleRdfs03.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/inf/RuleRdfs03.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RuleRdfs03.java 31 Jan 2007 15:52:54 -0000 1.1 --- RuleRdfs03.java 18 Apr 2007 17:29:07 -0000 1.2 *************** *** 46,50 **** ! public class RuleRdfs03 extends AbstractRuleRdfs2379 { public RuleRdfs03( InferenceEngine store, Var a, Var x, Var u, Var v ) { --- 46,50 ---- ! public class RuleRdfs03 extends AbstractRuleRdfs_2_3_7_9 { public RuleRdfs03( InferenceEngine store, Var a, Var x, Var u, Var v ) { |