aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java
index fe43e09..107d3ca 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java
@@ -104,16 +104,22 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
104 } 104 }
105 105
106 public void outputInstance4BinaryPredicate(String iri, String filename) { 106 public void outputInstance4BinaryPredicate(String iri, String filename) {
107 if(isDisposed()) throw new DisposedException();
108
107 Utility.redirectCurrentOut(filename); 109 Utility.redirectCurrentOut(filename);
108 outputInstance4BinaryPredicate(iri); 110 outputInstance4BinaryPredicate(iri);
109 Utility.closeCurrentOut(); 111 Utility.closeCurrentOut();
110 } 112 }
111 113
112 public void outputInstance4BinaryPredicate(String iri) { 114 public void outputInstance4BinaryPredicate(String iri) {
115 if(isDisposed()) throw new DisposedException();
116
113 outputAnswers("select ?x ?y where { ?x <" + iri + "> ?y . }"); 117 outputAnswers("select ?x ?y where { ?x <" + iri + "> ?y . }");
114 } 118 }
115 119
116 public void outputInstanceNumbers(String filename) { 120 public void outputInstanceNumbers(String filename) {
121 if(isDisposed()) throw new DisposedException();
122
117 TupleIterator predicateTuples = null; 123 TupleIterator predicateTuples = null;
118 TupleIterator instanceTuples; 124 TupleIterator instanceTuples;
119 Set<String> number = new HashSet<String>(); 125 Set<String> number = new HashSet<String>();
@@ -177,6 +183,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
177 } 183 }
178 184
179 public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException { 185 public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException {
186 if(isDisposed()) throw new DisposedException();
187
180 TupleIterator iter = 188 TupleIterator iter =
181 store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); 189 store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB);
182// iter.open(); 190// iter.open();
@@ -184,16 +192,22 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
184 } 192 }
185 193
186 public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException { 194 public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException {
195 if(isDisposed()) throw new DisposedException();
196
187 TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); 197 TupleIterator iter = store.compileQuery(queryText, prefixes, parameters);
188// iter.open(); 198// iter.open();
189 return iter; 199 return iter;
190 } 200 }
191 201
192 public void setExpandEquality(boolean flag) { 202 public void setExpandEquality(boolean flag) {
203 if(isDisposed()) throw new DisposedException();
204
193 parameters.m_expandEquality = flag; 205 parameters.m_expandEquality = flag;
194 } 206 }
195 207
196 public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException { 208 public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException {
209 if(isDisposed()) throw new DisposedException();
210
197 parameters.m_expandEquality = false; 211 parameters.m_expandEquality = false;
198 TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); 212 TupleIterator iter = store.compileQuery(queryText, prefixes, parameters);
199// iter.open(); 213// iter.open();
@@ -202,10 +216,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
202 } 216 }
203 217
204 public TupleIterator internal_evaluate(String queryText, boolean incrementally) throws JRDFStoreException { 218 public TupleIterator internal_evaluate(String queryText, boolean incrementally) throws JRDFStoreException {
219 if(isDisposed()) throw new DisposedException();
220
205 return incrementally ? internal_evaluateAgainstIDBs(queryText) : internal_evaluate(queryText); 221 return incrementally ? internal_evaluateAgainstIDBs(queryText) : internal_evaluate(queryText);
206 } 222 }
207 223
208 public String getUnusedRules(Collection<DLClause> clauses, boolean toUpdate) { 224 public String getUnusedRules(Collection<DLClause> clauses, boolean toUpdate) {
225 if(isDisposed()) throw new DisposedException();
226
209 DLClause clause; 227 DLClause clause;
210 for(Iterator<DLClause> iter = clauses.iterator(); iter.hasNext(); ) { 228 for(Iterator<DLClause> iter = clauses.iterator(); iter.hasNext(); ) {
211 if(materialisedRules.contains(clause = iter.next())) 229 if(materialisedRules.contains(clause = iter.next()))
@@ -219,10 +237,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
219 } 237 }
220 238
221 public void outputMaterialisedRules() { 239 public void outputMaterialisedRules() {
240 if(isDisposed()) throw new DisposedException();
241
222 System.out.println(DLClauseHelper.toString(materialisedRules)); 242 System.out.println(DLClauseHelper.toString(materialisedRules));
223 } 243 }
224 244
225 public void outputAnswers(String query) { 245 public void outputAnswers(String query) {
246 if(isDisposed()) throw new DisposedException();
247
226 TupleIterator iter = null; 248 TupleIterator iter = null;
227 try { 249 try {
228 iter = internal_evaluate(query); 250 iter = internal_evaluate(query);
@@ -241,6 +263,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
241 } 263 }
242 264
243 public void outputInstance4UnaryPredicate(String iri) { 265 public void outputInstance4UnaryPredicate(String iri) {
266 if(isDisposed()) throw new DisposedException();
267
244 outputAnswers("select ?x where { ?x " 268 outputAnswers("select ?x where { ?x "
245 + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <" 269 + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <"
246 + iri 270 + iri
@@ -248,14 +272,20 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
248 } 272 }
249 273
250 public void outputSubjects(String p, String o) { 274 public void outputSubjects(String p, String o) {
275 if(isDisposed()) throw new DisposedException();
276
251 outputAnswers("select x where { ?x <" + p + "> <" + o + "> . }"); 277 outputAnswers("select x where { ?x <" + p + "> <" + o + "> . }");
252 } 278 }
253 279
254 public void outputObjects(String s, String p) { 280 public void outputObjects(String s, String p) {
281 if(isDisposed()) throw new DisposedException();
282
255 outputAnswers("select ?x where { <" + s + "> <" + p + "> ?x . }"); 283 outputAnswers("select ?x where { <" + s + "> <" + p + "> ?x . }");
256 } 284 }
257 285
258 public void outputIDBFacts() { 286 public void outputIDBFacts() {
287 if(isDisposed()) throw new DisposedException();
288
259 TupleIterator iter = null; 289 TupleIterator iter = null;
260 try { 290 try {
261 iter = internal_evaluateAgainstIDBs("select distict ?x ?y ?z where { ?x ?y ?z }"); 291 iter = internal_evaluateAgainstIDBs("select distict ?x ?y ?z where { ?x ?y ?z }");
@@ -274,10 +304,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
274 } 304 }
275 305
276 public void outputType4Individual(String iri) { 306 public void outputType4Individual(String iri) {
307 if(isDisposed()) throw new DisposedException();
308
277 outputAnswers("select ?z where { <" + iri + "> " + Namespace.RDF_TYPE_QUOTED + " ?z }"); 309 outputAnswers("select ?z where { <" + iri + "> " + Namespace.RDF_TYPE_QUOTED + " ?z }");
278 } 310 }
279 311
280 public int getSameAsNumber() { 312 public int getSameAsNumber() {
313 if(isDisposed()) throw new DisposedException();
314
281 TupleIterator iter = null; 315 TupleIterator iter = null;
282 int counter = 0; 316 int counter = 0;
283 try { 317 try {
@@ -294,6 +328,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
294 } 328 }
295 329
296 public UFS<String> getEqualityGroups(boolean reuse) { 330 public UFS<String> getEqualityGroups(boolean reuse) {
331 if(isDisposed()) throw new DisposedException();
332
297 if(reuse && equalityGroups != null) return equalityGroups; 333 if(reuse && equalityGroups != null) return equalityGroups;
298 334
299 equalityGroups = new UFS<String>(); 335 equalityGroups = new UFS<String>();
@@ -317,6 +353,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine {
317 } 353 }
318 354
319 public void clearRulesAndIDBFacts(Collection<int[]> collection) { 355 public void clearRulesAndIDBFacts(Collection<int[]> collection) {
356 if(isDisposed()) throw new DisposedException();
357
320// performDeletion(collection); 358// performDeletion(collection);
321 collection.clear(); 359 collection.clear();
322 try { 360 try {