Package org.eclipse.rdf4j.model.impl
Class DynamicModel
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Statement>
-
- org.eclipse.rdf4j.model.impl.DynamicModel
-
- All Implemented Interfaces:
Serializable,Iterable<Statement>,Collection<Statement>,Set<Statement>,Model,NamespaceAware
public class DynamicModel extends AbstractSet<Statement> implements Model
A LinkedHashModel or a TreeModel achieves fast data access at the cost of higher indexing time. The DynamicModel postpones this cost until such access is actually needed. It stores all data in a LinkedHashMap and supports adding, retrieving and removing data. The model will upgrade to a full model (provided by the modelFactory) if more complex operations are called, for instance removing data according to a pattern (eg. all statements with rdf:type as predicate).DynamicModel is thread safe to the extent that the underlying LinkedHashMap or Model is. The upgrade path is protected by the actual upgrade method being synchronized. The LinkedHashMap storage is not removed once upgraded, so concurrent reads that have started reading from the LinkedHashMap can continue to read even during an upgrade. We do make the LinkedHashMap unmodifiable to reduce the chance of there being a bug.
- Author:
- HÃ¥vard Mikkelsen Ottestad
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DynamicModel(ModelFactory modelFactory)
-
Method Summary
-
Methods inherited from class java.util.AbstractCollection
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
DynamicModel
public DynamicModel(ModelFactory modelFactory)
-
-
Method Detail
-
unmodifiable
public Model unmodifiable()
- Specified by:
unmodifiablein interfaceModel
-
getNamespace
public Optional<Namespace> getNamespace(String prefix)
- Specified by:
getNamespacein interfaceNamespaceAware
-
getNamespaces
public Set<Namespace> getNamespaces()
- Specified by:
getNamespacesin interfaceNamespaceAware
-
setNamespace
public Namespace setNamespace(String prefix, String name)
- Specified by:
setNamespacein interfaceModel
-
setNamespace
public void setNamespace(Namespace namespace)
- Specified by:
setNamespacein interfaceModel
-
removeNamespace
public Optional<Namespace> removeNamespace(String prefix)
- Specified by:
removeNamespacein interfaceModel
-
predicates
public Set<IRI> predicates()
- Specified by:
predicatesin interfaceModel
-
size
public int size()
- Specified by:
sizein interfaceCollection<Statement>- Specified by:
sizein interfaceSet<Statement>- Specified by:
sizein classAbstractCollection<Statement>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<Statement>- Specified by:
isEmptyin interfaceSet<Statement>- Overrides:
isEmptyin classAbstractCollection<Statement>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<Statement>- Specified by:
containsin interfaceSet<Statement>- Overrides:
containsin classAbstractCollection<Statement>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<Statement>- Specified by:
toArrayin interfaceSet<Statement>- Overrides:
toArrayin classAbstractCollection<Statement>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfaceCollection<Statement>- Specified by:
toArrayin interfaceSet<Statement>- Overrides:
toArrayin classAbstractCollection<Statement>
-
add
public boolean add(Statement statement)
- Specified by:
addin interfaceCollection<Statement>- Specified by:
addin interfaceSet<Statement>- Overrides:
addin classAbstractCollection<Statement>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<Statement>- Specified by:
removein interfaceSet<Statement>- Overrides:
removein classAbstractCollection<Statement>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<Statement>- Specified by:
containsAllin interfaceSet<Statement>- Overrides:
containsAllin classAbstractCollection<Statement>
-
addAll
public boolean addAll(Collection<? extends Statement> c)
- Specified by:
addAllin interfaceCollection<Statement>- Specified by:
addAllin interfaceSet<Statement>- Overrides:
addAllin classAbstractCollection<Statement>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<Statement>- Specified by:
retainAllin interfaceSet<Statement>- Overrides:
retainAllin classAbstractCollection<Statement>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<Statement>- Specified by:
removeAllin interfaceSet<Statement>- Overrides:
removeAllin classAbstractSet<Statement>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<Statement>- Specified by:
clearin interfaceSet<Statement>- Overrides:
clearin classAbstractCollection<Statement>
-
getStatements
public Iterable<Statement> getStatements(Resource subject, IRI predicate, Value object, Resource... contexts)
- Specified by:
getStatementsin interfaceModel
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<Statement>- Specified by:
equalsin interfaceSet<Statement>- Overrides:
equalsin classAbstractSet<Statement>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<Statement>- Specified by:
hashCodein interfaceSet<Statement>- Overrides:
hashCodein classAbstractSet<Statement>
-
-