Example #1
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
            });
        }
Example #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
			};
		}