Reputation: 493
I was wondering how expensive (time-wise) the
OWLOntologyManager.addAxioms(OWLOntology ont, java.util.Set<? extends OWLAxiom> axioms)
operation is. The main reason I am asking is I am working with a very large dataset and wanted to know if it would be more efficient to add axioms to my ontology immediately as they are created or wait until all the axioms are ready and add them in one method call?
Additionally, and this is just because I'm curious, are the various OWLAxiom
creation methods constant time operations ? If not, how expensive are they?
Just in case you are wondering, I plan to apply the pellet reasoner in a buffering mode and flush the changes once all ontology modifications are complete.
Upvotes: 0
Views: 53
Reputation: 10684
Adding axioms requires a few maps to be updated (depending on the type of axiom, one or more indexes may exist). If there are listeners waiting to hear about changes to an ontology, they will be notified as well - it is up to the listener whether or not expensive operations are carried out.
Reasoners are an example of listeners: typically they will collect axioms until flush()
is called, in a temporary collection.
Time cost wise, this should amount to one or more insertions in a hash map (or concurrent hash map), and iteration on a list of listeners, usually containing very few elements. The cost is expected to be close to constant, however for large ontologies the increase in memory use might cause slowdown for garbage collection.
For recent versions of OWL API (4.0.2, for example) adding axioms as the ontology is being parsed from a file uses temporary lists rather than sets - this reduces the hashing cost. The lists are turned into sets once loading finishes - on the first read access to the axiom collections, to be precise.
When compared with reasoning costs, any of these costs should be irrelevant - reasoning is expected to take much longer, as it is a much more complex operation.
Buffering and then flushing once changes are completed is likely to be the best strategy in this case.
OWL API could use better batching of axioms for insertion, but in its current versions there is little difference between adding a set of axioms and adding a single axiom.
Upvotes: 2