Пример #1
0
        private unsafe static void RenderFixedSizeTreePage(LowLevelTransaction tx, FixedSizeTreePage page, TextWriter sw, FixedSizeTreeHeader.Large *header, string text, bool open)
        {
            sw.WriteLine(
                "<ul><li><input type='checkbox' id='page-{0}' {3} /><label for='page-{0}'>{4}: Page {0:#,#;;0} - {1} - {2:#,#;;0} entries from {5}</label><ul>",
                page.PageNumber, page.IsLeaf ? "Leaf" : "Branch", page.NumberOfEntries, open ? "checked" : "", text, page.Source);

            for (int i = 0; i < page.NumberOfEntries; i++)
            {
                if (page.IsLeaf)
                {
                    var key =
                        *(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + header->ValueSize)) * i));
                    sw.Write("{0:#,#;;0}, ", key);
                }
                else
                {
                    var key =
                        *(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + sizeof(long))) * Math.Max(i, 1)));
                    var pageNum = *(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + sizeof(long))) * i) + sizeof(long));

                    var s = key.ToString("#,#");
                    if (i == 0)
                    {
                        s = "[smallest]";
                    }

                    RenderFixedSizeTreePage(tx, tx.GetReadOnlyFixedSizeTreePage(pageNum), sw, header, s, false);
                }
            }

            sw.WriteLine("</ul></li></ul>");
        }
Пример #2
0
        private static unsafe long GetFixedSizeTreeKey(FixedSizeTreePage page, FixedSizeTreeSafe.LargeFixedSizeTreeSafe tree, int i)
        {
            if (page.IsLeaf)
            {
                return(*(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + tree.ValueSize)) * i)));
            }

            return(*(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + sizeof(long))) * i)));
        }
        public static List <double> GetPageDensities(Tree tree)
        {
            var allPages = tree.AllPages();

            if (allPages.Count == 0)
            {
                return(null);
            }

            var densities = new List <double>();
            var pageSize  = tree.Llt.DataPager.PageSize;

            for (var i = 0; i < allPages.Count; i++)
            {
                var page = tree.Llt.GetPage(allPages[i]);

                if (page.IsOverflow)
                {
                    var numberOfPages = tree.Llt.DataPager.GetNumberOfOverflowPages(page.OverflowSize);

                    densities.Add(((double)(page.OverflowSize + Constants.Tree.PageHeaderSize)) / (numberOfPages * pageSize));

                    i += numberOfPages - 1;
                }
                else
                {
                    if ((page.Flags & PageFlags.FixedSizeTreePage) == PageFlags.FixedSizeTreePage)
                    {
                        var fstp     = new FixedSizeTreePage(page.Pointer, tree.Llt.PageSize);
                        var sizeUsed = Constants.FixedSizeTree.PageHeaderSize +
                                       fstp.NumberOfEntries * (fstp.IsLeaf ? fstp.ValueSize : FixedSizeTree.BranchEntrySize);
                        densities.Add((double)sizeUsed / pageSize);
                    }
                    else
                    {
                        densities.Add(((double)new TreePage(page.Pointer, pageSize).SizeUsed) / pageSize);
                    }
                }
            }
            return(densities);
        }
Пример #4
0
        private static List <double> GetPageDensities(FixedSizeTree tree)
        {
            var allPages = tree.AllPages();

            if (allPages.Count == 0)
            {
                return(null);
            }

            var densities = new List <double>();

            foreach (var pageNumber in allPages)
            {
                var page     = tree.Llt.GetPage(pageNumber);
                var fstp     = new FixedSizeTreePage(page.Pointer, tree.ValueSize + sizeof(long), Constants.Storage.PageSize);
                var sizeUsed = Constants.FixedSizeTree.PageHeaderSize +
                               fstp.NumberOfEntries * (fstp.IsLeaf ? fstp.ValueSize + sizeof(long) : FixedSizeTree.BranchEntrySize);
                densities.Add((double)sizeUsed / Constants.Storage.PageSize);
            }
            return(densities);
        }
Пример #5
0
 private static unsafe long GetFixedSizeTreePageNumber(FixedSizeTreePage page, int i)
 {
     return(*(long *)(page.Pointer + page.StartPosition + (((sizeof(long) + sizeof(long))) * i) + sizeof(long)));
 }
Пример #6
0
        private static async Task RenderFixedSizeTreePageAsync(LowLevelTransaction tx, FixedSizeTreePage page, TextWriter sw, FixedSizeTreeSafe.LargeFixedSizeTreeSafe tree, string text, bool open)
        {
            await sw.WriteLineAsync(
                string.Format("<ul><li><input type='checkbox' id='page-{0}' {3} /><label for='page-{0}'>{4}: Page {0:#,#;;0} - {1} - {2:#,#;;0} entries</label><ul>",
                              page.PageNumber, page.IsLeaf ? "Leaf" : "Branch", page.NumberOfEntries, open ? "checked" : "", text));

            for (int i = 0; i < page.NumberOfEntries; i++)
            {
                var key = GetFixedSizeTreeKey(page, tree, i);

                if (page.IsLeaf)
                {
                    await sw.WriteAsync(string.Format("{0:#,#;;0}, ", key));
                }
                else
                {
                    var pageNum = GetFixedSizeTreePageNumber(page, i);

                    var s = key.ToString("#,#");
                    if (i == 0)
                    {
                        if (key == long.MinValue)
                        {
                            s = "[smallest]";
                        }
                        else
                        {
                            s = "[smallest " + s + "]";
                        }
                    }

                    var fstPage = tx.GetPage(pageNum);
                    await RenderFixedSizeTreePageAsync(tx, CreateFixedSizeTreePage(fstPage, tree), sw, tree, s, false);
                }
            }

            await sw.WriteLineAsync("</ul></li></ul>");
        }