blob: 94f5401cbdd0a2465fcca5f9c5e4e78316c38c86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
package uk.ac.ox.cs.jrdfox;
import java.io.File;
import org.semanticweb.owlapi.model.OWLOntology;
import uk.ac.ox.cs.JRDFox.JRDFStoreException;
import uk.ac.ox.cs.JRDFox.Prefixes;
import uk.ac.ox.cs.JRDFox.store.DataStore;
import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType;
import uk.ac.ox.cs.JRDFox.store.Parameters;
import uk.ac.ox.cs.JRDFox.store.TripleStatus;
import uk.ac.ox.cs.JRDFox.store.TupleIterator;
import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType;
import uk.ac.ox.cs.pagoda.owl.OWLHelper;
import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxQueryEngine;
import uk.ac.ox.cs.pagoda.util.Namespace;
import uk.ac.ox.cs.pagoda.util.Timer;
public class Tester {
public static void main(String[] args) throws JRDFStoreException {
Tester tester = new Tester();
tester.testCrash();
}
private void evaluate_againstIDs(String queryText) throws JRDFStoreException {
int number = 0;
Timer t = new Timer();
TupleIterator iter = null;
try {
iter = store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB);
for (long multi = iter.open(); multi != 0; multi = iter.getNext())
++number;
} finally {
if (iter != null) iter.dispose();
}
System.out.println(number);
System.out.println(t.duration());
}
DataStore store;
Prefixes prefixes = new Prefixes();
Parameters parameters;
public Tester() {
try {
store = new DataStore(StoreType.NarrowParallelHead);
store.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads);
store.initialize();
System.out.println("data store created.");
} catch (JRDFStoreException e) {
e.printStackTrace();
}
parameters = new Parameters();
parameters.m_allAnswersInRoot = true;
parameters.m_useBushy = true;
}
public Tester(String path) {
try {
store = new DataStore(new File(path));
} catch (JRDFStoreException e) {
e.printStackTrace();
}
parameters = new Parameters();
// parameters.m_allAnswersInRoot = true;
// parameters.m_useBushy = true;
}
public void applyReasoning(boolean incremental) {
Timer t = new Timer();
try {
store.applyReasoning(incremental);
} catch (JRDFStoreException e) {
e.printStackTrace();
}
System.out.println("reasoning done: " + t.duration());
}
public void dispose() {
store.dispose();
}
public void testCrash() throws JRDFStoreException {
// DataStore lowerStore = new DataStore(StoreType.NarrowParallelHead);
// lowerStore.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads);
// lowerStore.initialize();
// System.out.println("lower data store created.");
OWLOntology ontology = OWLHelper.loadOntology("data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl");
System.out.println("ontology loaded ... " + ontology.getAxiomCount());
store.importTurtleFile(new File("testcase/fly.ttl"));
System.out.println("data loaded. " + store.getTriplesCount());
store.importRules(new File[] {new File("testcase/lower.dlog")});
System.out.println("rules loaded. " + store.getTriplesCount());
store.applyReasoning();
System.out.println("materialised. " + store.getTriplesCount());
store.clearRulesAndMakeFactsExplicit();
store.importRules(new File[] {new File("testcase/multi.dlog")});
System.out.println("rules loaded. " + store.getTriplesCount());
store.applyReasoning();
System.out.println("materialised. " + store.getTriplesCount());
store.makeFactsExplicit();
store.importTurtleFiles(new File[] {new File("testcase/first.ttl")}, UpdateType.ScheduleForAddition);
System.out.println("first data loaded. " + store.getTriplesCount());
store.applyReasoning(true);
System.out.println("incremental reasoning done. " + store.getTriplesCount());
store.clearRulesAndMakeFactsExplicit();
store.importTurtleFiles(new File[] {new File("testcase/second.ttl")}, UpdateType.ScheduleForAddition);
store.importRules(new File[] {new File("testcase/tracking.dlog")}, UpdateType.ScheduleForAddition);
store.applyReasoning(true);
System.out.println("incremental reasoning done. " + store.getTriplesCount());
evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }");
System.out.println("done.");
// tester.applyReasoning(true);
// tester.evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }");
// System.out.println("done.");
store.dispose();
// lowerStore.dispose();
}
public void test() throws JRDFStoreException {
evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> "
+ "SELECT distinct ?x WHERE { "
+ "?x a benchmark:Person . "
+ "?x benchmark:like ?y . "
+ "?z a benchmark:Chair . "
+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
+ "?z benchmark:like ?y . "
+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }");
evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> "
+ "SELECT distinct ?x WHERE { "
+ "?x a benchmark:Person . "
+ "?x benchmark:like ?y . "
+ "?z a benchmark:Chair . "
+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
+ "?z benchmark:like ?y . "
+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> ."
+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }");
evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> "
+ "SELECT distinct ?x WHERE { "
+ "?x a benchmark:Person . "
+ "?x benchmark:like ?y . "
+ "?z a benchmark:Chair . "
+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
+ "?z benchmark:like ?y . "
+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }");
evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> "
+ "SELECT distinct ?x WHERE { "
+ "?x a benchmark:Person . "
+ "?x benchmark:like ?y . "
+ "?z a benchmark:Chair . "
+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
+ "?z benchmark:like ?y . "
+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }");
}
public void evaluate(String query) throws JRDFStoreException {
int number = 0;
Timer t = new Timer();
TupleIterator iter = null;
try {
iter = store.compileQuery(query, prefixes, parameters);
for (long multi = iter.open(); multi != 0; multi = iter.getNext())
++number;
} finally {
if (iter != null) iter.dispose();
}
System.out.println(number);
System.out.println(t.duration());
}
}
|