Example #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);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.util.List<org.neo4j.kernel.impl.transaction.log.entry.CheckPoint> find(long version) throws java.io.IOException
            public virtual IList <CheckPoint> Find(long version)
            {
                IList <CheckPoint> checkPoints = new List <CheckPoint>();

                for ( ; version >= INITIAL_LOG_VERSION && LogFiles.versionExists(version); version--)
                {
                    LogVersionedStoreChannel             channel = LogFiles.openForVersion(version);
                    ReadableClosablePositionAwareChannel recoveredDataChannel = new ReadAheadLogChannel(channel);

                    using (LogEntryCursor cursor = new LogEntryCursor(LogEntryReader, recoveredDataChannel))
                    {
                        while (cursor.Next())
                        {
                            LogEntry entry = cursor.Get();
                            if (entry is CheckPoint)
                            {
                                checkPoints.Add(entry.As());
                            }
                        }
                    }
                }
                return(checkPoints);
            }