コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean next() throws java.io.IOException
        public override bool Next()
        {
            // Clear the previous deserialized transaction so that it won't have to be kept in heap while deserializing
            // the next one. Could be problematic if both are really big.
            _current = null;

            while (true)
            {
                if (!_logEntryCursor.next())
                {
                    return(false);
                }

                LogEntry entry = _logEntryCursor.get();
                if (entry is CheckPoint)
                {
                    // this is a good position anyhow
                    _channel.getCurrentPosition(_lastGoodPositionMarker);
                    continue;
                }

                Debug.Assert(entry is LogEntryStart, "Expected Start entry, read " + entry + " instead");
                LogEntryStart  startEntry = entry.As();
                LogEntryCommit commitEntry;

                IList <StorageCommand> entries = new List <StorageCommand>();
                while (true)
                {
                    if (!_logEntryCursor.next())
                    {
                        return(false);
                    }

                    entry = _logEntryCursor.get();
                    if (entry is LogEntryCommit)
                    {
                        commitEntry = entry.As();
                        break;
                    }

                    LogEntryCommand command = entry.As();
                    entries.Add(command.Command);
                }

                PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(entries);
                transaction.SetHeader(startEntry.AdditionalHeader, startEntry.MasterId, startEntry.LocalId, startEntry.TimeWritten, startEntry.LastCommittedTxWhenTransactionStarted, commitEntry.TimeWritten, -1);
                _current = new CommittedTransactionRepresentation(startEntry, transaction, commitEntry);
                _channel.getCurrentPosition(_lastGoodPositionMarker);
                return(true);
            }
        }