Class MemStatementList
- java.lang.Object
-
- org.eclipse.rdf4j.sail.memory.model.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 Summary
Fields Modifier and Type Field Description private static MemStatement[]
EMPTY_ARRAY
private static java.lang.invoke.VarHandle
GUARANTEED_LAST_INDEX_IN_USE
private int
guaranteedLastIndexInUse
private static java.lang.invoke.VarHandle
PREVIOUSLY_INSERTED_INDEX
private int
previouslyInsertedIndex
private static java.lang.invoke.VarHandle
PRIORITISE_CLEANUP
private boolean
prioritiseCleanup
private java.util.concurrent.atomic.AtomicReference<java.lang.Thread>
prioritisedThread
private int
size
private static java.lang.invoke.VarHandle
SIZE
private MemStatement[]
statements
private static java.lang.invoke.VarHandle
STATEMENTS
(package private) static java.lang.invoke.VarHandle
STATEMENTS_ARRAY
-
Constructor Summary
Constructors Constructor Description MemStatementList()
MemStatementList(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(MemStatement st)
void
cleanSnapshots(int currentSnapshot)
void
clear()
MemStatement
getExact(MemResource subject, MemIRI predicate, MemValue object, MemResource context, int snapshot)
Iterates through this list and returns the statement that exactly matches the provided arguments.int
getGuaranteedLastIndexInUse()
(package private) int
getRealSizeForTesting()
MemStatement[]
getStatements()
An internal method to retrieve the inner array that stores the statements.private MemStatement[]
getStatementsWithoutInterrupt()
boolean
isEmpty()
private boolean
optimisticInnerRemove(MemStatement toRemove, MemStatement[] statements, int i)
boolean
optimisticRemove(MemStatement st)
boolean
optimisticRemove(MemStatement st, int index)
void
setPrioritiseCleanup(boolean prioritiseCleanup)
int
size()
private void
updateGuaranteedLastIndexInUse(int newValue)
(package private) boolean
verifySizeForTesting()
-
-
-
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()
-
-