Class AbstractMemoryOverflowModel<T extends AbstractModel>
- All Implemented Interfaces:
Serializable
,Iterable<Statement>
,Collection<Statement>
,Set<Statement>
,Model
,NamespaceAware
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
The default batch size is 1024.protected T
static int
ms GC activity over the past second that triggers overflow to diskstatic int
ms GC activity over the past second that skips overflow to disk in anticipation of GC freeing up memorystatic int
ms GC activity over the past second that disables overflow to diskstatic int
The minimum amount of free memory before overflowing to disk.Fields inherited from class org.eclipse.rdf4j.model.impl.AbstractModel
NULL_CONTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds one or more statements to the model.boolean
boolean
addAll
(Collection<? extends Statement> c) boolean
Removes statements with the specified context exist in this model.boolean
Determines if statements with the specified subject, predicate, object and (optionally) context exist in this model.Returns a filtered view of the statements with the specified subject, predicate, object and (optionally) context.getNamespace
(String prefix) Gets the namespace that is associated with the specified prefix, if any.Gets the set that contains the assigned namespaces.iterator()
protected abstract void
overflowToDiskInner
(Model memory) boolean
Removes statements with the specified subject, predicate, object and (optionally) context exist in this model.removeNamespace
(String prefix) Removes a namespace declaration by removing the association between a prefix and a namespace name.void
removeTermIteration
(Iterator<Statement> iter, Resource subj, IRI pred, Value obj, Resource... contexts) Called by aggregate sets when a term has been removed from a term iterator.setNamespace
(String prefix, String name) Sets the prefix for a namespace.void
setNamespace
(Namespace namespace) Sets the prefix for a namespace.int
size()
Methods inherited from class org.eclipse.rdf4j.model.impl.AbstractModel
clear, closeIterator, contains, containsAll, contexts, isEmpty, 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
-
Field Details
-
BATCH_SIZE
public static int BATCH_SIZEThe default batch size is 1024. This is the number of statements that will be written to disk at a time. -
MEMORY_THRESHOLD_HIGH
public static int MEMORY_THRESHOLD_HIGHms GC activity over the past second that triggers overflow to disk -
MEMORY_THRESHOLD_MEDIUM
public static int MEMORY_THRESHOLD_MEDIUMms GC activity over the past second that disables overflow to disk -
MEMORY_THRESHOLD_LOW
public static int MEMORY_THRESHOLD_LOWms GC activity over the past second that skips overflow to disk in anticipation of GC freeing up memory -
MIN_AVAILABLE_MEM_BEFORE_OVERFLOWING
public static int MIN_AVAILABLE_MEM_BEFORE_OVERFLOWINGThe minimum amount of free memory before overflowing to disk. Defaults to 32 MB for heaps smaller than 1 GB and 128 MB for heaps larger than 1 GB. -
disk
-
-
Constructor Details
-
AbstractMemoryOverflowModel
public AbstractMemoryOverflowModel() -
AbstractMemoryOverflowModel
-
-
Method Details
-
getNamespaces
Description copied from interface:NamespaceAware
Gets the set that contains the assigned namespaces. -
getNamespace
Description copied from interface:NamespaceAware
Gets the namespace that is associated with the specified prefix, if any. If multiple namespaces match the given prefix, the result may not be consistent over successive calls to this method.- Parameters:
prefix
- A namespace prefix.- Returns:
- The namespace name that is associated with the specified prefix, or
Optional.empty()
if there is no such namespace.
-
setNamespace
-
setNamespace
-
removeNamespace
Description copied from interface:Model
Removes a namespace declaration by removing the association between a prefix and a namespace name.- Parameters:
prefix
- The namespace prefix of which the assocation with a namespace name is to be removed.- Returns:
- the previous namespace bound to the prefix or
Optional.empty()
-
contains
Description copied from interface:Model
Determines if statements with the specified subject, predicate, object and (optionally) context exist in this model. Thesubject
,predicate
andobject
parameters can benull
to indicate wildcards. Thecontexts
parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match. Note: to match statements without an associated context, specify the valuenull
and explicitly cast it to typeResource
.Examples:
model.contains(s1, null, null)
is true if any statements in this model have subjects1
,
model.contains(null, null, null, c1)
is true if any statements in this model have contextc1
,
model.contains(null, null, null, (Resource)null)
is true if any statements in this model have no associated context,
model.contains(null, null, null, c1, c2, c3)
is true if any statements in this model have contextc1
,c2
orc3
.- Parameters:
subj
- The subject of the statements to match,null
to match statements with any subject.pred
- The predicate of the statements to match,null
to match statements with any predicate.obj
- The object of the statements to match,null
to match statements with any object.contexts
- The contexts of the statements to match. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match.- Returns:
true
if statements match the specified pattern.
-
add
Description copied from interface:Model
Adds one or more statements to the model. This method creates a statement for each specified context and adds those to the model. If no contexts are specified, a single statement with no associated context is added. If this Model is a filtered Model then null (if context empty) values are permitted and will use the corresponding filtered values.- Parameters:
subj
- The statement's subject.pred
- The statement's predicate.obj
- The statement's object.contexts
- The contexts to add statements to.
-
add
- Specified by:
add
in interfaceCollection<T extends AbstractModel>
- Specified by:
add
in interfaceSet<T extends AbstractModel>
- Overrides:
add
in classAbstractModel
-
addAll
- Specified by:
addAll
in interfaceCollection<T extends AbstractModel>
- Specified by:
addAll
in interfaceSet<T extends AbstractModel>
- Overrides:
addAll
in classAbstractModel
-
remove
Description copied from interface:Model
Removes statements with the specified subject, predicate, object and (optionally) context exist in this model. Thesubject
,predicate
andobject
parameters can benull
to indicate wildcards. Thecontexts
parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will be removed disregarding their context. If one or more contexts are specified, statements with a context matching one of these will be removed. Note: to remove statements without an associated context, specify the valuenull
and explicitly cast it to typeResource
.Examples:
model.remove(s1, null, null)
removes any statements in this model have subjects1
,
model.remove(null, null, null, c1)
removes any statements in this model have contextc1
,
model.remove(null, null, null, (Resource)null)
removes any statements in this model have no associated context,
model.remove(null, null, null, c1, c2, c3)
removes any statements in this model have contextc1
,c2
orc3
.- Parameters:
subj
- The subject of the statements to remove,null
to remove statements with any subject.pred
- The predicate of the statements to remove,null
to remove statements with any predicate.obj
- The object of the statements to remove,null
to remove statements with any object.contexts
- The contexts of the statements to remove. If no contexts are specified, statements will be removed disregarding their context. If one or more contexts are specified, statements with a context matching one of these will be removed.- Returns:
true
if one or more statements have been removed.
-
size
public int size()- Specified by:
size
in interfaceCollection<T extends AbstractModel>
- Specified by:
size
in interfaceSet<T extends AbstractModel>
- Specified by:
size
in classAbstractCollection<Statement>
-
iterator
- Specified by:
iterator
in interfaceCollection<T extends AbstractModel>
- Specified by:
iterator
in interfaceIterable<T extends AbstractModel>
- Specified by:
iterator
in interfaceSet<T extends AbstractModel>
- Specified by:
iterator
in classAbstractCollection<Statement>
-
clear
Description copied from interface:Model
Removes statements with the specified context exist in this model.- Specified by:
clear
in interfaceModel
- Overrides:
clear
in classAbstractModel
- Parameters:
contexts
- The context of the statements to remove.- Returns:
true
if one or more statements have been removed.
-
filter
Description copied from interface:Model
Returns a filtered view of the statements with the specified subject, predicate, object and (optionally) context. Thesubject
,predicate
andobject
parameters can benull
to indicate wildcards. Thecontexts
parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match. Note: to match statements without an associated context, specify the valuenull
and explicitly cast it to typeResource
.The returned model is backed by this Model, so changes to this Model are reflected in the returned model, and vice-versa. If this Model is modified while an iteration over the returned model is in progress (except through the iterator's own
remove
operation), the results of the iteration are undefined. The model supports element removal, which removes the corresponding statement from this Model, via theIterator.remove
,Set.remove
,removeAll
,retainAll
, andclear
operations. The statements passed to theadd
andaddAll
operations must match the parameter pattern.Examples:
model.filter(s1, null, null)
matches all statements that have subjects1
,
model.filter(null, null, null, c1)
matches all statements that have contextc1
,
model.filter(null, null, null, (Resource)null)
matches all statements that have no associated context,
model.filter(null, null, null, c1, c2, c3)
matches all statements that have contextc1
,c2
orc3
.- Parameters:
subj
- The subject of the statements to match,null
to match statements with any subject.pred
- The predicate of the statements to match,null
to match statements with any predicate.obj
- The object of the statements to match,null
to match statements with any object.contexts
- The contexts of the statements to match. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match.- Returns:
- The statements that match the specified pattern.
- See Also:
-
removeTermIteration
public void removeTermIteration(Iterator<Statement> iter, 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:
iter
- 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
-
overflowToDiskInner
-