diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 22:45:35 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 22:45:35 +0100 |
| commit | c0f5bdcdb29608532656c71c219680eccd4aad09 (patch) | |
| tree | 5f599adfe2e3f15a1d2b3f1cb8d0bf9ace59badd /test/uk/ac/ox/cs/jrdfox/Tester.java | |
| parent | c8a9fc67a3f6ed201d7c917e36128268587eabe5 (diff) | |
| download | ACQuA-c0f5bdcdb29608532656c71c219680eccd4aad09.tar.gz ACQuA-c0f5bdcdb29608532656c71c219680eccd4aad09.zip | |
fixed some bugs in windows server
Diffstat (limited to 'test/uk/ac/ox/cs/jrdfox/Tester.java')
| -rw-r--r-- | test/uk/ac/ox/cs/jrdfox/Tester.java | 121 |
1 files changed, 107 insertions, 14 deletions
diff --git a/test/uk/ac/ox/cs/jrdfox/Tester.java b/test/uk/ac/ox/cs/jrdfox/Tester.java index 00476d6..94f5401 100644 --- a/test/uk/ac/ox/cs/jrdfox/Tester.java +++ b/test/uk/ac/ox/cs/jrdfox/Tester.java | |||
| @@ -2,44 +2,137 @@ package uk.ac.ox.cs.jrdfox; | |||
| 2 | 2 | ||
| 3 | import java.io.File; | 3 | import java.io.File; |
| 4 | 4 | ||
| 5 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 6 | |||
| 5 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | 7 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; |
| 6 | import uk.ac.ox.cs.JRDFox.Prefixes; | 8 | import uk.ac.ox.cs.JRDFox.Prefixes; |
| 7 | import uk.ac.ox.cs.JRDFox.store.DataStore; | 9 | import uk.ac.ox.cs.JRDFox.store.DataStore; |
| 10 | import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType; | ||
| 8 | import uk.ac.ox.cs.JRDFox.store.Parameters; | 11 | import uk.ac.ox.cs.JRDFox.store.Parameters; |
| 12 | import uk.ac.ox.cs.JRDFox.store.TripleStatus; | ||
| 9 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | 13 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; |
| 14 | import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType; | ||
| 15 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | ||
| 16 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxQueryEngine; | ||
| 17 | import uk.ac.ox.cs.pagoda.util.Namespace; | ||
| 10 | import uk.ac.ox.cs.pagoda.util.Timer; | 18 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 11 | 19 | ||
| 12 | public class Tester { | 20 | public class Tester { |
| 13 | 21 | ||
| 14 | public static void main(String[] args) { | 22 | public static void main(String[] args) throws JRDFStoreException { |
| 23 | Tester tester = new Tester(); | ||
| 24 | tester.testCrash(); | ||
| 25 | } | ||
| 26 | |||
| 27 | private void evaluate_againstIDs(String queryText) throws JRDFStoreException { | ||
| 28 | int number = 0; | ||
| 29 | Timer t = new Timer(); | ||
| 30 | TupleIterator iter = null; | ||
| 15 | try { | 31 | try { |
| 16 | (new Tester()).test();; | 32 | iter = store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); |
| 17 | } catch (JRDFStoreException e) { | 33 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) |
| 18 | // TODO Auto-generated catch block | 34 | ++number; |
| 19 | e.printStackTrace(); | 35 | } finally { |
| 36 | if (iter != null) iter.dispose(); | ||
| 20 | } | 37 | } |
| 38 | System.out.println(number); | ||
| 39 | System.out.println(t.duration()); | ||
| 40 | |||
| 21 | } | 41 | } |
| 22 | 42 | ||
| 23 | DataStore store; | 43 | DataStore store; |
| 24 | Prefixes prefixes = new Prefixes(); | 44 | Prefixes prefixes = new Prefixes(); |
| 25 | Parameters parameters; | 45 | Parameters parameters; |
| 26 | 46 | ||
| 27 | public Tester() { | 47 | public Tester() { |
| 28 | try { | 48 | try { |
| 29 | store = new DataStore(new File("lazy-upper-bound")); | 49 | store = new DataStore(StoreType.NarrowParallelHead); |
| 50 | store.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads); | ||
| 51 | store.initialize(); | ||
| 52 | System.out.println("data store created."); | ||
| 30 | } catch (JRDFStoreException e) { | 53 | } catch (JRDFStoreException e) { |
| 31 | e.printStackTrace(); | 54 | e.printStackTrace(); |
| 32 | } | 55 | } |
| 33 | parameters = new Parameters(); | 56 | parameters = new Parameters(); |
| 34 | parameters.m_allAnswersInRoot = true; | 57 | parameters.m_allAnswersInRoot = true; |
| 35 | parameters.m_useBushy = true; | 58 | parameters.m_useBushy = true; |
| 36 | 59 | } | |
| 60 | |||
| 61 | public Tester(String path) { | ||
| 62 | try { | ||
| 63 | store = new DataStore(new File(path)); | ||
| 64 | } catch (JRDFStoreException e) { | ||
| 65 | e.printStackTrace(); | ||
| 66 | } | ||
| 67 | parameters = new Parameters(); | ||
| 68 | // parameters.m_allAnswersInRoot = true; | ||
| 69 | // parameters.m_useBushy = true; | ||
| 70 | } | ||
| 71 | |||
| 72 | public void applyReasoning(boolean incremental) { | ||
| 73 | Timer t = new Timer(); | ||
| 74 | try { | ||
| 75 | store.applyReasoning(incremental); | ||
| 76 | } catch (JRDFStoreException e) { | ||
| 77 | e.printStackTrace(); | ||
| 78 | } | ||
| 79 | System.out.println("reasoning done: " + t.duration()); | ||
| 37 | } | 80 | } |
| 38 | 81 | ||
| 39 | public void dispose() { | 82 | public void dispose() { |
| 40 | store.dispose(); | 83 | store.dispose(); |
| 41 | } | 84 | } |
| 42 | 85 | ||
| 86 | public void testCrash() throws JRDFStoreException { | ||
| 87 | // DataStore lowerStore = new DataStore(StoreType.NarrowParallelHead); | ||
| 88 | // lowerStore.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads); | ||
| 89 | // lowerStore.initialize(); | ||
| 90 | // System.out.println("lower data store created."); | ||
| 91 | OWLOntology ontology = OWLHelper.loadOntology("data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"); | ||
| 92 | System.out.println("ontology loaded ... " + ontology.getAxiomCount()); | ||
| 93 | |||
| 94 | store.importTurtleFile(new File("testcase/fly.ttl")); | ||
| 95 | System.out.println("data loaded. " + store.getTriplesCount()); | ||
| 96 | |||
| 97 | store.importRules(new File[] {new File("testcase/lower.dlog")}); | ||
| 98 | System.out.println("rules loaded. " + store.getTriplesCount()); | ||
| 99 | |||
| 100 | store.applyReasoning(); | ||
| 101 | System.out.println("materialised. " + store.getTriplesCount()); | ||
| 102 | |||
| 103 | store.clearRulesAndMakeFactsExplicit(); | ||
| 104 | |||
| 105 | store.importRules(new File[] {new File("testcase/multi.dlog")}); | ||
| 106 | System.out.println("rules loaded. " + store.getTriplesCount()); | ||
| 107 | |||
| 108 | store.applyReasoning(); | ||
| 109 | System.out.println("materialised. " + store.getTriplesCount()); | ||
| 110 | |||
| 111 | store.makeFactsExplicit(); | ||
| 112 | |||
| 113 | store.importTurtleFiles(new File[] {new File("testcase/first.ttl")}, UpdateType.ScheduleForAddition); | ||
| 114 | System.out.println("first data loaded. " + store.getTriplesCount()); | ||
| 115 | |||
| 116 | store.applyReasoning(true); | ||
| 117 | System.out.println("incremental reasoning done. " + store.getTriplesCount()); | ||
| 118 | |||
| 119 | store.clearRulesAndMakeFactsExplicit(); | ||
| 120 | |||
| 121 | store.importTurtleFiles(new File[] {new File("testcase/second.ttl")}, UpdateType.ScheduleForAddition); | ||
| 122 | store.importRules(new File[] {new File("testcase/tracking.dlog")}, UpdateType.ScheduleForAddition); | ||
| 123 | store.applyReasoning(true); | ||
| 124 | System.out.println("incremental reasoning done. " + store.getTriplesCount()); | ||
| 125 | |||
| 126 | evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }"); | ||
| 127 | System.out.println("done."); | ||
| 128 | // tester.applyReasoning(true); | ||
| 129 | // tester.evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }"); | ||
| 130 | // System.out.println("done."); | ||
| 131 | |||
| 132 | store.dispose(); | ||
| 133 | // lowerStore.dispose(); | ||
| 134 | } | ||
| 135 | |||
| 43 | public void test() throws JRDFStoreException { | 136 | public void test() throws JRDFStoreException { |
| 44 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " | 137 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " |
| 45 | + "SELECT distinct ?x WHERE { " | 138 | + "SELECT distinct ?x WHERE { " |
| @@ -82,18 +175,18 @@ public class Tester { | |||
| 82 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " | 175 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " |
| 83 | + "?z benchmark:like ?y . " | 176 | + "?z benchmark:like ?y . " |
| 84 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); | 177 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); |
| 85 | } | 178 | } |
| 86 | 179 | ||
| 87 | public void evaluate(String query) throws JRDFStoreException { | 180 | public void evaluate(String query) throws JRDFStoreException { |
| 88 | TupleIterator iter = store.compileQuery(query, prefixes, parameters); | ||
| 89 | |||
| 90 | int number = 0; | 181 | int number = 0; |
| 91 | Timer t = new Timer(); | 182 | Timer t = new Timer(); |
| 183 | TupleIterator iter = null; | ||
| 92 | try { | 184 | try { |
| 185 | iter = store.compileQuery(query, prefixes, parameters); | ||
| 93 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) | 186 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) |
| 94 | ++number; | 187 | ++number; |
| 95 | } finally { | 188 | } finally { |
| 96 | iter.dispose(); | 189 | if (iter != null) iter.dispose(); |
| 97 | } | 190 | } |
| 98 | System.out.println(number); | 191 | System.out.println(number); |
| 99 | System.out.println(t.duration()); | 192 | System.out.println(t.duration()); |
