Class MemorySailStore

    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
      • RUNTIME

        private static final java.lang.Runtime RUNTIME
      • MAX_MEMORY

        private static final long MAX_MEMORY
      • CLEANUP_MAX_MEMORY_THRESHOLD

        private static final int CLEANUP_MAX_MEMORY_THRESHOLD
        See Also:
        Constant Field Values
      • CLEANUP_MINIMUM_FREE_MEMORY

        private static final int CLEANUP_MINIMUM_FREE_MEMORY
        See Also:
        Constant Field Values
      • CLEANUP_MINIMUM_FREE_MEMORY_RATIO

        private static final double CLEANUP_MINIMUM_FREE_MEMORY_RATIO
        See Also:
        Constant Field Values
      • EMPTY_CONTEXT

        public static final MemResource[] EMPTY_CONTEXT
      • NULL_CONTEXT

        public static final MemResource[] NULL_CONTEXT
      • valueFactory

        private final MemValueFactory valueFactory
        Factory/cache for MemValue objects.
      • statements

        private final MemStatementList statements
        List containing all available statements.
      • mayHaveInferred

        private volatile boolean mayHaveInferred
        This 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 currentSnapshot
        Identifies the current snapshot.
      • namespaceStore

        private final MemNamespaceStore namespaceStore
        Store for namespace prefix info.
      • txnLockManager

        private final java.util.concurrent.locks.ReentrantLock txnLockManager
        Lock manager used to prevent concurrent writes.
      • snapshotCleanupThread

        private volatile java.lang.Thread snapshotCleanupThread
        Cleanup thread that removes deprecated statements when no other threads are accessing this list. Seee scheduleSnapshotCleanup().
      • snapshotCleanupThreadLockObject

        private final java.lang.Object snapshotCleanupThreadLockObject
        Lock object used to synchronize concurrent access to snapshotCleanupThread.
    • Constructor Detail

      • MemorySailStore

        public MemorySailStore​(boolean debug)
    • Method Detail

      • close

        public void close()
        Description copied from interface: SailClosable
        Closes this resource, relinquishing any underlying resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface SailClosable
      • invalidateCache

        private void invalidateCache()
      • createStatementIterator

        private CloseableIteration<MemStatement,​SailException> createStatementIterator​(Resource subj,
                                                                                             IRI pred,
                                                                                             Value obj,
                                                                                             java.lang.Boolean explicit,
                                                                                             int snapshot,
                                                                                             Resource... contexts)
                                                                                      throws java.lang.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:
        java.lang.InterruptedException
      • createTripleIterator

        private CloseableIteration<MemTriple,​SailException> createTripleIterator​(Resource subj,
                                                                                       IRI pred,
                                                                                       Value obj,
                                                                                       int snapshot)
                                                                                throws java.lang.InterruptedException
        Creates a TripleIterator that contains the triples matching the specified pattern of subject, predicate, object, context.
        Throws:
        java.lang.InterruptedException
      • cleanSnapshots

        protected void cleanSnapshots()
                               throws java.lang.InterruptedException
        Removes statements from old snapshots from the main statement list and resets the snapshot to 1 for the rest of the statements.
        Throws:
        java.lang.InterruptedException
      • prioritiseSnapshotCleaningIfLowOnMemory

        private boolean prioritiseSnapshotCleaningIfLowOnMemory​(boolean prioritiseCleaning)
      • memoryIsLow

        private static boolean memoryIsLow​(long freeToAllocateMemory)
      • getFreeToAllocateMemory

        private long getFreeToAllocateMemory()
      • scheduleSnapshotCleanup

        protected void scheduleSnapshotCleanup()
      • convertToSailException

        private SailException convertToSailException​(java.lang.InterruptedException e)