Пример #1
0
        public static TreeReport GetReport(FixedSizeTree fst, bool includeDetails)
        {
            List <double> pageDensities = null;

            if (includeDetails)
            {
                pageDensities = GetPageDensities(fst);
            }

            var density = pageDensities?.Average() ?? -1;

            var treeReport = new TreeReport
            {
                Type                  = fst.Type ?? RootObjectType.FixedSizeTree,
                Name                  = fst.Name.ToString(),
                BranchPages           = -1,
                Depth                 = fst.Depth,
                NumberOfEntries       = fst.NumberOfEntries,
                LeafPages             = -1,
                OverflowPages         = 0,
                PageCount             = fst.PageCount,
                Density               = density,
                AllocatedSpaceInBytes = fst.PageCount * Constants.Storage.PageSize,
                UsedSpaceInBytes      = includeDetails ? (long)(fst.PageCount * Constants.Storage.PageSize * density) : -1,
                MultiValues           = null,
            };

            return(treeReport);
        }
Пример #2
0
		public StorageReport Generate(ReportInput input)
		{
			var unallocatedPagesAtEndOfFile = input.NumberOfAllocatedPages - input.NextPageNumber;

			var dataFile = new DataFileReport
			{
				AllocatedSpaceInBytes = PagesToBytes(input.NumberOfAllocatedPages),
				SpaceInUseInBytes = PagesToBytes(input.NextPageNumber - input.NumberOfFreePages),
				FreeSpaceInBytes = PagesToBytes(input.NumberOfFreePages + unallocatedPagesAtEndOfFile)
			};

			var trees = new List<TreeReport>();

			foreach (var tree in input.Trees)
			{
				List<double> densities = null;

				if (input.IsLightReport == false)
				{
					densities = GetPageDensities(tree);
				}

				MultiValuesReport multiValues = null;

				if (tree.State.Flags == TreeFlags.MultiValueTrees)
				{
					multiValues = CreateMultiValuesReport(tree);
				}

				var state = tree.State;
				var treeReport = new TreeReport
				{
					Name = tree.Name,
					BranchPages = state.BranchPages,
					Depth = state.Depth,
					EntriesCount = state.EntriesCount,
					LeafPages = state.LeafPages,
					OverflowPages = state.OverflowPages,
					PageCount = state.PageCount,
					Density = densities == null ? 0 : CalculateTreeDensity(densities),
					MultiValues = multiValues
				};

				trees.Add(treeReport);
			}

			var journals = input.Journals.Select(journal => new JournalReport
			{
				Number = journal.Number,
				AllocatedSpaceInBytes = PagesToBytes(journal.JournalWriter.NumberOfAllocatedPages)
			}).ToList();

			return new StorageReport
			{
				DataFile = dataFile,
				Trees = trees,
				Journals = journals
			};
		}
Пример #3
0
        public StorageReport Generate(ReportInput input)
        {
            var unallocatedPagesAtEndOfFile = input.NumberOfAllocatedPages - input.NextPageNumber;

            var dataFile = new DataFileReport
            {
                AllocatedSpaceInBytes = PagesToBytes(input.NumberOfAllocatedPages),
                SpaceInUseInBytes     = PagesToBytes(input.NextPageNumber - input.NumberOfFreePages),
                FreeSpaceInBytes      = PagesToBytes(input.NumberOfFreePages + unallocatedPagesAtEndOfFile)
            };

            var trees = new List <TreeReport>();

            foreach (var tree in input.Trees)
            {
                List <double> densities = null;

                if (input.IsLightReport == false)
                {
                    densities = GetPageDensities(tree);
                }

                MultiValuesReport multiValues = null;

                if (tree.State.Flags == TreeFlags.MultiValueTrees)
                {
                    multiValues = CreateMultiValuesReport(tree);
                }

                var state      = tree.State;
                var treeReport = new TreeReport
                {
                    Name          = tree.Name,
                    BranchPages   = state.BranchPages,
                    Depth         = state.Depth,
                    EntriesCount  = state.EntriesCount,
                    LeafPages     = state.LeafPages,
                    OverflowPages = state.OverflowPages,
                    PageCount     = state.PageCount,
                    Density       = densities == null ? 0 : CalculateTreeDensity(densities),
                    MultiValues   = multiValues
                };

                trees.Add(treeReport);
            }

            var journals = input.Journals.Select(journal => new JournalReport
            {
                Number = journal.Number,
                AllocatedSpaceInBytes = PagesToBytes(journal.JournalWriter.NumberOfAllocatedPages)
            }).ToList();

            return(new StorageReport
            {
                DataFile = dataFile,
                Trees = trees,
                Journals = journals
            });
        }
Пример #4
0
        public static TreeReport GetReport(Tree tree, bool includeDetails)
        {
            List <double>         pageDensities = null;
            Dictionary <int, int> pageBalance   = null;

            if (includeDetails)
            {
                pageDensities = GetPageDensities(tree);
                pageBalance   = GatherBalanceDistribution(tree);
            }

            MultiValuesReport multiValues = null;
            StreamsReport     streams     = null;

            if (tree.State.Flags == TreeFlags.MultiValueTrees)
            {
                multiValues = CreateMultiValuesReport(tree);
            }
            else if (tree.State.Flags == (TreeFlags.FixedSizeTrees | TreeFlags.Streams))
            {
                streams = CreateStreamsReport(tree);
            }

            var density = pageDensities?.Average() ?? -1;

            var treeReport = new TreeReport
            {
                Type                  = RootObjectType.VariableSizeTree,
                Name                  = tree.Name.ToString(),
                BranchPages           = tree.State.BranchPages,
                Depth                 = tree.State.Depth,
                NumberOfEntries       = tree.State.NumberOfEntries,
                LeafPages             = tree.State.LeafPages,
                OverflowPages         = tree.State.OverflowPages,
                PageCount             = tree.State.PageCount,
                Density               = density,
                AllocatedSpaceInBytes = tree.State.PageCount * Constants.Storage.PageSize + (streams?.AllocatedSpaceInBytes ?? 0),
                UsedSpaceInBytes      = includeDetails ? (long)(tree.State.PageCount * Constants.Storage.PageSize * density) : -1,
                MultiValues           = multiValues,
                Streams               = streams,
                BalanceHistogram      = pageBalance,
            };

            return(treeReport);
        }
        public static TreeReport GetReport(Tree tree, bool calculateExactSizes)
        {
            List <double> pageDensities = null;

            if (calculateExactSizes)
            {
                pageDensities = GetPageDensities(tree);
            }

            MultiValuesReport multiValues = null;

            if (tree.State.Flags == TreeFlags.MultiValueTrees)
            {
                multiValues = CreateMultiValuesReport(tree);
            }

            var density = pageDensities?.Average() ?? -1;

            var treeReport = new TreeReport
            {
                Type                  = RootObjectType.VariableSizeTree,
                Name                  = tree.Name.ToString(),
                BranchPages           = tree.State.BranchPages,
                Depth                 = tree.State.Depth,
                NumberOfEntries       = tree.State.NumberOfEntries,
                LeafPages             = tree.State.LeafPages,
                OverflowPages         = tree.State.OverflowPages,
                PageCount             = tree.State.PageCount,
                Density               = density,
                AllocatedSpaceInBytes = tree.State.PageCount * tree.Llt.PageSize,
                UsedSpaceInBytes      = calculateExactSizes ? (long)(tree.State.PageCount * tree.Llt.PageSize * density) : -1,
                MultiValues           = multiValues
            };

            return(treeReport);
        }