Class CacheObjectMapImpl<X extends org.semanticweb.owlapi.model.OWLObject>

java.lang.Object
com.github.owlcs.ontapi.internal.CacheObjectMapImpl<X>
Type Parameters:
X - any subtype of OWLObject (in the system it is either OWLAxiom or OWLAnnotation)
All Implemented Interfaces:
ObjectMap<X>

public class CacheObjectMapImpl<X extends org.semanticweb.owlapi.model.OWLObject> extends Object implements ObjectMap<X>
An auxiliary class-container (bucket) to provide a common way for working with OWLObjects and Triples all together. It is logically based on the ONTObject container, that is a wrapper around classic OWL-API Object but with a possibility to get all associated Jena RDF Triples. In the Internal Model instances of this class are used as indivisible buckets per axiom/object type.

Created by @ssz on 09.03.2019.

  • Constructor Details

    • CacheObjectMapImpl

      public CacheObjectMapImpl(Supplier<Iterator<ONTObject<X>>> loader, boolean parallel)
    • CacheObjectMapImpl

      public CacheObjectMapImpl(Supplier<Iterator<ONTObject<X>>> loader, boolean withMerge, boolean parallel, boolean fastIterator)
      Constructs a bucket instance.
      Parameters:
      loader - a Supplier to load object-triples pairs, not null
      withMerge - if true merging is performed while loading cache, otherwise the source is assumed to be distinct
      parallel - if true use caffeine cache, otherwise LHM based cache
      fastIterator - if true use Array-based cache to speedup iteration over CacheObjectMapImpl-keys
  • Method Details

    • loadMap

      protected CacheObjectMapImpl.CachedMap<X,ONTObject<X>> loadMap()
      Loads the cache into memory using loader.
      Returns:
      CacheObjectMapImpl.CachedMap
    • definitelyHasNoAnnotatedAxioms

      public boolean definitelyHasNoAnnotatedAxioms()
      Answers true iff this ObjectMap consists only plain Axioms.
      Returns:
      boolean
    • createMap

      protected <K, V> Map<K,V> createMap()
      Creates a fresh Map that is used in caches.
      Type Parameters:
      K - key type
      V - value type
      Returns:
      Map
    • getMap

      protected CacheObjectMapImpl.CachedMap<X,ONTObject<X>> getMap()
    • isLoaded

      public boolean isLoaded()
      Description copied from interface: ObjectMap
      Answers true if this ObjectMap is loaded, i.e. already contains all ONTObjects in memory.
      Specified by:
      isLoaded in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Returns:
      boolean
    • load

      public void load()
      Description copied from interface: ObjectMap
      Loads a map using internal loader. No-op in case of ObjectMap.hasNew() or ObjectMap.isLoaded() is true.
      Specified by:
      load in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
    • hasNew

      public boolean hasNew()
      Description copied from interface: ObjectMap
      Answers true if any of the encapsulated ONTObjects has been added manually through the method ObjectMap.add(ONTObject), not just loaded by the internal loader. This flag is for optimization.
      Specified by:
      hasNew in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Returns:
      boolean
    • keys

      public Stream<X> keys()
      Description copied from interface: ObjectMap
      Lists all OWLObjectss encapsulated by this map.
      Specified by:
      keys in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Returns:
      Stream of ObjectMaps
    • values

      public Stream<ONTObject<X>> values()
      Description copied from interface: ObjectMap
      Lists all ONTObjects encapsulated by this map.
      Specified by:
      values in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Returns:
      Stream of ONTObject that wrap ObjectMaps
    • count

      public long count()
      Description copied from interface: ObjectMap
      Returns the count of objects in this map.
      Specified by:
      count in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Returns:
      long
    • contains

      public boolean contains(X o)
      Answers true is the map contains the object. It is used directly by OWL-API interfaces.
      Specified by:
      contains in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Parameters:
      o - CacheObjectMapImpl key-object, not null
      Returns:
      boolean
    • remove

      public void remove(X key)
      Deletes the given object and all its associated triples.
      Specified by:
      remove in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Parameters:
      key - CacheObjectMapImpl (axiom or annotation)
    • add

      public void add(ONTObject<X> value)
      Description copied from interface: ObjectMap
      Adds the given object with all its associated triples to internal map, if it is supported.
      Specified by:
      add in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Parameters:
      value - ONTObject of ObjectMap, not null
    • get

      public ONTObject<X> get(X key)
      Description copied from interface: ObjectMap
      Answers the ONTObject associated with the given key.
      Specified by:
      get in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
      Parameters:
      key - ObjectMap key-object, not null
      Returns:
      ONTObject or null
    • clear

      public void clear()
      Description copied from interface: ObjectMap
      Clears the whole map-cache.
      Specified by:
      clear in interface ObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>