JournalFile() public static method

public static JournalFile ( string baseName, int version ) : string
baseName string
version int
return string
Example #1
0
        public JournaledMemTable(string baseFileName, int version)
        {
            _baseFileName = baseFileName;
            _version      = version;
            _memTable     = new MemTable();

            // If the journal exists from a previous run, then load its data into the memtable
            string journalFile = Config.JournalFile(baseFileName, version);

            if (File.Exists(journalFile))
            {
                var journalReader = new JournalReader(baseFileName, version);
                try {
                    foreach (var pair in journalReader.Enumerate())
                    {
                        _memTable.Add(pair.Key, pair.Value);
                    }
                } finally {
                    journalReader.Close();
                }
                _journal = new JournalWriter(baseFileName, version, true);
            }
            else
            {
                _journal = new JournalWriter(baseFileName, version, false);
            }
        }
Example #2
0
        public JournalWriter(string baseFileName, int version, bool append)
        {
            _fileName = Config.JournalFile(baseFileName, version);
            FileMode fileMode = append ? FileMode.Append : FileMode.Create;

            _writer = new BinaryWriter(new FileStream(_fileName, fileMode, FileAccess.Write, FileShare.None, 1024, FileOptions.SequentialScan));
        }
Example #3
0
#pragma warning restore 420

        private void CheckForIncompleteJournalRotation(string baseFileName, int currentMemTableVersion)
        {
            int previousMemTableVersion = currentMemTableVersion - 1;

            // Is there a left-over journal from a previous rotation that was aborted while in rotation.
            if (File.Exists(Config.JournalFile(baseFileName, previousMemTableVersion)))
            {
                var memTable = new JournaledMemTable(baseFileName, previousMemTableVersion);
                memTable.WriteToSortedBlockTable(_manifest);
                memTable.Close();
            }
        }
Example #4
0
 public JournalReader(string baseFileName, int version)
 {
     _fileName = Config.JournalFile(baseFileName, version);
     _reader   = new BinaryReader(new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.None, 1024, false));
 }