Class MemorySailStore
java.lang.Object
org.eclipse.rdf4j.sail.memory.MemorySailStore
- All Implemented Interfaces:
AutoCloseable, SailClosable, SailStore
An implementation of
SailStore that keeps committed statements in a MemStatementList.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classprivate final classprivate final class(package private) static classSnapshotMonitor is used to keep track of which snapshot version are no longer is use (read or write) so that we can safely clean that snapshot version. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final doubleprivate intIdentifies the current snapshot.static final MemResource[]static final EmptyIteration<MemStatement, SailException> static final EmptyIteration<MemTriple, SailException> private final MemStatementIteratorCacheprivate static final org.slf4j.Loggerprivate static final longprivate booleanThis gets set to `true` when we add our first inferred statement.private final MemNamespaceStoreStore for namespace prefix info.static final MemResource[]private static final Runtimeprivate ThreadCleanup thread that removes deprecated statements when no other threads are accessing this list.private final ObjectLock object used to synchronize concurrent access tosnapshotCleanupThread.(package private) final MemorySailStore.SnapshotMonitorprivate final MemStatementListList containing all available statements.private final ExclusiveReentrantLockManagerLock manager used to prevent concurrent writes.private final MemValueFactoryFactory/cache for MemValue objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRemoves statements from old snapshots from the main statement list and resets the snapshot to 1 for the rest of the statements.voidclose()Closes this resource, relinquishing any underlying resources.private SailExceptionprivate CloseableIteration<MemStatement, SailException> createStatementIterator(Resource subj, IRI pred, Value obj, Boolean explicit, int snapshot, Resource... contexts) Creates a StatementIterator that contains the statements matching the specified pattern of subject, predicate, object, context.private CloseableIteration<MemTriple, SailException> createTripleIterator(Resource subj, IRI pred, Value obj, int snapshot) Creates a TripleIterator that contains the triples matching the specified pattern of subject, predicate, object, context.Used bySailSourceConnectionto determine query join order.private longprivate CloseableIteration<MemStatement, SailException> getMemStatementIterator(MemResource subj, MemIRI pred, MemValue obj, Boolean explicit, int snapshot, MemResource[] memContexts, MemStatementList statementList) private MemStatementListgetSmallestStatementList(MemResource subj, MemIRI pred, MemValue obj) TheValueFactorythat should be used in association with this.private voidprivate static booleanmemoryIsLow(long freeToAllocateMemory) private booleanprioritiseSnapshotCleaningIfLowOnMemory(boolean prioritiseCleaning) protected void
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
RUNTIME
-
MAX_MEMORY
private static final long MAX_MEMORY -
CLEANUP_MAX_MEMORY_THRESHOLD
private static final int CLEANUP_MAX_MEMORY_THRESHOLD- See Also:
-
CLEANUP_MINIMUM_FREE_MEMORY
private static final int CLEANUP_MINIMUM_FREE_MEMORY- See Also:
-
CLEANUP_MINIMUM_FREE_MEMORY_RATIO
private static final double CLEANUP_MINIMUM_FREE_MEMORY_RATIO- See Also:
-
EMPTY_ITERATION
-
EMPTY_TRIPLE_ITERATION
-
EMPTY_CONTEXT
-
NULL_CONTEXT
-
iteratorCache
-
valueFactory
Factory/cache for MemValue objects. -
statements
List containing all available statements. -
mayHaveInferred
private volatile boolean mayHaveInferredThis gets set to `true` when we add our first inferred statement. If the value is `false` we guarantee that there are no inferred statements in the MemorySailStore. If it is `true` then an inferred statement was added at some point, but we make no guarantees regarding if there still are inferred statements or if they are in the current snapshot.The purpose of this variable is to optimize read operations that only read inferred statements when there are no inferred statements.
-
currentSnapshot
private volatile int currentSnapshotIdentifies the current snapshot. -
snapshotMonitor
-
namespaceStore
Store for namespace prefix info. -
txnLockManager
Lock manager used to prevent concurrent writes. -
snapshotCleanupThread
Cleanup thread that removes deprecated statements when no other threads are accessing this list. SeeescheduleSnapshotCleanup(). -
snapshotCleanupThreadLockObject
Lock object used to synchronize concurrent access tosnapshotCleanupThread.
-
-
Constructor Details
-
MemorySailStore
public MemorySailStore(boolean debug)
-
-
Method Details
-
getValueFactory
Description copied from interface:SailStoreTheValueFactorythat should be used in association with this.- Specified by:
getValueFactoryin interfaceSailStore- Returns:
- this object's
ValueFactory
-
close
public void close()Description copied from interface:SailClosableCloses this resource, relinquishing any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSailClosable
-
invalidateCache
private void invalidateCache() -
getEvaluationStatistics
Description copied from interface:SailStoreUsed bySailSourceConnectionto determine query join order.- Specified by:
getEvaluationStatisticsin interfaceSailStore- Returns:
- a
EvaluationStatisticsthat is aware of the data distribution of thisSailStore.
-
getExplicitSailSource
- Specified by:
getExplicitSailSourcein interfaceSailStore- Returns:
SailSourceof only explicit statements
-
getInferredSailSource
- Specified by:
getInferredSailSourcein interfaceSailStore- Returns:
SailSourceof only inferred statements
-
createStatementIterator
private CloseableIteration<MemStatement, SailException> createStatementIterator(Resource subj, IRI pred, Value obj, Boolean explicit, int snapshot, Resource... contexts) throws InterruptedException Creates a StatementIterator that contains the statements matching the specified pattern of subject, predicate, object, context. Inferred statements are excluded when explicitOnly is set to true . Statements from the null context are excluded when namedContextsOnly is set to true. The returned StatementIterator will assume the specified read mode.- Throws:
InterruptedException
-
getMemStatementIterator
private CloseableIteration<MemStatement, SailException> getMemStatementIterator(MemResource subj, MemIRI pred, MemValue obj, Boolean explicit, int snapshot, MemResource[] memContexts, MemStatementList statementList) throws InterruptedException - Throws:
InterruptedException
-
getSmallestStatementList
-
createTripleIterator
private CloseableIteration<MemTriple, SailException> createTripleIterator(Resource subj, IRI pred, Value obj, int snapshot) throws InterruptedException Creates a TripleIterator that contains the triples matching the specified pattern of subject, predicate, object, context.- Throws:
InterruptedException
-
cleanSnapshots
Removes statements from old snapshots from the main statement list and resets the snapshot to 1 for the rest of the statements.- Throws:
InterruptedException
-
prioritiseSnapshotCleaningIfLowOnMemory
private boolean prioritiseSnapshotCleaningIfLowOnMemory(boolean prioritiseCleaning) -
memoryIsLow
private static boolean memoryIsLow(long freeToAllocateMemory) -
getFreeToAllocateMemory
private long getFreeToAllocateMemory() -
scheduleSnapshotCleanup
protected void scheduleSnapshotCleanup() -
convertToSailException
-