private PrepareLogRecord GetPrepareInternal(ITransactionFileReader reader, long pos) { var result = reader.TryReadAt(pos); if (!result.Success) { throw new InvalidOperationException("Couldn't read record which is supposed to be in file."); } Debug.Assert(result.LogRecord.RecordType == LogRecordType.Prepare, "Incorrect type of log record, expected Prepare record."); return((PrepareLogRecord)result.LogRecord); }
private static PrepareLogRecord ReadPrepareInternal(ITransactionFileReader reader, long pos) { var result = reader.TryReadAt(pos); // TODO AN need to change this to account for possibly scavenged records, shouldn't throw exception, // TODO AN rather return meaningful result if (!result.Success) { throw new InvalidOperationException("Couldn't read record which is supposed to be in file."); } Debug.Assert(result.LogRecord.RecordType == LogRecordType.Prepare, "Incorrect type of log record, expected Prepare record."); return((PrepareLogRecord)result.LogRecord); }
private EpochRecord ReadEpochAt(ITransactionFileReader reader, long epochPos) { var result = reader.TryReadAt(epochPos); if (!result.Success) { throw new Exception($"Could not find Epoch record at LogPosition {epochPos}."); } if (result.LogRecord.RecordType != LogRecordType.System) { throw new Exception($"LogRecord is not SystemLogRecord: {result.LogRecord}."); } var sysRec = (SystemLogRecord)result.LogRecord; if (sysRec.SystemRecordType != SystemRecordType.Epoch) { throw new Exception($"SystemLogRecord is not of Epoch sub-type: {result.LogRecord}."); } return(sysRec.GetEpochRecord()); }
private static PrepareResult ReadPrepareInternal(ITransactionFileReader reader, long pos) { RecordReadResult result = reader.TryReadAt(pos); if (!result.Success) return new PrepareResult(false, null); Debug.Assert(result.LogRecord.RecordType == LogRecordType.Prepare, "Incorrect type of log record, expected Prepare record."); return new PrepareResult(true, (PrepareLogRecord)result.LogRecord); }
public RecordReadResult TryReadAt(long position) { return(Reader.TryReadAt(position)); }