java.lang.Object
org.apache.jena.graph.impl.GraphBase
org.apache.jena.mem.GraphMem
org.apache.jena.mem.GraphMemIndexedSet
- All Implemented Interfaces:
org.apache.jena.atlas.lib.Copyable<GraphMem>,Graph,GraphWithPerform
In-memory
GraphMem implementation that stores all triples in a single
indexed set (IndexedSetTripleStore). This class is not thread-safe.
Different indexing strategies can be selected to
balance memory usage and lookup performance. The triples themselves always live
in a flat set; only the auxiliary subject/predicate/object indices are
controlled by the strategy. See IndexingStrategy for the trade-offs of
each variant.
While the index has not been built (e.g. with IndexingStrategy.LAZY,
IndexingStrategy.LAZY_PARALLEL, IndexingStrategy.MANUAL or
IndexingStrategy.MINIMAL) the memory footprint is very low and the
following operations are particularly fast:
GraphBase.add(org.apache.jena.graph.Triple)- adds a triple to the graphGraphBase.delete(org.apache.jena.graph.Triple)- removes a triple from the graph
initializeIndexParallel() to build the index in parallel.-
Field Summary
Fields inherited from class org.apache.jena.graph.impl.GraphBase
TOSTRING_TRIPLE_BASE, TOSTRING_TRIPLE_LIMITFields inherited from interface org.apache.jena.graph.Graph
emptyGraph -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new graph using theIndexingStrategy.EAGERdefault indexing strategy.GraphMemIndexedSet(IndexingStrategy indexingStrategy) Creates a new graph that uses the given indexing strategy. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of this graph.Returns the indexing strategy this graph was created with.voidBuild (or rebuild) the index sequentially.voidBuild (or rebuild) the index in parallel.booleanReports whether the index is currently built and ready to serve pattern lookups directly.voidDrops the current subject/predicate/object index and reverts to the initial strategy.Methods inherited from class org.apache.jena.mem.GraphMem
clear, graphBaseContains, graphBaseFind, graphBaseSize, performAdd, performDelete, stream, streamMethods inherited from class org.apache.jena.graph.impl.GraphBase
add, close, contains, contains, delete, find, find, forTestingOnly_graphBaseFind, getEventManager, getPrefixMapping, getTransactionHandler, isClosed, isEmpty, isIsomorphicWith, notifyAdd, notifyDelete, remove, size, toString, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.jena.graph.Graph
add, add, close, contains, contains, delete, delete, find, find, find, getEventManager, getPrefixMapping, getTransactionHandler, isClosed, isEmpty, isIsomorphicWith, remove, size, sizeLong
-
Constructor Details
-
GraphMemIndexedSet
public GraphMemIndexedSet()Creates a new graph using theIndexingStrategy.EAGERdefault indexing strategy. -
GraphMemIndexedSet
Creates a new graph that uses the given indexing strategy.- Parameters:
indexingStrategy- the indexing strategy to use; controls when the subject/predicate/object index is built and how pattern lookups are evaluated
-
-
Method Details
-
copy
Creates a copy of this graph. Since the triples and nodes are immutable, the copy contains the same triples and nodes as this graph. Modifications to the copy will not affect this graph.Returns an independent copy that preserves the indexing strategy and, if the source has its index built, copies the index data structures directly to avoid rebuilding them.
-
getIndexingStrategy
Returns the indexing strategy this graph was created with. The strategy is fixed for the lifetime of the graph; clearing or initializing the index does not change it.- Returns:
- the indexing strategy
-
resetIndexingStrategy
public void resetIndexingStrategy()Drops the current subject/predicate/object index and reverts to the initial strategy. Subsequent pattern lookups will trigger (re)building the index according to the configuredIndexingStrategy. -
initializeIndex
public void initializeIndex()Build (or rebuild) the index sequentially. After this call, pattern lookups will be served by the eager strategy regardless of the originally configured indexing strategy. -
initializeIndexParallel
public void initializeIndexParallel()Build (or rebuild) the index in parallel. This can be substantially faster thaninitializeIndex()for larger graphs. After this call, pattern lookups will be served by the eager strategy regardless of the originally configured indexing strategy. -
isIndexInitialized
public boolean isIndexInitialized()Reports whether the index is currently built and ready to serve pattern lookups directly. For graphs configured with a non-eager strategy this may flip fromfalsetotrueas soon as the first lookup is performed (or wheninitializeIndex()is called explicitly).- Returns:
trueiff the index is initialized
-