Class MemStatementList
- java.lang.Object
-
- org.eclipse.rdf4j.sail.memory.model.MemStatementList
-
public class MemStatementList extends java.lang.ObjectA dedicated data structure for storing MemStatement objects, offering operations optimized for their use in the memory Sail.
-
-
Field Summary
Fields Modifier and Type Field Description private static MemStatement[]EMPTY_ARRAYprivate static java.lang.invoke.VarHandleGUARANTEED_LAST_INDEX_IN_USEprivate intguaranteedLastIndexInUseprivate static java.lang.invoke.VarHandlePREVIOUSLY_INSERTED_INDEXprivate intpreviouslyInsertedIndexprivate static java.lang.invoke.VarHandlePRIORITISE_CLEANUPprivate booleanprioritiseCleanupprivate java.util.concurrent.atomic.AtomicReference<java.lang.Thread>prioritisedThreadprivate intsizeprivate static java.lang.invoke.VarHandleSIZEprivate MemStatement[]statementsprivate static java.lang.invoke.VarHandleSTATEMENTS(package private) static java.lang.invoke.VarHandleSTATEMENTS_ARRAY
-
Constructor Summary
Constructors Constructor Description MemStatementList()MemStatementList(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(MemStatement st)voidcleanSnapshots(int currentSnapshot)voidclear()MemStatementgetExact(MemResource subject, MemIRI predicate, MemValue object, MemResource context, int snapshot)Iterates through this list and returns the statement that exactly matches the provided arguments.intgetGuaranteedLastIndexInUse()(package private) intgetRealSizeForTesting()MemStatement[]getStatements()An internal method to retrieve the inner array that stores the statements.private MemStatement[]getStatementsWithoutInterrupt()booleanisEmpty()private booleanoptimisticInnerRemove(MemStatement toRemove, MemStatement[] statements, int i)booleanoptimisticRemove(MemStatement st)booleanoptimisticRemove(MemStatement st, int index)voidsetPrioritiseCleanup(boolean prioritiseCleanup)intsize()private voidupdateGuaranteedLastIndexInUse(int newValue)(package private) booleanverifySizeForTesting()
-
-
-
Field Detail
-
EMPTY_ARRAY
private static final MemStatement[] EMPTY_ARRAY
-
statements
private volatile MemStatement[] statements
-
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
-
-
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()
-
-