Class MemStatementList


  • public class MemStatementList
    extends java.lang.Object
    A dedicated data structure for storing MemStatement objects, offering operations optimized for their use in the memory Sail.
    • Field Detail

      • EMPTY_ARRAY

        private static final MemStatement[] EMPTY_ARRAY
      • STATEMENTS

        private static final java.lang.invoke.VarHandle STATEMENTS
      • STATEMENTS_ARRAY

        static final java.lang.invoke.VarHandle STATEMENTS_ARRAY
      • size

        private volatile int size
      • SIZE

        private static final java.lang.invoke.VarHandle SIZE
      • previouslyInsertedIndex

        private volatile int previouslyInsertedIndex
      • PREVIOUSLY_INSERTED_INDEX

        private static final java.lang.invoke.VarHandle PREVIOUSLY_INSERTED_INDEX
      • guaranteedLastIndexInUse

        private volatile int guaranteedLastIndexInUse
      • GUARANTEED_LAST_INDEX_IN_USE

        private static final java.lang.invoke.VarHandle GUARANTEED_LAST_INDEX_IN_USE
      • prioritiseCleanup

        private volatile boolean prioritiseCleanup
      • PRIORITISE_CLEANUP

        private static final java.lang.invoke.VarHandle PRIORITISE_CLEANUP
      • prioritisedThread

        private final java.util.concurrent.atomic.AtomicReference<java.lang.Thread> prioritisedThread
    • Constructor Detail

      • MemStatementList

        public MemStatementList()
      • MemStatementList

        public MemStatementList​(int capacity)
    • Method Detail

      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • add

        public void add​(MemStatement st)
                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • updateGuaranteedLastIndexInUse

        private void updateGuaranteedLastIndexInUse​(int newValue)
      • optimisticRemove

        public boolean optimisticRemove​(MemStatement st)
                                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • optimisticRemove

        public boolean optimisticRemove​(MemStatement st,
                                        int index)
                                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • optimisticInnerRemove

        private boolean optimisticInnerRemove​(MemStatement toRemove,
                                              MemStatement[] statements,
                                              int i)
      • clear

        public void clear()
      • cleanSnapshots

        public void cleanSnapshots​(int currentSnapshot)
                            throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • getExact

        public MemStatement getExact​(MemResource subject,
                                     MemIRI predicate,
                                     MemValue object,
                                     MemResource context,
                                     int snapshot)
                              throws java.lang.InterruptedException
        Iterates through this list and returns the statement that exactly matches the provided arguments. The subject, predicate and object should not be null. If the context is null it will match statements with null as their context.
        Parameters:
        subject -
        predicate -
        object -
        context -
        snapshot -
        Returns:
        Throws:
        java.lang.InterruptedException
      • getStatements

        public MemStatement[] getStatements()
                                     throws java.lang.InterruptedException
        An internal method to retrieve the inner array that stores the statements. Useful to reduce the number of volatile reads.
        Returns:
        the underlying array og MemStatements
        Throws:
        java.lang.InterruptedException
      • getStatementsWithoutInterrupt

        private MemStatement[] getStatementsWithoutInterrupt()
      • getGuaranteedLastIndexInUse

        public int getGuaranteedLastIndexInUse()
      • setPrioritiseCleanup

        public void setPrioritiseCleanup​(boolean prioritiseCleanup)
      • verifySizeForTesting

        boolean verifySizeForTesting()
      • getRealSizeForTesting

        int getRealSizeForTesting()