- All Superinterfaces:
org.apache.jena.atlas.lib.Copyable<TripleStore>
- All Known Implementing Classes:
FastTripleStore,IndexedSetTripleStore,LegacyTripleStore,RoaringTripleStore
Storage abstraction used by the
mem2 in-memory graph implementations.
A TripleStore is a set-like collection of Triples that also
supports pattern-based lookup (find(org.apache.jena.graph.Triple), stream(Triple),
contains(org.apache.jena.graph.Triple)). Implementations are expected to be efficient for the
lookup patterns described in
MatchPattern.
Implementations are not required to be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a triple to the store.voidclear()Remove all triples from the store.booleanReturnstrueif the store contains any triple matching the given pattern.copy()Returns an independent copy of this store.intReturns the number of triples in the store.Returns anExtendedIteratorover every triple in the store matching the given pattern.booleanisEmpty()Returnstrueif the store contains no triples.voidRemove a triple from the store.stream()Returns aStreamof all triples in the store.Returns aStreamof every triple in the store matching the given pattern.
-
Method Details
-
add
Add a triple to the store. Does nothing if the triple is already present.- Parameters:
triple- the triple to add
-
remove
Remove a triple from the store. Does nothing if the triple is not present.- Parameters:
triple- the triple to remove
-
clear
void clear()Remove all triples from the store. After this call,isEmpty()returnstrueand any associated indices are emptied. -
countTriples
int countTriples()Returns the number of triples in the store.- Returns:
- the number of triples
-
isEmpty
boolean isEmpty()Returnstrueif the store contains no triples.- Returns:
trueif empty
-
contains
Returnstrueif the store contains any triple matching the given pattern. The pattern may contain wildcards (e.g.Node.ANY).- Parameters:
tripleMatch- the triple pattern to match- Returns:
trueif at least one matching triple exists
-
stream
Returns aStreamof all triples in the store. The returned stream supportsBaseStream.parallel().- Returns:
- a stream over every triple in this store
-
stream
Returns aStreamof every triple in the store matching the given pattern. The returned stream supportsBaseStream.parallel().- Parameters:
tripleMatch- the triple pattern to match (may contain wildcards)- Returns:
- a stream over the matching triples
-
find
Returns anExtendedIteratorover every triple in the store matching the given pattern.- Parameters:
tripleMatch- the triple pattern to match (may contain wildcards)- Returns:
- an iterator over the matching triples
-
copy
TripleStore copy()Returns an independent copy of this store. SinceNodes andTriples are immutable, the copy may share node and triple instances with the original; only the container/index data structures are duplicated so that mutations in either store do not affect the other.- Specified by:
copyin interfaceorg.apache.jena.atlas.lib.Copyable<TripleStore>- Returns:
- an independent copy of this store
-