Class ValueStoreWAL
java.lang.Object
org.eclipse.rdf4j.sail.nativerdf.wal.ValueStoreWAL
- All Implemented Interfaces:
AutoCloseable
Write-ahead log (WAL) for the ValueStore. The WAL records minted values in append-only segments so they can be
recovered or searched independently from the on-disk ValueStore files. This class is thread-safe for concurrent
producers and uses a background writer thread to serialize and fsync according to the configured
ValueStoreWalConfig.SyncPolicy.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidawaitDurable(long lsn) Block until the given LSN is durably forced to disk according to the configured sync policy.voidclose()config()getQueue()booleanReturnstrueif WAL segments were already present in the directory when this WAL was opened.booleanisClosed()Returnstrueonceclose()has been invoked and the writer thread has terminated.longlogMint(int id, ValueStoreWalValueKind kind, String lexical, String datatype, String language, int hash) Append a minted value record to the WAL.static ValueStoreWALopen(ValueStoreWalConfig config) Open a ValueStore WAL for the provided configuration.voidPurge all WAL segments from the WAL directory.
-
Field Details
-
NO_LSN
public static final long NO_LSN- See Also:
-
MAX_FRAME_BYTES
public static final int MAX_FRAME_BYTES- See Also:
-
-
Method Details
-
getQueue
-
open
Open a ValueStore WAL for the provided configuration. The WAL directory is created if it does not already exist. If existing segments are detected, the next LSN is seeded from the last valid record to ensure monotonicity across restarts.- Throws:
IOException
-
config
-
logMint
public long logMint(int id, ValueStoreWalValueKind kind, String lexical, String datatype, String language, int hash) throws IOException Append a minted value record to the WAL.- Parameters:
id- the ValueStore internal idkind- the kind of value (IRI, BNODE, LITERAL, NAMESPACE)lexical- the lexical form (may be empty but never null)datatype- the datatype IRI string for literals, otherwise emptylanguage- the language tag for literals, otherwise emptyhash- a hash of the underlying serialized value- Returns:
- the log sequence number (LSN) assigned to the record
- Throws:
IOException
-
awaitDurable
Block until the given LSN is durably forced to disk according to the configured sync policy. This is a no-op whenlsn <= NO_LSNor after the WAL is closed.- Throws:
InterruptedExceptionIOException
-
hasInitialSegments
public boolean hasInitialSegments()Returnstrueif WAL segments were already present in the directory when this WAL was opened. -
isClosed
public boolean isClosed()Returnstrueonceclose()has been invoked and the writer thread has terminated. -
purgeAllSegments
Purge all WAL segments from the WAL directory. Coordinated with the writer thread to close the current segment before deletion and reset to a fresh segment after purge completes.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-