From: Bryan T. <tho...@us...> - 2007-04-14 13:33:55
|
Update of /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14591/src/java/com/bigdata/rdf Modified Files: TempTripleStore.java TripleStore.java Log Message: Modified RuleRdfs11 to use a binary search to locate possible matches during the self-join. This gives a big speedup on the nciOncology dataset. There is more work to do here. I think that RuleRdfs11 should fix point all by itself in order to compute the transative closure of the subClassOf relationship as quickly as possible (in as few rounds). This the join is handled in the abstract rule shared by the subPropertyOf rule, this will also provide a fast fixed point for that relation. Index: TempTripleStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/TempTripleStore.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TempTripleStore.java 13 Apr 2007 15:02:34 -0000 1.4 --- TempTripleStore.java 14 Apr 2007 13:33:52 -0000 1.5 *************** *** 48,51 **** --- 48,52 ---- package com.bigdata.rdf; + import java.util.Arrays; import java.util.Locale; import java.util.UUID; *************** *** 59,63 **** --- 60,67 ---- import com.bigdata.journal.TemporaryStore; import com.bigdata.rawstore.Bytes; + import com.bigdata.rdf.inf.OSPComparator; + import com.bigdata.rdf.inf.POSComparator; import com.bigdata.rdf.inf.SPO; + import com.bigdata.rdf.inf.SPOComparator; import com.bigdata.rdf.model.OptimizedValueFactory._Statement; import com.bigdata.rdf.serializers.StatementSerializer; *************** *** 232,235 **** --- 236,288 ---- /** + * Copies the entailments from the array into the {@link TempTripleStore}. + * + * @param stmts + * The source statements. + * + * @param n + * The #of statements in the buffer. + */ + public void addStatements(SPO[] stmts, int n ) { + + // deal with the SPO index + IIndex spo = getSPOIndex(); + Arrays.sort(stmts,0,n,SPOComparator.INSTANCE); + for ( int i = 0; i < n; i++ ) { + byte[] key = keyBuilder.statement2Key + ( stmts[i].s, stmts[i].p, stmts[i].o + ); + if ( !spo.contains(key) ) { + spo.insert(key, null); + } + } + + // deal with the POS index + IIndex pos = getPOSIndex(); + Arrays.sort(stmts,0,n,POSComparator.INSTANCE); + for ( int i = 0; i < n; i++ ) { + byte[] key = keyBuilder.statement2Key + ( stmts[i].p, stmts[i].o, stmts[i].s + ); + if ( !pos.contains(key) ) { + pos.insert(key, null); + } + } + + // deal with the OSP index + IIndex osp = getOSPIndex(); + Arrays.sort(stmts,0,n,OSPComparator.INSTANCE); + for ( int i = 0; i < n; i++ ) { + byte[] key = keyBuilder.statement2Key + ( stmts[i].o, stmts[i].s, stmts[i].p + ); + if ( !osp.contains(key) ) { + osp.insert(key, null); + } + } + + } + + /** * Writes out some usage details on System.err. */ Index: TripleStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/java/com/bigdata/rdf/TripleStore.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** TripleStore.java 13 Apr 2007 15:02:34 -0000 1.28 --- TripleStore.java 14 Apr 2007 13:33:52 -0000 1.29 *************** *** 66,74 **** import com.bigdata.btree.BTree; - import com.bigdata.btree.Errors; - import com.bigdata.btree.IBatchOp; import com.bigdata.btree.IEntryIterator; import com.bigdata.btree.IIndex; - import com.bigdata.btree.ISimpleBTree; import com.bigdata.btree.KeyBuilder; import com.bigdata.journal.ICommitRecord; --- 66,71 ---- *************** *** 92,96 **** import com.bigdata.rdf.serializers.StatementSerializer; import com.bigdata.rdf.serializers.TermIdSerializer; - import com.bigdata.scaleup.MasterJournal; import com.bigdata.scaleup.PartitionedIndexView; import com.bigdata.scaleup.SlaveJournal; --- 89,92 ---- *************** *** 554,557 **** --- 550,583 ---- /** + * Externalizes a statement using an appreviated syntax. + */ + public String toString( long s, long p, long o ) { + + IIndex ndx = getIdTermIndex(); + + URI s1 = (URI) ndx.lookup(keyBuilder.id2key(s)); + + URI p1 = (URI) ndx.lookup(keyBuilder.id2key(p)); + + URI o1 = (URI) ndx.lookup(keyBuilder.id2key(o)); + + return ("< "+abbrev(s1)+", "+abbrev(p1)+", "+abbrev(o1)+" >"); + + } + + // @todo substitute in well know namespaces (rdf, rdfs, etc). + private String abbrev( URI uri ) { + + String t = uri.getURI(); + + int index = t.lastIndexOf('#'); + + if(index==-1) return t; + + return t.substring(index); + + } + + /** * Return true if the statement exists in the store (non-batch API). * |