예제 #1
0
        public StorageEnvironment(StorageEnvironmentOptions options, string debugJournalName)
            : this(options)
        {
            DebugJournal = new DebugJournal(debugJournalName, this);

            if (Writer != null)
            {
                Writer.Dispose();
            }
            Writer = new TransactionMergingWriter(this, _cancellationTokenSource.Token, DebugJournal);
        }
예제 #2
0
        public unsafe StorageEnvironment(StorageEnvironmentOptions options)
        {
            try
            {
                TemporaryPage      = new TemporaryPage();
                _options           = options;
                _dataPager         = options.DataPager;
                _freeSpaceHandling = new FreeSpaceHandling(this);
                _sliceComparer     = NativeMethods.memcmp;
                _headerAccessor    = new HeaderAccessor(this);
                var isNew = _headerAccessor.Initialize();

                _scratchBufferPool = new ScratchBufferPool(this);

                _journal = new WriteAheadJournal(this);

                if (isNew)
                {
                    CreateNewDatabase();
                }
                else // existing db, let us load it
                {
                    LoadExistingDatabase();
                }

                State.FreeSpaceRoot.Name = Constants.FreeSpaceTreeName;
                State.Root.Name          = Constants.RootTreeName;

                Writer = new TransactionMergingWriter(this);

                if (_options.ManualFlushing == false)
                {
                    _flushingTask = FlushWritesToDataFileAsync();
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
예제 #3
0
        public StorageEnvironment(StorageEnvironmentOptions options)
        {
            try
            {
                _options           = options;
                _dataPager         = options.DataPager;
                _freeSpaceHandling = new FreeSpaceHandling();
                _headerAccessor    = new HeaderAccessor(this);
                var isNew = _headerAccessor.Initialize();

                _scratchBufferPool = new ScratchBufferPool(this);

                _journal = new WriteAheadJournal(this);

                if (isNew)
                {
                    CreateNewDatabase();
                }
                else // existing db, let us load it
                {
                    LoadExistingDatabase();
                }

                Writer = new TransactionMergingWriter(this, _cancellationTokenSource.Token);

                if (_options.ManualFlushing == false)
                {
                    _flushingTask = FlushWritesToDataFileAsync();
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }