Closed matentzn closed 6 years ago
In ELK only direct subclasses / superclasses are stored in the taxonomy model. Indirect (all) subclasses / superclasses are computed on the fly from the direct ones. We do not decide for the user which calls of the OWL API methods to cache. If you need to retrieve (non-direct) subclasses / superclasses frequently for the same object, V2 seems to be the right choice.
Okay thanks.
I do not know whether this is a bug, but I had a bottleneck in an application and I was surprised to find it here. After calling r.precomputeInferences(CLASS_HIERARCHY) I would expect calls to getSubclasses and getSuperclasses to be mere look-ups. However, these calls tend to be very slow; In order to proof that it was not the lookup itself causing the trouble, I tried the following:
OWLReasoner r = new ElkReasonerFactory().createReasoner(o); List<OWLClass> classes = createClassListWithDuplicates();
V1
for(OWLClass c:classes) { System.out.println(r.getSubClasses(c,false)); }
V2:
Map<OWLClass,Set<OWLClass>> makeshiftcache = new HashMap<>(); for(OWLClass c:classes) { if(!makeshiftcache.containsKey(c)) { makeshiftcache.put(c,r.getSubClasses(c,false).getFlattened()); } System.out.println(makeshiftcache.get(c)); }
Over time, V2 gets faster and faster, while V1 remains always the same in terms of performance. Is this intentional, or not a supported behaviour?