/// <summary> /// write transaction's raw page data into journal. returns write page position /// </summary> public long Write(Transaction tx, byte *[] pages) { var txPages = tx.GetTransactionPages(); var ptt = new Dictionary <long, PagePosition>(); var unused = new HashSet <PagePosition>(); var pageWritePos = _writePage; UpdatePageTranslationTable(tx, txPages, unused, ptt); lock (_locker) { _writePage += pages.Length; _pageTranslationTable.SetItems(tx, ptt); Debug.Assert(!_unusedPages.Any(unused.Contains)); _unusedPages.AddRange(unused); } var position = pageWritePos * AbstractPager.PageSize; _journalWriter.WriteGather(position, pages); return(pageWritePos); }
/// <summary> /// write transaction's raw page data into journal. returns write page position /// </summary> public long Write(LowLevelTransaction tx, IntPtr[] pages, LazyTransactionBuffer lazyTransactionScratch, int uncompressedPageCount) { var ptt = new Dictionary <long, PagePosition>(NumericEqualityComparer.Instance); var unused = new HashSet <PagePosition>(); var pageWritePos = _writePage; UpdatePageTranslationTable(tx, unused, ptt); lock (_locker) { _writePage += pages.Length; _pageTranslationTable.SetItems(tx, ptt); Debug.Assert(!_unusedPages.Any(unused.Contains)); _unusedPages.AddRange(unused); } var position = pageWritePos * tx.Environment.Options.PageSize; if (tx.IsLazyTransaction == false && (lazyTransactionScratch == null || lazyTransactionScratch.HasDataInBuffer() == false)) { _journalWriter.WriteGather(position, pages); } else { if (lazyTransactionScratch == null) { throw new InvalidOperationException("lazyTransactionScratch cannot be null if the transaction is lazy (or a previous one was)"); } lazyTransactionScratch.EnsureSize(_journalWriter.NumberOfAllocatedPages); lazyTransactionScratch.AddToBuffer(position, pages, uncompressedPageCount); // non lazy tx will add itself to the buffer and then flush scratch to journal if (tx.IsLazyTransaction == false || lazyTransactionScratch.NumberOfPages > tx.Environment.ScratchBufferPool.GetAvailablePagesCount() / 2) { lazyTransactionScratch.WriteBufferToFile(this, tx); } else { lazyTransactionScratch.EnsureHasExistingReadTransaction(tx); } } return(pageWritePos); }
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); }
/// <summary> /// write transaction's raw page data into journal. returns write page position /// </summary> public long Write(Transaction tx, IntPtr[] pages) { var ptt = new Dictionary <long, PagePosition>(NumericEqualityComparer.Instance); var unused = new HashSet <PagePosition>(); var pageWritePos = _writePage; UpdatePageTranslationTable(tx, unused, ptt); lock (_locker) { _writePage += pages.Length; _pageTranslationTable.SetItems(tx, ptt); Debug.Assert(!_unusedPages.Any(unused.Contains)); _unusedPages.AddRange(unused); } var position = pageWritePos * AbstractPager.PageSize; _journalWriter.WriteGather(position, pages); return(pageWritePos); }