本文整理汇总了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
});
}
}
示例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;
}
示例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);
}
示例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;
}
示例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
});
}
}