예제 #1
0
        public StorageReport GenerateReport(Transaction tx, bool computeExactSizes = false)
        {
            var numberOfAllocatedPages = Math.Max(_dataPager.NumberOfAllocatedPages, NextPageNumber - 1); // async apply to data file task
            var numberOfFreePages      = _freeSpaceHandling.AllPages(tx).Count;

            var trees = new List <Tree>();

            using (var rootIterator = tx.Root.Iterate())
            {
                if (rootIterator.Seek(Slice.BeforeAllKeys))
                {
                    do
                    {
                        var tree = tx.ReadTree(rootIterator.CurrentKey.ToString());
                        trees.Add(tree);
                    }while (rootIterator.MoveNext());
                }
            }

            var generator = new StorageReportGenerator(tx);

            return(generator.Generate(new ReportInput
            {
                NumberOfAllocatedPages = numberOfAllocatedPages,
                NumberOfFreePages = numberOfFreePages,
                NextPageNumber = NextPageNumber,
                Journals = Journal.Files.ToList(),
                Trees = trees,
                IsLightReport = !computeExactSizes
            }));
        }
예제 #2
0
        public StorageReport GenerateReport(Transaction tx)
        {
            var numberOfAllocatedPages = Math.Max(_dataPager.NumberOfAllocatedPages, NextPageNumber - 1); // async apply to data file task
            var numberOfFreePages      = _freeSpaceHandling.AllPages(tx.LowLevelTransaction).Count;

            var countOfTrees  = 0;
            var countOfTables = 0;

            using (var rootIterator = tx.LowLevelTransaction.RootObjects.Iterate(false))
            {
                if (rootIterator.Seek(Slices.BeforeAllKeys))
                {
                    do
                    {
                        var currentKey = rootIterator.CurrentKey.Clone(tx.Allocator);
                        var type       = tx.GetRootObjectType(currentKey);
                        switch (type)
                        {
                        case RootObjectType.VariableSizeTree:
                            countOfTrees++;
                            break;

                        case RootObjectType.EmbeddedFixedSizeTree:
                            break;

                        case RootObjectType.FixedSizeTree:
                            countOfTrees++;
                            break;

                        case RootObjectType.Table:
                            countOfTables++;
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }while (rootIterator.MoveNext());
                }
            }

            var generator = new StorageReportGenerator(tx.LowLevelTransaction);

            return(generator.Generate(new ReportInput
            {
                NumberOfAllocatedPages = numberOfAllocatedPages,
                NumberOfFreePages = numberOfFreePages,
                NextPageNumber = NextPageNumber,
                CountOfTrees = countOfTrees,
                CountOfTables = countOfTables,
                Journals = Journal.Files.ToList()
            }));
        }
        public StorageReport GenerateReport(Transaction tx, bool computeExactSizes = false)
        {
            var numberOfAllocatedPages = Math.Max(_dataPager.NumberOfAllocatedPages, NextPageNumber - 1); // async apply to data file task
            var numberOfFreePages      = _freeSpaceHandling.AllPages(tx.LowLevelTransaction).Count;

            var trees          = new List <Tree>();
            var fixedSizeTrees = new List <FixedSizeTree>();

            using (var rootIterator = tx.LowLevelTransaction.RootObjects.Iterate(false))
            {
                if (rootIterator.Seek(Slices.BeforeAllKeys))
                {
                    do
                    {
                        var curretKey = rootIterator.CurrentKey.Clone(tx.Allocator);
                        switch (tx.GetRootObjectType(curretKey))
                        {
                        case RootObjectType.VariableSizeTree:
                            var tree = tx.ReadTree(curretKey.ToString());
                            trees.Add(tree);
                            break;

                        case RootObjectType.EmbeddedFixedSizeTree:
                            break;

                        case RootObjectType.FixedSizeTree:
                            fixedSizeTrees.Add(tx.FixedTreeFor(curretKey, 0));
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }while (rootIterator.MoveNext());
                }
            }

            var generator = new StorageReportGenerator(tx.LowLevelTransaction);

            return(generator.Generate(new ReportInput
            {
                NumberOfAllocatedPages = numberOfAllocatedPages,
                NumberOfFreePages = numberOfFreePages,
                NextPageNumber = NextPageNumber,
                Journals = Journal.Files.ToList(),
                Trees = trees,
                FixedSizeTrees = fixedSizeTrees,
                IsLightReport = !computeExactSizes
            }));
        }
예제 #4
0
파일: TableReport.cs 프로젝트: ikvm/ravendb
        public TableReport(long allocatedSpaceInBytes, long usedSizeInBytes, bool calculateExactSizes, StorageReportGenerator generator = null)
        {
            AllocatedSpaceInBytes = DataSizeInBytes = allocatedSpaceInBytes;
            UsedSizeInBytes       = usedSizeInBytes;

            if (calculateExactSizes == false)
            {
                UsedSizeInBytes = -1;
            }

            Indexes   = new List <TreeReport>();
            Structure = new List <TreeReport>();

            _storageGenerator = generator;
        }
예제 #5
0
        public void AddPreAllocatedBuffers(NewPageAllocator tablePageAllocator, bool includeDetails)
        {
            if (PreAllocatedBuffers != null)
            {
                throw new InvalidOperationException("Pre allocated buffers already defined");
            }

            PreAllocatedBuffers = StorageReportGenerator.GetReport(tablePageAllocator, includeDetails);

            AllocatedSpaceInBytes += PreAllocatedBuffers.AllocatedSpaceInBytes;

            if (includeDetails)
            {
                var allocationTree = PreAllocatedBuffers.AllocationTree;
                UsedSizeInBytes += (long)(allocationTree.AllocatedSpaceInBytes * allocationTree.Density);
            }
        }
예제 #6
0
 public void ReportGeneratorCalculatesCorrectDensity(double[] pageDensities, double expectedDensity)
 {
     Assert.Equal(expectedDensity, StorageReportGenerator.CalculateTreeDensity(pageDensities.ToList()));
 }
예제 #7
0
        public void AddIndex(Tree tree, bool includeDetails)
        {
            var report = StorageReportGenerator.GetReport(tree, includeDetails);

            AddIndex(report, Constants.Storage.PageSize, includeDetails);
        }
예제 #8
0
        public void AddIndex(FixedSizeTree fst, bool includeDetails)
        {
            var report = StorageReportGenerator.GetReport(fst, includeDetails);

            AddIndex(report, Constants.Storage.PageSize, includeDetails);
        }
예제 #9
0
        public unsafe DetailedStorageReport GenerateDetailedReport(Transaction tx, bool calculateExactSizes = false)
        {
            var numberOfAllocatedPages = Math.Max(_dataPager.NumberOfAllocatedPages, NextPageNumber - 1); // async apply to data file task
            var numberOfFreePages      = _freeSpaceHandling.AllPages(tx.LowLevelTransaction).Count;

            var trees          = new List <Tree>();
            var fixedSizeTrees = new List <FixedSizeTree>();
            var tables         = new List <Table>();

            using (var rootIterator = tx.LowLevelTransaction.RootObjects.Iterate(false))
            {
                if (rootIterator.Seek(Slices.BeforeAllKeys))
                {
                    do
                    {
                        var currentKey = rootIterator.CurrentKey.Clone(tx.Allocator);
                        var type       = tx.GetRootObjectType(currentKey);
                        switch (type)
                        {
                        case RootObjectType.VariableSizeTree:
                            var tree = tx.ReadTree(currentKey);
                            trees.Add(tree);
                            break;

                        case RootObjectType.EmbeddedFixedSizeTree:
                            break;

                        case RootObjectType.FixedSizeTree:

                            if (SliceComparer.AreEqual(currentKey, NewPageAllocator.AllocationStorage))     // will be counted inside pre allocated buffers report
                            {
                                continue;
                            }

                            fixedSizeTrees.Add(tx.FixedTreeFor(currentKey));
                            break;

                        case RootObjectType.Table:
                            var tableTree             = tx.ReadTree(currentKey, RootObjectType.Table);
                            var writtenSchemaData     = tableTree.DirectRead(TableSchema.SchemasSlice);
                            var writtenSchemaDataSize = tableTree.GetDataSize(TableSchema.SchemasSlice);
                            var tableSchema           = TableSchema.ReadFrom(tx.Allocator, writtenSchemaData, writtenSchemaDataSize);

                            var table = tx.OpenTable(tableSchema, currentKey);
                            tables.Add(table);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }while (rootIterator.MoveNext());
                }
            }

            var generator = new StorageReportGenerator(tx.LowLevelTransaction);

            return(generator.Generate(new DetailedReportInput
            {
                NumberOfAllocatedPages = numberOfAllocatedPages,
                NumberOfFreePages = numberOfFreePages,
                NextPageNumber = NextPageNumber,
                Journals = Journal.Files.ToList(),
                Trees = trees,
                FixedSizeTrees = fixedSizeTrees,
                Tables = tables,
                CalculateExactSizes = calculateExactSizes,
                ScratchBufferPoolInfo = _scratchBufferPool.InfoForDebug(PossibleOldestReadTransaction(tx.LowLevelTransaction))
            }));
        }
예제 #10
0
        public void AddIndex(Tree tree, bool calculateExactSizes)
        {
            var report = StorageReportGenerator.GetReport(tree, calculateExactSizes);

            AddIndex(report, tree.Llt.PageSize, calculateExactSizes);
        }
예제 #11
0
        public void AddIndex(FixedSizeTree fst, bool calculateExactSizes)
        {
            var report = StorageReportGenerator.GetReport(fst, calculateExactSizes);

            AddIndex(report, fst.Llt.PageSize, calculateExactSizes);
        }
예제 #12
0
        public void AddStructure(Tree tree, bool calculateExactSizes)
        {
            var report = StorageReportGenerator.GetReport(tree, calculateExactSizes);

            AddStructure(report, Constants.Storage.PageSize, calculateExactSizes);
        }