diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-29 18:35:51 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-29 18:35:51 +0100 |
| commit | 4b7253559c290b6fdd1c4122830f153fda85dd62 (patch) | |
| tree | 37c1487e4682be719dec532ca3d7e1af353fb9a1 /src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java | |
| parent | 6a559a415b3bdb3048021839e5bcf5bbf5aa4bbd (diff) | |
| download | ACQuA-4b7253559c290b6fdd1c4122830f153fda85dd62.tar.gz ACQuA-4b7253559c290b6fdd1c4122830f153fda85dd62.zip | |
Disposable.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java index bea5bbf..16e2627 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java | |||
| @@ -9,6 +9,7 @@ import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | |||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxQueryEngine; | 9 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxQueryEngine; |
| 10 | import uk.ac.ox.cs.pagoda.rules.LowerDatalogProgram; | 10 | import uk.ac.ox.cs.pagoda.rules.LowerDatalogProgram; |
| 11 | import uk.ac.ox.cs.pagoda.util.Timer; | 11 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 12 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 12 | 13 | ||
| 13 | class RLQueryReasoner extends QueryReasoner { | 14 | class RLQueryReasoner extends QueryReasoner { |
| 14 | 15 | ||
| @@ -16,13 +17,14 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 16 | 17 | ||
| 17 | LowerDatalogProgram program; | 18 | LowerDatalogProgram program; |
| 18 | Timer t = new Timer(); | 19 | Timer t = new Timer(); |
| 19 | 20 | ||
| 20 | public RLQueryReasoner() { | 21 | public RLQueryReasoner() { |
| 21 | rlLowerStore = new BasicQueryEngine("rl"); | 22 | rlLowerStore = new BasicQueryEngine("rl"); |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | @Override | 25 | @Override |
| 25 | public void evaluate(QueryRecord queryRecord) { | 26 | public void evaluate(QueryRecord queryRecord) { |
| 27 | if(isDisposed()) throw new DisposedException(); | ||
| 26 | AnswerTuples rlAnswer = null; | 28 | AnswerTuples rlAnswer = null; |
| 27 | t.reset(); | 29 | t.reset(); |
| 28 | try { | 30 | try { |
| @@ -38,12 +40,13 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 38 | 40 | ||
| 39 | @Override | 41 | @Override |
| 40 | public void dispose() { | 42 | public void dispose() { |
| 41 | if (rlLowerStore != null) rlLowerStore.dispose(); | ||
| 42 | super.dispose(); | 43 | super.dispose(); |
| 44 | if(rlLowerStore != null) rlLowerStore.dispose(); | ||
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | @Override | 47 | @Override |
| 46 | public void loadOntology(OWLOntology ontology) { | 48 | public void loadOntology(OWLOntology ontology) { |
| 49 | if(isDisposed()) throw new DisposedException(); | ||
| 47 | program = new LowerDatalogProgram(); | 50 | program = new LowerDatalogProgram(); |
| 48 | program.load(ontology, new UnaryBottom()); | 51 | program.load(ontology, new UnaryBottom()); |
| 49 | program.transform(); | 52 | program.transform(); |
| @@ -53,6 +56,7 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 53 | 56 | ||
| 54 | @Override | 57 | @Override |
| 55 | public boolean preprocess() { | 58 | public boolean preprocess() { |
| 59 | if(isDisposed()) throw new DisposedException(); | ||
| 56 | rlLowerStore.importRDFData("data", importedData.toString()); | 60 | rlLowerStore.importRDFData("data", importedData.toString()); |
| 57 | rlLowerStore.materialise("lower program", program.toString()); | 61 | rlLowerStore.materialise("lower program", program.toString()); |
| 58 | 62 | ||
| @@ -61,6 +65,7 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 61 | 65 | ||
| 62 | @Override | 66 | @Override |
| 63 | public boolean isConsistent() { | 67 | public boolean isConsistent() { |
| 68 | if(isDisposed()) throw new DisposedException(); | ||
| 64 | AnswerTuples ans = null; | 69 | AnswerTuples ans = null; |
| 65 | try { | 70 | try { |
| 66 | ans = rlLowerStore.evaluate(QueryRecord.botQueryText, new String[] {"X"}); | 71 | ans = rlLowerStore.evaluate(QueryRecord.botQueryText, new String[] {"X"}); |
| @@ -74,6 +79,7 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 74 | 79 | ||
| 75 | @Override | 80 | @Override |
| 76 | public void evaluateUpper(QueryRecord record) { | 81 | public void evaluateUpper(QueryRecord record) { |
| 82 | if(isDisposed()) throw new DisposedException(); | ||
| 77 | evaluate(record); | 83 | evaluate(record); |
| 78 | } | 84 | } |
| 79 | 85 | ||
