Performance on the performanceInference() method
804791 Oct 12, 2010 1:46 PMI am currently new developer using the Semantic Technologies with the Jena Adaptor for Oracle 11g release 2 and I am having performance issues with the performanceInference() method. I am currently working in a collaborative work environment where the entailment index needs to be keep VALID so other users know that the current Model is up to date when querying the ontology.
I have two questions?
1) My current test is running around 4-9 seconds to perform the inference on the Model is there any other ways to speed this up?
2) Is there a better way to keep the entailment index VALID during the addition/deletion of Triples without using the performInference call (I know you can switch the InferenceMaintenanceMode.UPDATE_WHEN_COMMIT and not use the performInference and commit the transaction on the graph but this still is producing the similar results regarding the performance)?
3) Is only one Attachment allowed to be enable on a specific Model? I have noticed I cannot put multiple Attachments on a existing Model.
Any help is very much appreciated, thanks.
The example code is below:
public void testIncrementalInference() throws Exception
{
Oracle oracle = new Oracle(JDBC_URL, USER, PASSWORD);
String[] modelNames =
{
"acorn_instances", "acorn_delta", "AD_NCR_Testbed", "asset_core",
"assetdescription", "assetdescription_i", "cstl",
"designofexperiments", "networktopology", "ncr_master_import",
"treat_combin_1", "treat_combin_2"
};
/* Test attaching an RDFS rulebase */
Attachment attachment = Attachment.createInstance(
modelNames,
"RDFS",
InferenceMaintenanceMode.NO_UPDATE,
QueryOptions.ALLOW_QUERY_INCOMPLETE);
GraphOracleSem graphOracleSem = new GraphOracleSem(
oracle,
"experiment",
attachment);
ModelOracleSem modelOracleSem = new ModelOracleSem(graphOracleSem);
graphOracleSem.setInferenceOption("INC=T,DOP=4");
graphOracleSem.analyze();
graphOracleSem.performInference();
graphOracleSem.analyzeInferredGraph();
/* Start time of the FACTROracleOntologyLoader */
Long startDl = System.currentTimeMillis();
List<Triple> triples = new ArrayList<Triple>();
for (int i = 0; i < 50; i++)
{
Triple rahulNadellaTriple = Triple.create(
Node.createURI(UUID.randomUUID().toString()),
Node.createURI(UUID.randomUUID().toString()),
Node.createURI(UUID.randomUUID().toString()));
triples.add(rahulNadellaTriple);
}
Triple triple1 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("Jeff Ramson"));
Triple triple2 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("RJ Soward"));
Triple triple3 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("James Smith"));
triples.add(triple1);
triples.add(triple2);
triples.add(triple3);
modelOracleSem.getGraph().getBulkUpdateHandler().add(triples);
// modelOracleSem.commit();
// graphOracleSem.commitTransaction();
graphOracleSem.analyze();
graphOracleSem.performInference();
graphOracleSem.analyzeInferredGraph();
Long endDl = System.currentTimeMillis();
double milliseconds = ((double) (endDl - startDl));
System.out.println("Milliseconds: " + milliseconds);
StringBuilder sparqlQuery = new StringBuilder(
"select ?f ?k WHERE {?f <http://xmlns.com/foaf/0.1/name> ?k .}");
Query query = QueryFactory.create(sparqlQuery.toString());
QueryExecution qexec = QueryExecutionFactory.create(query, modelOracleSem);
/* Execute the SPARQL Select Query */
ResultSet results = qexec.execSelect();
FACTRResultFormatter.out(results, query);
}
I have two questions?
1) My current test is running around 4-9 seconds to perform the inference on the Model is there any other ways to speed this up?
2) Is there a better way to keep the entailment index VALID during the addition/deletion of Triples without using the performInference call (I know you can switch the InferenceMaintenanceMode.UPDATE_WHEN_COMMIT and not use the performInference and commit the transaction on the graph but this still is producing the similar results regarding the performance)?
3) Is only one Attachment allowed to be enable on a specific Model? I have noticed I cannot put multiple Attachments on a existing Model.
Any help is very much appreciated, thanks.
The example code is below:
public void testIncrementalInference() throws Exception
{
Oracle oracle = new Oracle(JDBC_URL, USER, PASSWORD);
String[] modelNames =
{
"acorn_instances", "acorn_delta", "AD_NCR_Testbed", "asset_core",
"assetdescription", "assetdescription_i", "cstl",
"designofexperiments", "networktopology", "ncr_master_import",
"treat_combin_1", "treat_combin_2"
};
/* Test attaching an RDFS rulebase */
Attachment attachment = Attachment.createInstance(
modelNames,
"RDFS",
InferenceMaintenanceMode.NO_UPDATE,
QueryOptions.ALLOW_QUERY_INCOMPLETE);
GraphOracleSem graphOracleSem = new GraphOracleSem(
oracle,
"experiment",
attachment);
ModelOracleSem modelOracleSem = new ModelOracleSem(graphOracleSem);
graphOracleSem.setInferenceOption("INC=T,DOP=4");
graphOracleSem.analyze();
graphOracleSem.performInference();
graphOracleSem.analyzeInferredGraph();
/* Start time of the FACTROracleOntologyLoader */
Long startDl = System.currentTimeMillis();
List<Triple> triples = new ArrayList<Triple>();
for (int i = 0; i < 50; i++)
{
Triple rahulNadellaTriple = Triple.create(
Node.createURI(UUID.randomUUID().toString()),
Node.createURI(UUID.randomUUID().toString()),
Node.createURI(UUID.randomUUID().toString()));
triples.add(rahulNadellaTriple);
}
Triple triple1 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("Jeff Ramson"));
Triple triple2 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("RJ Soward"));
Triple triple3 = Triple.create(
Node.createURI("urn:testuser"),
Node.createURI("http://xmlns.com/foaf/0.1/name"),
Node.createURI("James Smith"));
triples.add(triple1);
triples.add(triple2);
triples.add(triple3);
modelOracleSem.getGraph().getBulkUpdateHandler().add(triples);
// modelOracleSem.commit();
// graphOracleSem.commitTransaction();
graphOracleSem.analyze();
graphOracleSem.performInference();
graphOracleSem.analyzeInferredGraph();
Long endDl = System.currentTimeMillis();
double milliseconds = ((double) (endDl - startDl));
System.out.println("Milliseconds: " + milliseconds);
StringBuilder sparqlQuery = new StringBuilder(
"select ?f ?k WHERE {?f <http://xmlns.com/foaf/0.1/name> ?k .}");
Query query = QueryFactory.create(sparqlQuery.toString());
QueryExecution qexec = QueryExecutionFactory.create(query, modelOracleSem);
/* Execute the SPARQL Select Query */
ResultSet results = qexec.execSelect();
FACTRResultFormatter.out(results, query);
}