LogReader provides transaction log replay and iteration for a specific
Connection. It can apply a stored log to a database or stream log records to application
callbacks in file-based and pipe-based transaction logging scenarios.
public class LogReader
{
// ===== NESTED STRUCT: LogInfo =====
public struct LogInfo
{
public long StartTransCounter;
public long StopTransCounter;
public long StoredTransactions;
public ushort DiskPageSize;
public ushort PageSize;
public long LogSize;
public String[] Labels;
public bool CRC;
public bool Aligned;
public bool DictionaryCompat;
public bool TransactionApplyCompat;
public bool TransactionAppendCompat;
public bool NotCorrupted;
public bool Iteratable;
}
// ===== INTERFACE: ILogIterator =====
public interface ILogIterator
{
void Create(Object obj);
void Update(Object obj);
void Delete(Object obj);
void DeleteAll(Type type);
void EndOfTransaction();
}
// ===== CONSTRUCTOR =====
public LogReader(Connection con, string filePath);
// ===== REPLAY METHODS =====
public void Apply(int labelId);
public void Apply();
// ===== ITERATION METHODS =====
public void IterateFile(ILogIterator iterator, long memSize, IntPtr hint);
public void IteratePipe(ILogIterator iterator, long memSize, IntPtr hint);
public void IteratePipe(ILogIterator iterator, long memSize, IntPtr hint, Database.Device pipe);
public void StopPipeIteration();
// ===== INFORMATION METHODS =====
public LogInfo GetInfo();
// ===== INTERNAL CALLBACK (do not call) =====
public int InvokeCallback(ILogIterator iterator, int operation, int classId, IntPtr handle);
}
LogInfo struct (LogReader)Start/StopTransCounter), storage stats (StoredTransactions, LogSize), format details (DiskPageSize, CRC, Aligned), compatibility flags (DictionaryCompat, TransactionApply/AppendCompat), integrity status (NotCorrupted), and replay capability (Iteratable).ILogIterator interfaceCreate, Update, Delete, DeleteAll (class-level deletion), and EndOfTransaction (called when RT_OPTION_MARK_LAST_OBJ is set).LogReader(Connection, string)
filePath can be null.Apply(int labelId)
LogWriter.SetLabel() to create recovery points.Apply()
Apply(-1).IterateFile(ILogIterator, long, IntPtr)
ILogIterator. memSize specifies the size of the temporary in-memory database used to reconstruct objects, and hint is an optional native/shared-memory hint used in some runtime configurations.IteratePipe(ILogIterator, long, IntPtr[, Database.Device])
Database.Device when the pipe buffer device is managed explicitly by the application.StopPipeIteration()
IteratePipe(). Use to gracefully terminate real-time log consumption.GetInfo()
LogInfo structure. Use to verify compatibility, integrity, and available recovery points before replay.InvokeCallback(...) (internal)ILogIterator. Applications should never call this method directly.Apply(), verify LogInfo.TransactionApplyCompat and DictionaryCompat are true. Mismatched schema metadata or an incompatible log format can prevent successful replay.memSize parameter for iteration methods must be large enough to hold the largest object in the log. Insufficient memory causes iteration to fail with out-of-memory errors.LogWriter.SetLabel() to mark recovery points (e.g., after backups). During recovery, call LogReader.Apply(labelId) to replay only transactions up to the desired checkpoint, minimizing recovery time.LogFlags.Pipe or LogFlags.DynamicPipe, and the reader consumes records with IteratePipe(). In dynamic-pipe scenarios the application can attach a pipe buffer device and pass it explicitly to IteratePipe(..., Database.Device).ILogIterator callback throws DatabaseError, InvokeCallback returns its error code to the native layer and iteration stops. Application callback code should therefore use predictable error handling.Database and Connection. Use a connection that belongs to a database opened with the matching class dictionary and runtime configuration.LogReader instances are not thread-safe. Use separate reader instances per thread. The underlying connection should not be used concurrently for other database operations during log replay.