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;
            }
        }
	    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);
	    }
Exemple #3
0
            public OutstandingWrite(WriteBatch batch, TransactionMergingWriter transactionMergingWriter)
            {
                _transactionMergingWriter = transactionMergingWriter;
                Batch = batch;
                Size  = batch.Size();

                if (transactionMergingWriter._eventsBuffer.TryDequeue(out _completed) == false)
                {
                    _completed = new ManualResetEventSlim();
                }
                _completed.Reset();
            }
			public OutstandingWrite(WriteBatch batch, TransactionMergingWriter transactionMergingWriter)
			{
				_batch = batch;
				_transactionMergingWriter = transactionMergingWriter;

				_operations = CreateOperations(batch);
				Size = batch.Size();

				if (transactionMergingWriter._eventsBuffer.TryDequeue(out _completed) == false)
					_completed = new ManualResetEventSlim();
				_completed.Reset();
			}
        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, _cancellationTokenSource.Token);

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