diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/triplesource/impl/tdb/TDBTripleStoreQuirks.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/triplesource/impl/tdb/TDBTripleStoreQuirks.java index 936c93f03..2e2e88542 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/triplesource/impl/tdb/TDBTripleStoreQuirks.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/triplesource/impl/tdb/TDBTripleStoreQuirks.java @@ -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); + } + }