Exemple #1
0
        private LogRecordPage ReadPage(ulong pageOffset)
        {
            if (m_firstTailPage == null || m_secondTailPage == null)
            {
                m_firstTailPage  = ReadPageFromFile(m_restartPage.SystemPageSize * 2);
                m_secondTailPage = ReadPageFromFile(m_restartPage.SystemPageSize * 2 + m_restartPage.LogPageSize);
            }

            LogRecordPage page = null;

            if (pageOffset == m_firstTailPage.LastLsnOrFileOffset)
            {
                page = m_firstTailPage;
            }

            if (pageOffset == m_secondTailPage.LastLsnOrFileOffset)
            {
                if (page == null || m_secondTailPage.LastEndLsn >= m_firstTailPage.LastEndLsn)
                {
                    page = m_secondTailPage;
                }
            }

            if (page == null)
            {
                page = ReadPageFromFile(pageOffset);
            }
            return(page);
        }
Exemple #2
0
        private void WritePage(ulong pageOffset, LogRecordPage page)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            byte[] pageBytes = page.GetBytes((int)m_restartPage.LogPageSize, m_restartPage.LogRestartArea.LogPageDataOffset);
            WriteData(pageOffset, pageBytes);
        }
Exemple #3
0
        public LogRecord ReadRecord(ulong lsn)
        {
            if (m_restartPage == null)
            {
                m_restartPage = ReadRestartPage();
            }

            ulong         pageOffsetInFile   = LsnToPageOffsetInFile(lsn);
            int           recordOffsetInPage = LsnToRecordOffsetInPage(lsn);
            LogRecordPage page = ReadPage(pageOffsetInFile);

            return(page.ReadRecord(recordOffsetInPage, m_restartPage.LogRestartArea.LogPageDataOffset));
        }