Class LinkedHashModel
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Statement>
-
- org.eclipse.rdf4j.model.impl.AbstractModel
-
- org.eclipse.rdf4j.model.impl.LinkedHashModel
-
- All Implemented Interfaces:
Serializable
,Iterable<Statement>
,Collection<Statement>
,Set<Statement>
,Model
,NamespaceAware
public class LinkedHashModel extends AbstractModel
Hash table based implementation of theModel
interface.This implementation provides constant-time performance for filters using a single term, assuming the hash function disperses the elements properly among the buckets. Each term is indexed using a
HashMap
. When multiple terms are provided in a filter the index, of the term that reduces the possibleStatement
s the most, is used and a sequential scan is used to filter additional terms.Note that this implementation is not synchronized. If multiple threads access a model concurrently, and at least one of the threads modifies the model, it must be synchronized externally. This is typically accomplished by synchronizing on some object that naturally encapsulates the model. If no such object exists, the set should be "wrapped" using the * Models.synchronizedModel method.
- Author:
- James Leigh
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LinkedHashModel.ModelStatement
-
Constructor Summary
Constructors Constructor Description LinkedHashModel()
LinkedHashModel(int size)
LinkedHashModel(Collection<? extends Statement> c)
LinkedHashModel(Set<Namespace> namespaces)
LinkedHashModel(Set<Namespace> namespaces, int size)
LinkedHashModel(Set<Namespace> namespaces, Collection<? extends Statement> c)
LinkedHashModel(Model model)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Resource subj, IRI pred, Value obj, Resource... contexts)
boolean
add(Statement statement)
void
clear()
boolean
contains(Object o)
boolean
contains(Resource subj, IRI pred, Value obj, Resource... contexts)
Model
filter(Resource subj, IRI pred, Value obj, Resource... contexts)
Optional<Namespace>
getNamespace(String prefix)
Set<Namespace>
getNamespaces()
boolean
isEmpty()
Iterator
iterator()
boolean
remove(Resource subj, IRI pred, Value obj, Resource... contexts)
Optional<Namespace>
removeNamespace(String prefix)
void
removeTermIteration(Iterator iterator, Resource subj, IRI pred, Value obj, Resource... contexts)
Called by aggregate sets when a term has been removed from a term iterator.Namespace
setNamespace(String prefix, String name)
void
setNamespace(Namespace namespace)
int
size()
-
Methods inherited from class org.eclipse.rdf4j.model.impl.AbstractModel
addAll, clear, closeIterator, containsAll, contexts, objects, predicates, remove, removeAll, retainAll, subjects, toArray, toArray, unmodifiable
-
Methods inherited from class java.util.AbstractSet
equals, hashCode
-
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 org.eclipse.rdf4j.model.Model
getStatements
-
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
-
-
-
Constructor Detail
-
LinkedHashModel
public LinkedHashModel()
-
LinkedHashModel
public LinkedHashModel(Model model)
-
LinkedHashModel
public LinkedHashModel(Collection<? extends Statement> c)
-
LinkedHashModel
public LinkedHashModel(int size)
-
LinkedHashModel
public LinkedHashModel(Set<Namespace> namespaces, Collection<? extends Statement> c)
-
-
Method Detail
-
setNamespace
public void setNamespace(Namespace namespace)
-
size
public int size()
- Specified by:
size
in interfaceCollection<Statement>
- Specified by:
size
in interfaceSet<Statement>
- Specified by:
size
in classAbstractCollection<Statement>
-
add
public boolean add(Statement statement)
- Specified by:
add
in interfaceCollection<Statement>
- Specified by:
add
in interfaceSet<Statement>
- Overrides:
add
in classAbstractModel
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<Statement>
- Specified by:
clear
in interfaceSet<Statement>
- Overrides:
clear
in classAbstractModel
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Statement>
- Specified by:
contains
in interfaceSet<Statement>
- Overrides:
contains
in classAbstractModel
-
iterator
public Iterator iterator()
-
removeTermIteration
public void removeTermIteration(Iterator iterator, Resource subj, IRI pred, Value obj, Resource... contexts)
Description copied from class:AbstractModel
Called by aggregate sets when a term has been removed from a term iterator. Exactly one of the last four terms will be non-empty.- Specified by:
removeTermIteration
in classAbstractModel
- Parameters:
iterator
- The iterator used to navigate the live set (never null)subj
- the subject term to be removed or nullpred
- the predicate term to be removed or nullobj
- the object term to be removed or nullcontexts
- an array of one context term to be removed or an empty array
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Statement>
- Specified by:
isEmpty
in interfaceSet<Statement>
- Overrides:
isEmpty
in classAbstractModel
-
-