Package com.github.owlcs.ontapi.internal
Class CacheObjectMapImpl<X extends org.semanticweb.owlapi.model.OWLObject>
java.lang.Object
com.github.owlcs.ontapi.internal.CacheObjectMapImpl<X>
- Type Parameters:
X
- any subtype ofOWLObject
(in the system it is eitherOWLAxiom
orOWLAnnotation
)
- 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
OWLObject
s and Triple
s 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 Triple
s.
In the Internal Model
instances of this class are used as indivisible buckets per axiom/object type.
Created by @ssz on 09.03.2019.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
An internal map-object that holds true-Map
withCacheObjectMapImpl.CachedMap
-keys andCacheObjectMapImpl.CachedMap
-values. -
Constructor Summary
ConstructorsConstructorDescriptionCacheObjectMapImpl
(Supplier<Iterator<ONTObject<X>>> loader, boolean parallel) CacheObjectMapImpl
(Supplier<Iterator<ONTObject<X>>> loader, boolean withMerge, boolean parallel, boolean fastIterator) Constructs a bucket instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given object with all its associated triples to internal map, if it is supported.void
clear()
Clears the whole map-cache.boolean
Answerstrue
is the map contains the object.long
count()
Returns the count of objects in this map.protected <K,
V> Map<K, V> Creates a freshMap
that is used in caches.boolean
Answers theONTObject
associated with the givenkey
.protected CacheObjectMapImpl.CachedMap<X,
ONTObject<X>> getMap()
boolean
hasNew()
Answerstrue
if any of the encapsulatedONTObject
s has been added manually through the methodObjectMap.add(ONTObject)
, not just loaded by the internal loader.boolean
isLoaded()
Answerstrue
if thisObjectMap
is loaded, i.e. already contains allONTObject
s in memory.keys()
Lists allOWLObjects
s encapsulated by this map.void
load()
Loads a map using internal loader.protected CacheObjectMapImpl.CachedMap<X,
ONTObject<X>> loadMap()
Loads the cache into memory usingloader
.void
Deletes the given object and all its associated triples.values()
Lists allONTObject
s encapsulated by this map.
-
Constructor Details
-
CacheObjectMapImpl
-
CacheObjectMapImpl
public CacheObjectMapImpl(Supplier<Iterator<ONTObject<X>>> loader, boolean withMerge, boolean parallel, boolean fastIterator) Constructs a bucket instance.- Parameters:
loader
- aSupplier
to load object-triples pairs, notnull
withMerge
- iftrue
merging is performed while loading cache, otherwise the source is assumed to be distinctparallel
- iftrue
use caffeine cache, otherwise LHM based cachefastIterator
- iftrue
use Array-based cache to speedup iteration overCacheObjectMapImpl
-keys
-
-
Method Details
-
loadMap
Loads the cache into memory usingloader
.- Returns:
CacheObjectMapImpl.CachedMap
-
definitelyHasNoAnnotatedAxioms
public boolean definitelyHasNoAnnotatedAxioms()- Returns:
boolean
-
createMap
Creates a freshMap
that is used in caches.- Type Parameters:
K
- key typeV
- value type- Returns:
Map
-
getMap
-
isLoaded
public boolean isLoaded()Description copied from interface:ObjectMap
Answerstrue
if thisObjectMap
is loaded, i.e. already contains allONTObject
s in memory. -
load
public void load()Description copied from interface:ObjectMap
Loads a map using internal loader. No-op in case ofObjectMap.hasNew()
orObjectMap.isLoaded()
istrue
. -
hasNew
public boolean hasNew()Description copied from interface:ObjectMap
Answerstrue
if any of the encapsulatedONTObject
s has been added manually through the methodObjectMap.add(ONTObject)
, not just loaded by the internal loader. This flag is for optimization. -
keys
Description copied from interface:ObjectMap
Lists allOWLObjects
s encapsulated by this map. -
values
Description copied from interface:ObjectMap
Lists allONTObject
s encapsulated by this map. -
count
public long count()Description copied from interface:ObjectMap
Returns the count of objects in this map. -
contains
Answerstrue
is the map contains the object. It is used directly by OWL-API interfaces.- Specified by:
contains
in interfaceObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
- Parameters:
o
-CacheObjectMapImpl
key-object, notnull
- Returns:
- boolean
-
remove
Deletes the given object and all its associated triples.- Specified by:
remove
in interfaceObjectMap<X extends org.semanticweb.owlapi.model.OWLObject>
- Parameters:
key
-CacheObjectMapImpl
(axiom or annotation)
-
add
Description copied from interface:ObjectMap
Adds the given object with all its associated triples to internal map, if it is supported. -
get
Description copied from interface:ObjectMap
Answers theONTObject
associated with the givenkey
. -
clear
public void clear()Description copied from interface:ObjectMap
Clears the whole map-cache.
-