Beispiel #1
0
        private void MetadataInitialSetup()
        {
            using ITransaction tran = this.logManager.CreateTransaction(this.pageAllocator, false, "MetadataSetup");

            MixedPage mdColumnsFirstPage = this.pageAllocator.AllocateMixedPage(MetadataColumnsManager.GetSchemaDefinition(), PageManagerConstants.NullPageId, PageManagerConstants.NullPageId, tran).Result;

            this.columnsManager = new MetadataColumnsManager(this.pageAllocator, mdColumnsFirstPage, this.stringHeap);

            MixedPage mdTableFirstPage = this.pageAllocator.AllocateMixedPage(MetadataTablesManager.GetSchemaDefinition(), PageManagerConstants.NullPageId, PageManagerConstants.NullPageId, tran).Result;

            this.tableManager = new MetadataTablesManager(this.pageAllocator, mdTableFirstPage, this.stringHeap, this.columnsManager);

            RowHolder rhf = new RowHolder(this.masterPageColumnDefinition);

            rhf.SetField <int>(0, (int)MetadataObjectEnum.MdTableId);
            rhf.SetField <long>(1, (long)mdTableFirstPage.PageId());

            masterMetadataCollection.Add(rhf, tran).Wait();
            rhf.SetField <int>(0, (int)MetadataObjectEnum.MdColumnId);
            rhf.SetField <long>(1, (long)mdColumnsFirstPage.PageId());
            masterMetadataCollection.Add(rhf, tran).Wait();

            tran.Commit().Wait();
        }
Beispiel #2
0
        public async Task <int> CreateObject(ColumnCreateDefinition def, ITransaction tran)
        {
            if (await this.Exists(def, tran))
            {
                throw new ElementWithSameNameExistsException();
            }

            RowHolder             rh          = new RowHolder(columnDefinitions);
            PagePointerOffsetPair namePointer = await this.stringHeap.Add(def.ColumnName.ToCharArray(), tran);

            rh.SetField <int>(0, def.ColumnId);
            rh.SetField <int>(1, def.TableId);
            rh.SetField <PagePointerOffsetPair>(2, namePointer);
            rh.SetField <int>(3, (int)def.ColumnType.ColumnType);
            rh.SetField <int>(4, def.ColumnType.RepCount);

            await pageListCollection.Add(rh, tran);

            return(def.ColumnId);
        }
Beispiel #3
0
        public async Task <int> CreateObject(TableCreateDefinition def, ITransaction tran)
        {
            if (await this.Exists(def, tran))
            {
                throw new ElementWithSameNameExistsException();
            }

            if (def.ColumnNames.Length != def.ColumnTypes.Length)
            {
                throw new ArgumentException();
            }

            int id = 1;

            if (!(await pageListCollection.IsEmpty(tran)))
            {
                int maxId = await pageListCollection.Max <int>(rh => rh.GetField <int>(0), startMin : 0, tran);

                id = maxId + 1;
            }

            MixedPage rootPage = await this.pageAllocator.AllocateMixedPage(def.ColumnTypes, PageManagerConstants.NullPageId, PageManagerConstants.NullPageId, tran);

            RowHolder             rh          = new RowHolder(columnDefinitions);
            PagePointerOffsetPair namePointer = await this.stringHeap.Add(def.TableName.ToCharArray(), tran);

            rh.SetField <int>(0, id);
            rh.SetField <PagePointerOffsetPair>(1, namePointer);
            rh.SetField <long>(2, (long)rootPage.PageId());
            await pageListCollection.Add(rh, tran);

            for (int i = 0; i < def.ColumnNames.Length; i++)
            {
                ColumnCreateDefinition ccd = new ColumnCreateDefinition(id, def.ColumnNames[i], def.ColumnTypes[i], i);
                await columnManager.CreateObject(ccd, tran);
            }

            return(id);
        }