java.lang.Object
org.apache.jena.mem2.store.roaring.RoaringTripleStore
- All Implemented Interfaces:
org.apache.jena.atlas.lib.Copyable<TripleStore>,TripleStore
A triple store that is ideal for handling extremely large graphs.
With the new indexing strategies, it also works well for very small graphs,
where pattern matching is not needed.
This store supports different indexing strategies to balance RAM usage and performance for various operations.
See IndexingStrategy for details on the available strategies.
Internal structure:
- One indexed hash set (same as GraphMem2Fast uses) that holds all triples
- The index consists of three hash maps indexed by subjects, predicates, and objects with RoaringBitmaps as values
- The bitmaps contain the indices of the triples in the central hash set
The bitmaps are used to quickly find triples that match a given pattern.
The bitmap operations like FastAggregation.naive_and(RoaringBitmap...) and
RoaringBitmap.intersects(RoaringBitmap, RoaringBitmap) are used to find matches for the pattern
S_O, SP_, and _PO pretty fast, even in large graphs.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new RoaringTripleStore with the default indexing strategy (EAGER).RoaringTripleStore(IndexingStrategy indexingStrategy) Create a new RoaringTripleStore with the given indexing strategy. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a triple to the map.voidclear()Remove all triples from the map.voidClear the index of this store.booleanAnswer true if the graph contains any triple matchingt.copy()Return a new triple store that is a copy of this one.intReturn the number of triples in the map.Returns anExtendedIteratorof all triples in the graph matching the given triple match.Get the indexing strategy of this store.voidInitialize the index for this store.voidInitialize the index for this store in parallel.booleanisEmpty()Return true if the map is empty.booleanCheck if the index of this store is initialized.voidRemove a triple from the map.stream()Returns aStreamof all triples in the graph.Returns aStreamof Triples matching the given pattern.
-
Constructor Details
-
RoaringTripleStore
public RoaringTripleStore()Create a new RoaringTripleStore with the default indexing strategy (EAGER).The default strategy is EAGER, because of backwards compatibility. This is not necessarily the best strategy for all use cases, but it reflects the behavior before introducing the indexing strategies.
-
RoaringTripleStore
Create a new RoaringTripleStore with the given indexing strategy.- Parameters:
indexingStrategy- the indexing strategy to use
-
-
Method Details
-
isIndexInitialized
public boolean isIndexInitialized()Check if the index of this store is initialized. This will return true if the current strategy is EagerStoreStrategy, which means that the index has been initialized and all triples are indexed.- Returns:
- true if the index is initialized, false otherwise
-
getIndexingStrategy
Get the indexing strategy of this store.- Returns:
- the indexing strategy
-
clearIndex
public void clearIndex()Clear the index of this store. This will remove all triples from the index and reset the current strategy to the initial one. -
initializeIndex
public void initializeIndex()Initialize the index for this store. -
initializeIndexParallel
public void initializeIndexParallel()Initialize the index for this store in parallel. This will index all triples in parallel, which can be faster for large datasets. -
add
Description copied from interface:TripleStoreAdd a triple to the map.- Specified by:
addin interfaceTripleStore- Parameters:
triple- to add
-
remove
Description copied from interface:TripleStoreRemove a triple from the map.- Specified by:
removein interfaceTripleStore- Parameters:
triple- to remove
-
clear
public void clear()Description copied from interface:TripleStoreRemove all triples from the map.- Specified by:
clearin interfaceTripleStore
-
countTriples
public int countTriples()Description copied from interface:TripleStoreReturn the number of triples in the map.- Specified by:
countTriplesin interfaceTripleStore
-
isEmpty
public boolean isEmpty()Description copied from interface:TripleStoreReturn true if the map is empty.- Specified by:
isEmptyin interfaceTripleStore
-
contains
Description copied from interface:TripleStoreAnswer true if the graph contains any triple matchingt.- Specified by:
containsin interfaceTripleStore- Parameters:
tripleMatch- triple match pattern, which may be contained
-
stream
Description copied from interface:TripleStoreReturns aStreamof all triples in the graph. Note:BaseStream.parallel()is supported.- Specified by:
streamin interfaceTripleStore- Returns:
- a stream of triples in this graph.
-
stream
Description copied from interface:TripleStoreReturns aStreamof Triples matching the given pattern. Note:BaseStream.parallel()is supported.- Specified by:
streamin interfaceTripleStore- Parameters:
tripleMatch- triple match pattern- Returns:
- a stream of triples in this graph matching the pattern.
-
find
Description copied from interface:TripleStoreReturns anExtendedIteratorof all triples in the graph matching the given triple match.- Specified by:
findin interfaceTripleStore
-
copy
Description copied from interface:TripleStoreReturn a new triple store that is a copy of this one. Since Nodes and Triples are immutable and shared, the copy can share the same Nodes and Triples.- Specified by:
copyin interfaceorg.apache.jena.atlas.lib.Copyable<TripleStore>- Specified by:
copyin interfaceTripleStore- Returns:
- an independent copy of this store
-