Class ValueStoreWAL

java.lang.Object
org.eclipse.rdf4j.sail.nativerdf.wal.ValueStoreWAL
All Implemented Interfaces:
AutoCloseable

public final class ValueStoreWAL extends Object implements 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 Details

  • Method Details

    • getQueue

      public BlockingQueue<ValueStoreWalRecord> getQueue()
    • open

      public static ValueStoreWAL open(ValueStoreWalConfig config) throws IOException
      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

      public ValueStoreWalConfig 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 id
      kind - 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 empty
      language - the language tag for literals, otherwise empty
      hash - a hash of the underlying serialized value
      Returns:
      the log sequence number (LSN) assigned to the record
      Throws:
      IOException
    • awaitDurable

      public void awaitDurable(long lsn) throws InterruptedException, IOException
      Block until the given LSN is durably forced to disk according to the configured sync policy. This is a no-op when lsn <= NO_LSN or after the WAL is closed.
      Throws:
      InterruptedException
      IOException
    • hasInitialSegments

      public boolean hasInitialSegments()
      Returns true if WAL segments were already present in the directory when this WAL was opened.
    • isClosed

      public boolean isClosed()
      Returns true once close() has been invoked and the writer thread has terminated.
    • purgeAllSegments

      public void purgeAllSegments() throws IOException
      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

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException