예제 #1
0
        public PageManager(uint defaultPageSize, IPersistedStream persistedStream, IBufferPool bufferPool, ILockManager lockManager, InstrumentationInterface logger)
        {
            this.pageSize        = defaultPageSize;
            this.persistedStream = persistedStream;
            this.lockManager     = lockManager;
            this.logger          = logger;
            this.bufferPool      = bufferPool;

            this.AllocatationMapPages = new List <BitTrackingPage>();

            if (!this.persistedStream.IsInitialized())
            {
                logger.LogInfo("Initializing the persisted stream.");
                using (ITransaction tran = new NotLoggedTransaction())
                {
                    MixedPage allocationMapFirstPage = new MixedPage(pageSize, (ulong)AllocationMapPageId, new [] { new ColumnInfo(ColumnType.Int) }, PageManagerConstants.NullPageId, PageManagerConstants.NullPageId, new byte[4096], 0, tran);
                    BitTrackingPage.NullifyMixedPage(allocationMapFirstPage, tran);

                    this.AllocatationMapPages.Add(new BitTrackingPage(allocationMapFirstPage));
                    this.persistedStream.MarkInitialized();
                }
            }
            else
            {
                // TODO: Read boot page.
                logger.LogInfo("Using already initialized stream.");
                ulong     position = AllocationMapPageId * this.pageSize;
                MixedPage allocationMapFirstPage = (MixedPage)this.persistedStream.SeekAndRead(position, PageType.MixedPage, this.bufferPool, new ColumnInfo[] { new ColumnInfo(ColumnType.Int) }).Result;
                this.AllocatationMapPages.Add(new BitTrackingPage(allocationMapFirstPage));

                using (ITransaction tran = new NotLoggedTransaction())
                {
                    // TODO: Here we only iterate the first page.
                    // These pages need to be linked...
                    foreach (int _ in this.AllocatationMapPages.First().FindAllSet(tran))
                    {
                        this.pageCount++;
                    }
                }
            }
        }
예제 #2
0
 public PageManager(uint defaultPageSize, IPageEvictionPolicy evictionPolicy, IPersistedStream persistedStream)
     : this(defaultPageSize, persistedStream, new BufferPool(evictionPolicy, (int)defaultPageSize), new LockManager.LockManager(), new NoOpLogging())
 {
 }