VIVO-907 make the the check for isomorphism more efficient.

Read the file graph into memory and check against that.
This commit is contained in:
Jim Blake 2015-01-05 12:58:03 -05:00
parent ac39b0799e
commit 7639bf43e3

View file

@ -47,7 +47,7 @@ public class TDBTripleStoreQuirks extends DefaultTripleStoreQuirks {
Model mangled = ModelFactory.createDefaultModel();
mangled.read(mangleStream, null, "N-TRIPLE");
return !mangled.isIsomorphicWith(previous);
return !isIsomorphic(previous, mangled);
} catch (Exception e) {
log.warn("Failed to test for changes in filegraph. "
+ "Change assumed.", e);
@ -55,4 +55,17 @@ public class TDBTripleStoreQuirks extends DefaultTripleStoreQuirks {
}
}
/**
* If we check isomorphism with a dbModel directly, we issue many ASK
* queries against the underlying RDFService.
*
* It's faster to read the entire model from the RDFService and then issue
* all of those ASKs against a memory-resident model.
*/
private boolean isIsomorphic(Model previous, Model mangled) {
Model previousInMemory = ModelFactory.createDefaultModel()
.add(previous);
return mangled.isIsomorphicWith(previousInMemory);
}
}