diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/query')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java | 120 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/GapByStore4ID2.java | 141 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/GapByTriple.java | 40 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/GapTupleIterator.java | 6 |
4 files changed, 216 insertions, 91 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java b/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java index 1c0eb48..02db18d 100644 --- a/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java +++ b/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java | |||
| @@ -1,103 +1,106 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | 1 | package uk.ac.ox.cs.pagoda.query; |
| 2 | 2 | ||
| 3 | import java.util.HashMap; | 3 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; |
| 4 | import java.util.LinkedList; | 4 | import uk.ac.ox.cs.JRDFox.store.DataStore; |
| 5 | import java.util.Map; | 5 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; |
| 6 | |||
| 7 | import uk.ac.ox.cs.pagoda.MyPrefixes; | 6 | import uk.ac.ox.cs.pagoda.MyPrefixes; |
| 8 | //import uk.ac.ox.cs.pagoda.multistage.AnswerTupleID; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | 7 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; |
| 10 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxTripleManager; | 8 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxTripleManager; |
| 9 | import uk.ac.ox.cs.pagoda.util.Namespace; | ||
| 11 | import uk.ac.ox.cs.pagoda.util.Timer; | 10 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 12 | import uk.ac.ox.cs.pagoda.util.Utility; | 11 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 13 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | 12 | |
| 14 | import uk.ac.ox.cs.JRDFox.store.DataStore; | 13 | import java.util.HashMap; |
| 15 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | 14 | import java.util.LinkedList; |
| 15 | import java.util.Map; | ||
| 16 | |||
| 17 | //import uk.ac.ox.cs.pagoda.multistage.AnswerTupleID; | ||
| 16 | 18 | ||
| 17 | //public class GapByStore4ID extends GapTupleIterator<AnswerTupleID> { | 19 | //public class GapByStore4ID extends GapTupleIterator<AnswerTupleID> { |
| 18 | public class GapByStore4ID extends GapTupleIterator<int[]> { | 20 | public class GapByStore4ID extends GapTupleIterator<int[]> { |
| 19 | 21 | ||
| 20 | private MyPrefixes prefixes = MyPrefixes.PAGOdAPrefixes; | 22 | protected MyPrefixes prefixes = MyPrefixes.PAGOdAPrefixes; |
| 21 | private TupleIterator iterator = null; | 23 | protected TupleIterator iterator = null; |
| 22 | 24 | ||
| 23 | // AnswerTupleID tuple; | 25 | // AnswerTupleID tuple; |
| 24 | int[] tuple; | 26 | protected int[] tuple; |
| 25 | private BasicQueryEngine m_engine; | 27 | protected BasicQueryEngine m_engine; |
| 26 | private DataStore m_store; | 28 | protected DataStore m_store; |
| 27 | private RDFoxTripleManager tripleManager; | 29 | protected RDFoxTripleManager tripleManager; |
| 30 | protected long multi; | ||
| 31 | Map<Integer, Integer> original2gap = new HashMap<Integer, Integer>(); | ||
| 32 | LinkedList<String> predicatesWithGap = new LinkedList<String>(); | ||
| 28 | 33 | ||
| 29 | public GapByStore4ID(BasicQueryEngine engine) { | 34 | public GapByStore4ID(BasicQueryEngine engine) { |
| 30 | m_engine = engine; | 35 | m_engine = engine; |
| 31 | m_store = engine.getDataStore(); | 36 | m_store = engine.getDataStore(); |
| 32 | tripleManager = new RDFoxTripleManager(m_store, false); | 37 | tripleManager = new RDFoxTripleManager(m_store, false); |
| 33 | } | 38 | } |
| 34 | 39 | ||
| 35 | long multi; | ||
| 36 | |||
| 37 | @Override | 40 | @Override |
| 38 | public void compile(String program) throws JRDFStoreException { | 41 | public void compile(String program) throws JRDFStoreException { |
| 39 | clear(); | 42 | clear(); |
| 40 | 43 | ||
| 41 | boolean incrementally = true; | 44 | boolean incrementally = true; |
| 42 | Timer t = new Timer(); | 45 | Timer t = new Timer(); |
| 43 | long oldTripleCount = m_store.getTriplesCount(); | 46 | long oldTripleCount = m_store.getTriplesCount(); |
| 44 | 47 | ||
| 45 | if (program != null) { | 48 | if (program != null) { |
| 46 | // m_store.addRules(new String[] {program}); | 49 | // m_store.addRules(new String[] {program}); |
| 47 | m_store.importRules(program); | 50 | m_store.importRules(program); |
| 48 | incrementally = false; | 51 | incrementally = false; |
| 49 | } | 52 | } |
| 50 | 53 | ||
| 51 | m_store.applyReasoning(incrementally); | 54 | m_store.applyReasoning(incrementally); |
| 52 | 55 | ||
| 53 | long tripleCount = m_store.getTriplesCount(); | 56 | long tripleCount = m_store.getTriplesCount(); |
| 54 | 57 | ||
| 55 | Utility.logDebug("current store after materialising upper related rules: " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)", | 58 | Utility.logDebug("current store after materialising upper related rules: " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)", |
| 56 | "current store finished the materialisation of upper related rules in " + t.duration() + " seconds."); | 59 | "current store finished the materialisation of upper related rules in " + t.duration() + " seconds."); |
| 57 | 60 | ||
| 58 | m_engine.setExpandEquality(false); | 61 | m_engine.setExpandEquality(false); |
| 59 | iterator = m_engine.internal_evaluateAgainstIDBs("select ?x ?y ?z where { ?x ?y ?z . }"); | 62 | iterator = m_engine.internal_evaluateAgainstIDBs("select ?x ?y ?z where { ?x ?y ?z . }"); |
| 60 | m_engine.setExpandEquality(true); | 63 | m_engine.setExpandEquality(true); |
| 61 | 64 | ||
| 62 | multi = iterator.open(); | 65 | multi = iterator.open(); |
| 63 | Utility.logDebug("gap query evaluted ..."); | 66 | Utility.logDebug("gap query evaluted ..."); |
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | @Override | 69 | @Override |
| 67 | public boolean hasNext() { | 70 | public boolean hasNext() { |
| 68 | if (iterator == null) return false; | 71 | if(iterator == null) return false; |
| 69 | try { | 72 | try { |
| 70 | // tuple = new AnswerTupleID(3); | 73 | // tuple = new AnswerTupleID(3); |
| 71 | tuple = new int[3]; | 74 | tuple = new int[3]; |
| 72 | Integer predicate; | 75 | Integer predicate; |
| 73 | for (; multi != 0; multi = iterator.getNext()) { | 76 | for (; multi != 0; multi = iterator.getNext()) { |
| 74 | for (int i = 0; i < 3; ++i) | 77 | for (int i = 0; i < 3; ++i) |
| 75 | // tuple.setTerm(i, (int) iterator.getResourceID(i)); | 78 | // tuple.setTerm(i, (int) iterator.getResourceID(i)); |
| 76 | tuple[i] = (int) iterator.getResourceID(i); | 79 | tuple[i] = iterator.getResourceID(i); |
| 77 | 80 | ||
| 78 | if (isRDF_TYPE()) { | 81 | if (isRDF_TYPE()) { |
| 79 | // predicate = getGapPredicateID(tuple.getTerm(2)); | 82 | // predicate = getGapPredicateID(tuple.getTerm(2)); |
| 80 | predicate = getGapPredicateID(tuple[2]); | 83 | predicate = getGapPredicateID(tuple[2]); |
| 81 | if (predicate == null) continue; | 84 | if(predicate == null) continue; |
| 82 | // tuple.setTerm(2, predicate); | 85 | // tuple.setTerm(2, predicate); |
| 83 | tuple[2] = predicate; | 86 | tuple[2] = predicate; |
| 84 | } | 87 | } |
| 85 | else { | 88 | else { |
| 86 | // predicate = getGapPredicateID(tuple.getTerm(1)); | 89 | // predicate = getGapPredicateID(tuple.getTerm(1)); |
| 87 | predicate = getGapPredicateID(tuple[1]); | 90 | predicate = getGapPredicateID(tuple[1]); |
| 88 | if (predicate == null) continue; | 91 | if(predicate == null) continue; |
| 89 | // tuple.setTerm(1, predicate); | 92 | // tuple.setTerm(1, predicate); |
| 90 | tuple[1] = predicate; | 93 | tuple[1] = predicate; |
| 91 | } | 94 | } |
| 92 | return true; | 95 | return true; |
| 93 | } | 96 | } |
| 94 | } catch (JRDFStoreException e) { | 97 | } catch (JRDFStoreException e) { |
| 95 | e.printStackTrace(); | 98 | e.printStackTrace(); |
| 96 | return false; | 99 | return false; |
| 97 | } | 100 | } |
| 98 | return false; | 101 | return false; |
| 99 | } | 102 | } |
| 100 | 103 | ||
| 101 | @Override | 104 | @Override |
| 102 | // public AnswerTupleID next() { | 105 | // public AnswerTupleID next() { |
| 103 | public int[] next() { | 106 | public int[] next() { |
| @@ -105,19 +108,16 @@ public class GapByStore4ID extends GapTupleIterator<int[]> { | |||
| 105 | multi = iterator.getNext(); | 108 | multi = iterator.getNext(); |
| 106 | } catch (JRDFStoreException e) { | 109 | } catch (JRDFStoreException e) { |
| 107 | e.printStackTrace(); | 110 | e.printStackTrace(); |
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | return tuple; | 113 | return tuple; |
| 111 | } | 114 | } |
| 112 | 115 | ||
| 113 | Map<Integer, Integer> original2gap = new HashMap<Integer, Integer>(); | ||
| 114 | LinkedList<String> predicatesWithGap = new LinkedList<String>(); | ||
| 115 | |||
| 116 | public LinkedList<String> getPredicatesWithGap() { | 116 | public LinkedList<String> getPredicatesWithGap() { |
| 117 | return predicatesWithGap; | 117 | return predicatesWithGap; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | private Integer getGapPredicateID(int originalID) { | 120 | protected Integer getGapPredicateID(int originalID) { |
| 121 | Integer gapID; | 121 | Integer gapID; |
| 122 | if ((gapID = original2gap.get(originalID)) != null) | 122 | if ((gapID = original2gap.get(originalID)) != null) |
| 123 | return gapID; | 123 | return gapID; |
| @@ -136,11 +136,14 @@ public class GapByStore4ID extends GapTupleIterator<int[]> { | |||
| 136 | return gapID; | 136 | return gapID; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | private boolean isAuxPredicate(String originalPredicate) { | 139 | protected boolean isAuxPredicate(String originalPredicate) { |
| 140 | return originalPredicate.contains("_AUX"); | 140 | if(originalPredicate.equals(Namespace.EQUALITY_QUOTED)) return false; |
| 141 | return originalPredicate.contains("_AUX") || | ||
| 142 | originalPredicate.startsWith("<" + Namespace.OWL_NS) || | ||
| 143 | originalPredicate.startsWith("<" + Namespace.PAGODA_ORIGINAL); | ||
| 141 | } | 144 | } |
| 142 | 145 | ||
| 143 | private boolean isRDF_TYPE() { | 146 | protected boolean isRDF_TYPE() { |
| 144 | // return tripleManager.isRdfTypeID(tuple.getTerm(1)); | 147 | // return tripleManager.isRdfTypeID(tuple.getTerm(1)); |
| 145 | return tripleManager.isRdfTypeID(tuple[1]); | 148 | return tripleManager.isRdfTypeID(tuple[1]); |
| 146 | } | 149 | } |
| @@ -150,8 +153,6 @@ public class GapByStore4ID extends GapTupleIterator<int[]> { | |||
| 150 | Utility.logError("Unsupported operation!"); | 153 | Utility.logError("Unsupported operation!"); |
| 151 | } | 154 | } |
| 152 | 155 | ||
| 153 | private boolean valid = false; | ||
| 154 | |||
| 155 | @Override | 156 | @Override |
| 156 | public void save(String file) { | 157 | public void save(String file) { |
| 157 | Utility.logError("Unsupported Operation..."); | 158 | Utility.logError("Unsupported Operation..."); |
| @@ -168,7 +169,6 @@ public class GapByStore4ID extends GapTupleIterator<int[]> { | |||
| 168 | ++tupleCounter; | 169 | ++tupleCounter; |
| 169 | tripleManager.addTripleByID(tuple); | 170 | tripleManager.addTripleByID(tuple); |
| 170 | } | 171 | } |
| 171 | valid = true; | ||
| 172 | 172 | ||
| 173 | long tripleCounter = m_store.getTriplesCount(); | 173 | long tripleCounter = m_store.getTriplesCount(); |
| 174 | Utility.logDebug("There are " + tupleCounter + " tuples in the gap between lower and upper bound materialisation.", | 174 | Utility.logDebug("There are " + tupleCounter + " tuples in the gap between lower and upper bound materialisation.", |
| @@ -183,8 +183,6 @@ public class GapByStore4ID extends GapTupleIterator<int[]> { | |||
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | public boolean isValid() {return valid; } | ||
| 187 | |||
| 188 | @Override | 186 | @Override |
| 189 | public void addTo(DataStore store) throws JRDFStoreException { | 187 | public void addTo(DataStore store) throws JRDFStoreException { |
| 190 | Utility.logError("Unsupported Operation..."); | 188 | Utility.logError("Unsupported Operation..."); |
diff --git a/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID2.java b/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID2.java new file mode 100644 index 0000000..19efc58 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/query/GapByStore4ID2.java | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | ||
| 2 | |||
| 3 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | ||
| 4 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | ||
| 5 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | ||
| 6 | import uk.ac.ox.cs.pagoda.util.UFS; | ||
| 7 | |||
| 8 | import java.util.*; | ||
| 9 | |||
| 10 | public class GapByStore4ID2 extends GapByStore4ID { | ||
| 11 | |||
| 12 | private BasicQueryEngine m_baseEngine; | ||
| 13 | private UFS<String> m_equality = null, m_baseEquality = null; | ||
| 14 | private LinkedList<String> toAddedIndividuals = null; | ||
| 15 | private TupleIterator iter_individual = null; | ||
| 16 | private int currentID = -1; | ||
| 17 | |||
| 18 | public GapByStore4ID2(BasicQueryEngine engine, BasicQueryEngine baseEngine) { | ||
| 19 | super(engine); | ||
| 20 | m_baseEngine = baseEngine; | ||
| 21 | } | ||
| 22 | |||
| 23 | @Override | ||
| 24 | public boolean hasNext() { | ||
| 25 | if(getNewGapTuple(iterator, -1)) return true; | ||
| 26 | if(iterator != null) { | ||
| 27 | iterator.dispose(); | ||
| 28 | iterator = null; | ||
| 29 | } | ||
| 30 | return getNextGapFactAboutEquality(); | ||
| 31 | } | ||
| 32 | |||
| 33 | private boolean getNewGapTuple(TupleIterator it, int firstElement) { | ||
| 34 | if(it == null) return false; | ||
| 35 | int firstIndex = 0; | ||
| 36 | tuple = new int[3]; | ||
| 37 | if(firstElement > 0) { | ||
| 38 | tuple[0] = firstElement; | ||
| 39 | firstIndex = 1; | ||
| 40 | } | ||
| 41 | Integer predicate; | ||
| 42 | try { | ||
| 43 | for(; multi != 0; multi = it.getNext()) { | ||
| 44 | for(int i = firstIndex; i < 3; ++i) | ||
| 45 | tuple[i] = it.getResourceID(i - firstIndex); | ||
| 46 | |||
| 47 | if(isRDF_TYPE()) { | ||
| 48 | predicate = getGapPredicateID(tuple[2]); | ||
| 49 | if(predicate == null) continue; | ||
| 50 | tuple[2] = predicate; | ||
| 51 | } else { | ||
| 52 | predicate = getGapPredicateID(tuple[1]); | ||
| 53 | if(predicate == null) continue; | ||
| 54 | tuple[1] = predicate; | ||
| 55 | } | ||
| 56 | return true; | ||
| 57 | } | ||
| 58 | } catch(JRDFStoreException e) { | ||
| 59 | e.printStackTrace(); | ||
| 60 | return false; | ||
| 61 | } | ||
| 62 | return false; | ||
| 63 | } | ||
| 64 | |||
| 65 | private boolean getNextGapFactAboutEquality() { | ||
| 66 | if(toAddedIndividuals == null) { | ||
| 67 | m_equality = m_engine.getEqualityGroups(false); | ||
| 68 | m_baseEquality = m_baseEngine.getEqualityGroups(false); | ||
| 69 | toAddedIndividuals = new LinkedList<String>(); | ||
| 70 | Map<String, Integer> rep2cnt = new HashMap<String, Integer>(); | ||
| 71 | Map<String, Integer> rep2cnt_base = new HashMap<String, Integer>(); | ||
| 72 | count(m_engine, m_equality, rep2cnt); | ||
| 73 | count(m_baseEngine, m_baseEquality, rep2cnt_base); | ||
| 74 | Set<String> visitedrep = new HashSet<String>(); | ||
| 75 | for(String individual : m_equality.keySet()) { | ||
| 76 | String rep = m_equality.find(individual); | ||
| 77 | if(visitedrep.contains(rep)) continue; | ||
| 78 | visitedrep.add(rep); | ||
| 79 | String rep_base = m_baseEquality.find(individual); | ||
| 80 | if(!rep2cnt.get(rep).equals(rep2cnt_base.get(rep_base))) { | ||
| 81 | toAddedIndividuals.add(rep); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | } | ||
| 86 | while(true) { | ||
| 87 | if(getNewGapTuple(iter_individual, currentID)) return true; | ||
| 88 | if(iter_individual != null) { | ||
| 89 | iter_individual.dispose(); | ||
| 90 | iter_individual = null; | ||
| 91 | } | ||
| 92 | if(toAddedIndividuals.isEmpty()) { | ||
| 93 | currentID = -1; | ||
| 94 | return false; | ||
| 95 | } | ||
| 96 | String individual = toAddedIndividuals.remove(); | ||
| 97 | currentID = tripleManager.getResourceID(individual); | ||
| 98 | try { | ||
| 99 | iter_individual = | ||
| 100 | m_engine.internal_evaluateNotExpanded(String.format("select distinct ?y ?z where { <%s> ?y ?z }", individual)); | ||
| 101 | multi = iter_individual.open(); | ||
| 102 | } catch(JRDFStoreException e) { | ||
| 103 | e.printStackTrace(); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | private void count(BasicQueryEngine engine, UFS<String> equality, Map<String, Integer> map) { | ||
| 109 | for(String ind : equality.keySet()) { | ||
| 110 | Integer exist = map.get(ind); | ||
| 111 | if(exist == null) | ||
| 112 | map.put(equality.find(ind), 1); | ||
| 113 | else | ||
| 114 | map.put(equality.find(ind), ++exist); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | @Override | ||
| 119 | public int[] next() { | ||
| 120 | try { | ||
| 121 | if(iterator != null) | ||
| 122 | multi = iterator.getNext(); | ||
| 123 | else if(iter_individual != null) | ||
| 124 | multi = iter_individual.getNext(); | ||
| 125 | else | ||
| 126 | multi = 0; | ||
| 127 | } catch(JRDFStoreException e) { | ||
| 128 | e.printStackTrace(); | ||
| 129 | } | ||
| 130 | return tuple; | ||
| 131 | } | ||
| 132 | |||
| 133 | public void clear() { | ||
| 134 | super.clear(); | ||
| 135 | if(iter_individual != null) { | ||
| 136 | iter_individual.dispose(); | ||
| 137 | iter_individual = null; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | } | ||
diff --git a/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java b/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java index a1c1b0e..eaa629b 100644 --- a/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java +++ b/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java | |||
| @@ -1,36 +1,29 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | 1 | package uk.ac.ox.cs.pagoda.query; |
| 2 | 2 | ||
| 3 | import java.io.BufferedWriter; | 3 | import org.semanticweb.HermiT.model.*; |
| 4 | import java.io.FileOutputStream; | 4 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; |
| 5 | import java.io.IOException; | 5 | import uk.ac.ox.cs.JRDFox.Prefixes; |
| 6 | import java.io.OutputStreamWriter; | 6 | import uk.ac.ox.cs.JRDFox.store.DataStore; |
| 7 | import java.util.Collection; | 7 | import uk.ac.ox.cs.JRDFox.store.Parameters; |
| 8 | 8 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | |
| 9 | import org.semanticweb.HermiT.model.Atom; | ||
| 10 | import org.semanticweb.HermiT.model.AtomicConcept; | ||
| 11 | import org.semanticweb.HermiT.model.AtomicRole; | ||
| 12 | import org.semanticweb.HermiT.model.DLClause; | ||
| 13 | import org.semanticweb.HermiT.model.Individual; | ||
| 14 | |||
| 15 | import uk.ac.ox.cs.pagoda.MyPrefixes; | 9 | import uk.ac.ox.cs.pagoda.MyPrefixes; |
| 16 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 10 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| 17 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | 11 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; |
| 18 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxTripleManager; | 12 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxTripleManager; |
| 19 | import uk.ac.ox.cs.pagoda.util.Namespace; | 13 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 20 | import uk.ac.ox.cs.pagoda.util.Utility; | 14 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 21 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | 15 | |
| 22 | import uk.ac.ox.cs.JRDFox.Prefixes; | 16 | import java.io.BufferedWriter; |
| 23 | import uk.ac.ox.cs.JRDFox.store.DataStore; | 17 | import java.io.FileOutputStream; |
| 24 | import uk.ac.ox.cs.JRDFox.store.Parameters; | 18 | import java.io.IOException; |
| 25 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | 19 | import java.io.OutputStreamWriter; |
| 20 | import java.util.Collection; | ||
| 26 | 21 | ||
| 27 | public class GapByTriple extends GapTupleIterator<String> { | 22 | public class GapByTriple extends GapTupleIterator<String> { |
| 28 | 23 | ||
| 29 | private static final String RDF_TYPE = Namespace.RDF_NS + "type"; | ||
| 30 | private static final String BRIEF_RDF_TYPE = "rdf:type"; | ||
| 31 | |||
| 32 | static final String allTripleQuery = "SELECT ?X ?Y ?Z WHERE { ?X ?Y ?Z }"; | 24 | static final String allTripleQuery = "SELECT ?X ?Y ?Z WHERE { ?X ?Y ?Z }"; |
| 33 | 25 | private static final String RDF_TYPE = Namespace.RDF_NS + "type"; | |
| 26 | private static final String BRIEF_RDF_TYPE = "rdf:type"; | ||
| 34 | DataStore lowerStore, upperStore; | 27 | DataStore lowerStore, upperStore; |
| 35 | long multi; | 28 | long multi; |
| 36 | TupleIterator iterator; | 29 | TupleIterator iterator; |
| @@ -164,11 +157,6 @@ public class GapByTriple extends GapTupleIterator<String> { | |||
| 164 | } | 157 | } |
| 165 | 158 | ||
| 166 | @Override | 159 | @Override |
| 167 | public boolean isValid() { | ||
| 168 | return true; | ||
| 169 | } | ||
| 170 | |||
| 171 | @Override | ||
| 172 | public void clear() { | 160 | public void clear() { |
| 173 | iterator.dispose(); | 161 | iterator.dispose(); |
| 174 | } | 162 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/query/GapTupleIterator.java b/src/uk/ac/ox/cs/pagoda/query/GapTupleIterator.java index 58303bb..2983b2e 100644 --- a/src/uk/ac/ox/cs/pagoda/query/GapTupleIterator.java +++ b/src/uk/ac/ox/cs/pagoda/query/GapTupleIterator.java | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | 1 | package uk.ac.ox.cs.pagoda.query; |
| 2 | 2 | ||
| 3 | import java.util.Iterator; | ||
| 4 | |||
| 5 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | 3 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; |
| 6 | import uk.ac.ox.cs.JRDFox.store.DataStore; | 4 | import uk.ac.ox.cs.JRDFox.store.DataStore; |
| 7 | 5 | ||
| 6 | import java.util.Iterator; | ||
| 7 | |||
| 8 | public abstract class GapTupleIterator<T> implements Iterator<T> { | 8 | public abstract class GapTupleIterator<T> implements Iterator<T> { |
| 9 | 9 | ||
| 10 | public static final String gapPredicateSuffix = "_AUXg"; | 10 | public static final String gapPredicateSuffix = "_AUXg"; |
| @@ -17,8 +17,6 @@ public abstract class GapTupleIterator<T> implements Iterator<T> { | |||
| 17 | 17 | ||
| 18 | public void compile(String programText) throws JRDFStoreException {} | 18 | public void compile(String programText) throws JRDFStoreException {} |
| 19 | 19 | ||
| 20 | public abstract boolean isValid(); | ||
| 21 | |||
| 22 | public abstract void save(String file); | 20 | public abstract void save(String file); |
| 23 | 21 | ||
| 24 | public abstract void addBackTo() throws JRDFStoreException; | 22 | public abstract void addBackTo() throws JRDFStoreException; |
