当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.GetTransactionPages方法代码示例

本文整理汇总了C#中Transaction.GetTransactionPages方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.GetTransactionPages方法的具体用法?C# Transaction.GetTransactionPages怎么用?C# Transaction.GetTransactionPages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction.GetTransactionPages方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdatePageTranslationTable

	    private void UpdatePageTranslationTable(Transaction tx, HashSet<PagePosition> unused, Dictionary<long, PagePosition> ptt)
	    {
			foreach (var freedPageNumber in tx.GetFreedPagesNumbers())
			{
				// set freed page marker - note it can be overwritten below by later allocation

				ptt[freedPageNumber] = new PagePosition
				{
					ScratchPos = -1,
					ScratchNumber = -1,
					TransactionId = tx.Id,
					JournalNumber = Number,
					IsFreedPageMarker = true
				};
			}

            var txPages = tx.GetTransactionPages();
            foreach ( var txPage in txPages )
            {
                var scratchPage = tx.Environment.ScratchBufferPool.ReadPage(txPage.ScratchFileNumber, txPage.PositionInScratchBuffer);
                var pageNumber = scratchPage.PageNumber;

                PagePosition value;
                if (_pageTranslationTable.TryGetValue(tx, pageNumber, out value))
                {
                    value.UnusedInPTT = true;
                    unused.Add(value);
                }

                PagePosition pagePosition;
                if (ptt.TryGetValue(pageNumber, out pagePosition) && pagePosition.IsFreedPageMarker == false)
                    unused.Add(pagePosition);

                ptt[pageNumber] = new PagePosition
                {
                    ScratchPos = txPage.PositionInScratchBuffer,
                    ScratchNumber = txPage.ScratchFileNumber,
                    TransactionId = tx.Id,
                    JournalNumber = Number
                };
            }

		    foreach (var freedPage in tx.GetUnusedScratchPages())
		    {
			    unused.Add(new PagePosition
			    {
				    ScratchPos = freedPage.PositionInScratchBuffer,
					ScratchNumber = freedPage.ScratchFileNumber,
				    TransactionId = tx.Id,
				    JournalNumber = Number
			    });
		    }
	    }
开发者ID:jrusbatch,项目名称:ravendb,代码行数:53,代码来源:JournalFile.cs

示例2: CompressPages

		private IntPtr[] CompressPages(Transaction tx, int numberOfPages, IVirtualPager compressionPager,uint previousTransactionCrc)
		{
			// numberOfPages include the tx header page, which we don't compress
			var dataPagesCount = numberOfPages - 1;
			var sizeInBytes = dataPagesCount * AbstractPager.PageSize;
			var outputBuffer = LZ4.MaximumOutputLength(sizeInBytes);
			var outputBufferInPages = outputBuffer / AbstractPager.PageSize +
									  (outputBuffer % AbstractPager.PageSize == 0 ? 0 : 1);
			var pagesRequired = (dataPagesCount + outputBufferInPages);

			compressionPager.EnsureContinuous(tx, 0, pagesRequired);
			var tempBuffer = compressionPager.AcquirePagePointer(0);
			var compressionBuffer = compressionPager.AcquirePagePointer(dataPagesCount);

			var write = tempBuffer;
			var txPages = tx.GetTransactionPages();

            foreach( var txPage in txPages )
            {
                var scratchPage = tx.Environment.ScratchBufferPool.AcquirePagePointer(txPage.ScratchFileNumber, txPage.PositionInScratchBuffer);
                var count = txPage.NumberOfPages * AbstractPager.PageSize;
                MemoryUtils.BulkCopy(write, scratchPage, count);
                write += count;
            }

			var len = DoCompression(tempBuffer, compressionBuffer, sizeInBytes, outputBuffer);
		    var remainder = len % AbstractPager.PageSize;
            var compressedPages = (len / AbstractPager.PageSize) + (remainder == 0 ? 0 : 1);

		    if (remainder != 0)
		    {
                // zero the remainder of the page
				StdLib.memset(compressionBuffer + len, 0, remainder);
		    }

			var pages = new IntPtr[compressedPages + 1];

            var txHeaderPage = tx.GetTransactionHeaderPage();
            var txHeaderBase = tx.Environment.ScratchBufferPool.AcquirePagePointer(txHeaderPage.ScratchFileNumber, txHeaderPage.PositionInScratchBuffer);
			var txHeader = (TransactionHeader*)txHeaderBase;

			txHeader->Compressed = true;
			txHeader->CompressedSize = len;
			txHeader->UncompressedSize = sizeInBytes;
			txHeader->PreviousTransactionCrc = previousTransactionCrc;

			pages[0] = new IntPtr(txHeaderBase);
			for (int index = 0; index < compressedPages; index++)
			{
				pages[index + 1] = new IntPtr(compressionBuffer + (index * AbstractPager.PageSize));
			}

			txHeader->Crc = Crc.Value(compressionBuffer, 0, compressedPages * AbstractPager.PageSize);

			return pages;
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:56,代码来源:WriteAheadJournal.cs

示例3: Write

        public void Write(Transaction tx, byte*[] pages)
        {
            var txPages = tx.GetTransactionPages();

            var ptt = new Dictionary<long, PagePosition>();
            var unused = new HashSet<PagePosition>();
            var writePagePos = _writePage;

            UpdatePageTranslationTable(tx, txPages, unused, ptt);

            lock (_locker)
            {
                _writePage += pages.Length;
                _pageTranslationTable.SetItems(tx, ptt);
                _unusedPages.AddRange(unused);
            }

            _journalWriter.WriteGather(writePagePos * AbstractPager.PageSize, pages);
        }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:19,代码来源:JournalFile.cs

示例4: CompressPages

		private byte*[] CompressPages(Transaction tx, int numberOfPages, IVirtualPager compressionPager)
		{
			// numberOfPages include the tx header page, which we don't compress
			var dataPagesCount = numberOfPages - 1;
			var sizeInBytes = dataPagesCount * AbstractPager.PageSize;
			var outputBuffer = LZ4.MaximumOutputLength(sizeInBytes);
			var outputBufferInPages = outputBuffer / AbstractPager.PageSize +
									  (outputBuffer % AbstractPager.PageSize == 0 ? 0 : 1);
			var pagesRequired = (dataPagesCount + outputBufferInPages);

			compressionPager.EnsureContinuous(tx, 0, pagesRequired);
			var tempBuffer = compressionPager.AcquirePagePointer(0);
			var compressionBuffer = compressionPager.AcquirePagePointer(dataPagesCount);

			var write = tempBuffer;
			var txPages = tx.GetTransactionPages();

			for (int index = 1; index < txPages.Count; index++)
			{
				var txPage = txPages[index];
				var scratchPage = tx.Environment.ScratchBufferPool.AcquirePagePointer(txPage.PositionInScratchBuffer);
				var count = txPage.NumberOfPages * AbstractPager.PageSize;
				NativeMethods.memcpy(write, scratchPage, count);
				write += count;
			}

			var len = DoCompression(tempBuffer, compressionBuffer, sizeInBytes, outputBuffer);
			var compressedPages = (len / AbstractPager.PageSize) + (len % AbstractPager.PageSize == 0 ? 0 : 1);

			var pages = new byte*[compressedPages + 1];

			var txHeaderBase = tx.Environment.ScratchBufferPool.AcquirePagePointer(txPages[0].PositionInScratchBuffer);
			var txHeader = (TransactionHeader*)txHeaderBase;

			txHeader->Compressed = true;
			txHeader->CompressedSize = len;
			txHeader->UncompressedSize = sizeInBytes;

			pages[0] = txHeaderBase;
			for (int index = 0; index < compressedPages; index++)
			{
				pages[index + 1] = compressionBuffer + (index * AbstractPager.PageSize);
			}

			txHeader->Crc = Crc.Value(compressionBuffer, 0, compressedPages * AbstractPager.PageSize);

			return pages;
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:48,代码来源:WriteAheadJournal.cs

示例5: UpdatePageTranslationTable

	    private void UpdatePageTranslationTable(Transaction tx, HashSet<PagePosition> unused, Dictionary<long, PagePosition> ptt)
	    {
		    var txPages = tx.GetTransactionPages();

			foreach (var freedPageNumber in tx.GetFreedPagesNumbers())
			{
				// set freed page marker - note it can be overwritten below by later allocation

				ptt[freedPageNumber] = new PagePosition
				{
					ScratchPos = -1,
					JournalPos = -1,
					TransactionId = tx.Id,
					JournalNumber = Number,
					IsFreedPageMarker = true
				};
			}

		    for (int index = 1; index < txPages.Count; index++)
		    {
			    var txPage = txPages[index];
			    var scratchPage = tx.Environment.ScratchBufferPool.ReadPage(txPage.PositionInScratchBuffer);
			    var pageNumber = scratchPage.PageNumber;

				PagePosition value;
				if (_pageTranslationTable.TryGetValue(tx, pageNumber, out value))
					unused.Add(value);

				PagePosition pagePosition;
				if (ptt.TryGetValue(pageNumber, out pagePosition) && pagePosition.IsFreedPageMarker == false)
					unused.Add(pagePosition);

				ptt[pageNumber] = new PagePosition
				{
					ScratchPos = txPage.PositionInScratchBuffer,
					JournalPos = -1, // needed only during recovery and calculated there
					TransactionId = tx.Id,
					JournalNumber = Number
				};
			}

		    foreach (var freedPage in tx.GetUnusedScratchPages())
		    {
			    unused.Add(new PagePosition
			    {
				    ScratchPos = freedPage.PositionInScratchBuffer,
				    JournalPos = -1, // needed only during recovery and calculated there
				    TransactionId = tx.Id,
				    JournalNumber = Number
			    });
		    }
	    }
开发者ID:cocytus,项目名称:ravendb,代码行数:52,代码来源:JournalFile.cs


注:本文中的Transaction.GetTransactionPages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。