private ReadGraph g;
private Layer0 b;
+ private boolean mapLiterals = true;
+
public GraphComparator(Resource r1, Resource r2) {
this.r1 = r1;
this.r2 = r2;
this.maxIter = maxIter;
}
- public void clear() {
+ public boolean isMapLiterals() {
+ return mapLiterals;
+ }
+
+ public void setMapLiterals(boolean mapLiterals) {
+ this.mapLiterals = mapLiterals;
+ }
+
+ private void clear() {
changes1.clear();
changes1Set.clear();
changes2.clear();
processedResources.clear();
}
+ public void dispose() {
+ changes1 = null;
+ changes1Set = null;
+ changes2 = null;
+ changes2Set = null;
+ comparableResources = null;
+ comparableStatements = null;
+ comparator = null;
+ modifications = null;
+ modificationsSet = null;
+ processedResources = null;
+ nonMatchedLeft = null;
+ nonMatchedRight = null;
+ nonTested = null;
+ nonTraversed = null;
+ ss1 = null;
+ ss2 = null;
+ strong = null;
+ tested = null;
+ traversed = null;
+ }
+
public void test(ReadGraph g) throws DatabaseException {
test(g,null);
}
subjectRight.add(s.getSubject(),s);
objectRight.add(s.getObject(),s);
}
+ Set<Pair<Resource, Resource>> processed = new HashSet<Pair<Resource,Resource>>();
for (Resource ol : objectLeft.getKeys()) {
if (maxIter > 0 && iter > maxIter)
break;
}
if (sLeft.size() == 1 && sRight.size() == 1) {
- List<Statement> ss1 = new ArrayList<Statement>(subjectLeft.getValues(sLeft.iterator().next()));
- List<Statement> ss2 = new ArrayList<Statement>(subjectRight.getValues(sRight.iterator().next()));
+ Resource sl = sLeft.iterator().next();
+ Resource sr = sRight.iterator().next();
+ Pair<Resource, Resource> p = new Pair<Resource, Resource>(sl, sr);
+ if (processed.contains(p))
+ continue;
+ processed.add(p);
+ List<Statement> ss1 = new ArrayList<Statement>(subjectLeft.getValuesSnapshot(sl));
+ List<Statement> ss2 = new ArrayList<Statement>(subjectRight.getValuesSnapshot(sr));
+ for (int i = ss1.size() -1; i >= 0; i--) {
+ if (!unreliableLeft.contains(ss1.get(i)))
+ ss1.remove(i);
+ }
+ for (int i = ss2.size() -1; i >= 0; i--) {
+ if (!unreliableRight.contains(ss2.get(i)))
+ ss2.remove(i);
+ }
+
+ int ccount = comparableStatements.size();
+ int lcount = changes1.size();
+ int rcount = changes2.size();
- int count = comparableStatements.size();
compareStatements(ss1, ss2, objectsLeft, objectsRight,unreliableLeft,unreliableRight);
- if (comparableStatements.size() > count) {
+ if (comparableStatements.size() > ccount) {
didSomething = true;
for (Entry<Statement, Statement> entry : comparableStatements.getEntries()) {
unreliableLeft.remove(entry.getKey());
iter++;
}
}
+ if (changes1.size() > lcount) {
+ didSomething = true;
+ for (Statement stm : changes1) {
+ unreliableLeft.remove(stm);
+ iter++;
+ }
+ }
+ if (changes2.size() > rcount) {
+ didSomething = true;
+ for (Statement stm : changes2) {
+ unreliableRight.remove(stm);
+ iter++;
+ }
+ }
}
}
return didSomething;
if (!eq) {
addModification(r1,s1,r2,s2);
}
- if (!a1 && !a2)
+ if (mapLiterals && !a1 && !a2)
addComparable(s1, s2);
} else {
// Non literal properties.