Package org.eclipse.rdf4j.repository
Class RepositoryResult<T>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<T>
org.eclipse.rdf4j.repository.RepositoryResult<T>
- All Implemented Interfaces:
AutoCloseable
,Iterable<T>
,Iterator<T>
,CloseableIteration<T>
A RepositoryResult is a result collection of objects (for example
Statement
,
Namespace
, or Resource
objects) that can be iterated over. It keeps an open
connection to the backend for lazy retrieval of individual results. Additionally it has some utility methods to fetch
all results and add them to a collection.
By default, a RepositoryResult is not necessarily a (mathematical) set: it may contain duplicate objects. Duplicate
filtering can be switched on
, but this should not be used lightly as the filtering
mechanism is potentially memory-intensive.
A RepositoryResult needs to be closed
after use to free up any resources (open connections, read
locks, etc.) it has on the underlying repository.
- Author:
- Jeen Broekstra, Arjohn Kampman
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<C extends Collection<T>>
CaddTo
(C collection) Deprecated.asList()
Deprecated.UseIterations.asList(CloseableIteration)
instead.void
Switches on duplicate filtering while iterating over objects.protected void
Called byAbstractCloseableIteration.close()
when it is called for the first time.boolean
hasNext()
iterator()
next()
void
remove()
Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
RepositoryResult
-
-
Method Details
-
hasNext
- Specified by:
hasNext
in interfaceIterator<T>
- Throws:
RepositoryException
-
next
- Specified by:
next
in interfaceIterator<T>
- Throws:
RepositoryException
-
remove
- Specified by:
remove
in interfaceIterator<T>
- Throws:
RepositoryException
-
handleClose
Description copied from class:AbstractCloseableIteration
Called byAbstractCloseableIteration.close()
when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.- Overrides:
handleClose
in classAbstractCloseableIteration<T>
- Throws:
RepositoryException
-
enableDuplicateFilter
Switches on duplicate filtering while iterating over objects. The RepositoryResult will keep track of the previously returned objects in aSet
and on calling next() or hasNext() will ignore any objects that already occur in this Set.Caution: use of this filtering mechanism is potentially memory-intensive.
- Throws:
RepositoryException
- if a problem occurred during initialization of the filter.
-
asList
Deprecated.UseIterations.asList(CloseableIteration)
instead.Returns aList
containing all objects of this RepositoryResult in order of iteration. The RepositoryResult is fully consumed and automatically closed by this operation.Note: use this method with caution! It pulls the entire RepositoryResult in memory and as such is potentially very memory-intensive.
- Returns:
- a List containing all objects of this RepositoryResult.
- Throws:
RepositoryException
- if a problem occurred during retrieval of the results.- See Also:
-
addTo
Deprecated.UseIterations.addAll(CloseableIteration, Collection)
instead.Adds all objects of this RepositoryResult to the supplied collection. The RepositoryResult is fully consumed and automatically closed by this operation.- Returns:
- A reference to the collection that was supplied.
- Throws:
RepositoryException
- if a problem occurred during retrieval of the results.
-
iterator
-
Iterations.addAll(CloseableIteration, Collection)
instead.