📄 d_btreecontroller.java
字号:
"reserved bytes/page") + out_summary( "# of free bytes = ", li.num_free_bytes, (li.num_free_bytes / li.num_pages), "free bytes/page") + out_summary( "# of slot table bytes = ", li.num_slottab_bytes, (li.num_slottab_bytes / li.num_pages), "slot table bytes/page") + out_summary( "# of reserved+free+row+slot bytes = ", (li.num_rowsize_bytes + li.num_res_bytes + li.num_free_bytes + li.num_slottab_bytes), ((li.num_rowsize_bytes + li.num_res_bytes + li.num_free_bytes + li.num_slottab_bytes) / li.num_pages), "summed bytes/page") + out_summary( "# of total records = ", li.num_entries, (((double) li.num_entries) / li.num_pages), "records/page") + out_summary( "# of overflow records = ", li.num_overflow_rows, (((double) li.num_overflow_rows) / li.num_pages), "overflow records/page") + out_summary( "# of deleted records = ", li.num_deleted, (((double) li.num_deleted) / li.num_pages), "deleted records/page"); return(ret_string); } private static String diag_tabulate( Properties prop, LevelInfo level_info[]) { String ret_string = new String(); LevelInfo total = new LevelInfo(); // first tabulate totals for all levels for (int level = 0; level < level_info.length; level++) { LevelInfo li = level_info[level]; total.num_pages += li.num_pages; total.num_overflow_pgs += li.num_overflow_pgs; total.num_entries += li.num_entries; total.num_deleted += li.num_deleted; total.max_pageno = Math.max(total.max_pageno, li.max_pageno); total.num_free_bytes += li.num_free_bytes; total.num_res_bytes += li.num_res_bytes; total.num_overflow_rows += li.num_overflow_rows; total.num_rowsize_bytes += li.num_rowsize_bytes; total.num_slottab_bytes += li.num_slottab_bytes; total.min_rowsize_bytes = Math.min(total.min_rowsize_bytes, li.min_rowsize_bytes); total.max_rowsize_bytes = Math.max(total.max_rowsize_bytes, li.max_rowsize_bytes); } ret_string += "Btree conglom has:\n" + "\t" + prop.getProperty(Page.DIAG_PAGE_SIZE) + " bytes per page\n" + "\t" + total.num_pages + " total used pages (" + (Integer.parseInt(prop.getProperty(Page.DIAG_PAGE_SIZE)) * total.num_pages) + " bytes)\n" + "\tmaximum page number = " + total.max_pageno + ".\n" + "\treserved space % = " + prop.getProperty(Page.DIAG_RESERVED_SPACE) + "%.\n" + "\tminimum record size = " + prop.getProperty(Page.DIAG_MINIMUM_REC_SIZE) + ".\n" + "\tpage overhead bytes = " + prop.getProperty(Page.DIAG_PAGEOVERHEAD) + " bytes per page.\n"; // Format Totals: ret_string += diag_onelevel(prop, total); // Format Totals by level: // Totals by level: for (int level = 0; level < level_info.length; level++) { LevelInfo li = level_info[level]; ret_string += "level[" + level + "] stats:\n"; ret_string += diag_onelevel(prop, li); } return(ret_string); } private static String olddiag_tabulate( Properties prop, LevelInfo level_info[]) { String ret_string = new String(); long total_pages = 0; long total_res = 0; for (int level = 0; level < level_info.length; level++) { total_pages += level_info[level].num_pages; } // Totals: ret_string += "Btree conglom has:\n" + "\t" + prop.getProperty(Page.DIAG_PAGE_SIZE) + " bytes per page\n" + "\t" + total_pages + " total pages (" + (Integer.parseInt(prop.getProperty(Page.DIAG_PAGE_SIZE)) * total_pages) + " bytes)\n" + "\t" + level_info.length + " total levels\n" + "\t" + level_info[0].num_entries + " total user records\n"; // Totals by level: for (int level = 0; level < level_info.length; level++) { LevelInfo li = level_info[level]; ret_string += "level[" + level + "] stats:\n"; ret_string += "\t# of pages = " + li.num_pages + ".\n" + "\t# of entries = " + li.num_entries + ". " + "(" + (li.num_entries / li.num_pages) + " entries/page).\n" + "\t# of deleted entries = " + li.num_deleted + ". " + "(" + (li.num_deleted / li.num_pages) + " deleted/page).\n" + "\t# of free bytes = " + li.num_res_bytes + ". " + "(" + (li.num_res_bytes / li.num_pages) + " reserved bytes/page).\n" + "\t# of free bytes = " + li.num_free_bytes + ". " + "(" + (li.num_free_bytes / li.num_pages) + " free bytes/page).\n" + "\t# of slot table bytes= " + li.num_slottab_bytes + ". " + "(" + (li.num_slottab_bytes / li.num_pages) + " slot table bytes/page).\n"; } return(ret_string); } /* ** Methods of Diagnosticable */ public void init(Object obj) { if (SanityManager.DEBUG) SanityManager.ASSERT(obj instanceof BTreeController); super.init(obj); } /** * Default implementation of diagnostic on the object. * <p> * This routine returns a string with whatever diagnostic information * you would like to provide about this object. * <p> * This routine returns a summary table of information about pages in * each level of the btree. It tells the height of the tree, the * average free and reserved bytes per level, and the page size. * <p> * * @return A string with diagnostic information about the object. * * @exception StandardException Standard cloudscape exception policy **/ public String diag() throws StandardException { OpenBTree open_btree = (BTreeController) this.diag_object; ControlRow root = null; int tree_height; LevelInfo level_info[] = null; String diag_info = new String(); try { tree_height = open_btree.getHeight(); root = ControlRow.Get(open_btree, BTree.ROOTPAGEID); // Allocate a LevelInfo array with one entry per level of the tree. level_info = new LevelInfo[tree_height]; for (int level = 0; level < level_info.length; level++) level_info[level] = new LevelInfo(); // ask page to provide diag info: Properties prop = new Properties(); prop.put(Page.DIAG_PAGE_SIZE, ""); prop.put(Page.DIAG_BYTES_FREE, ""); prop.put(Page.DIAG_BYTES_RESERVED, ""); prop.put(Page.DIAG_RESERVED_SPACE, ""); prop.put(Page.DIAG_MINIMUM_REC_SIZE, ""); prop.put(Page.DIAG_NUMOVERFLOWED, ""); prop.put(Page.DIAG_ROWSIZE, ""); prop.put(Page.DIAG_MINROWSIZE, ""); prop.put(Page.DIAG_MAXROWSIZE, ""); prop.put(Page.DIAG_PAGEOVERHEAD, ""); prop.put(Page.DIAG_SLOTTABLE_SIZE, ""); diag_level(open_btree, root, prop, level_info); diag_info = diag_tabulate(prop, level_info); } finally { if (root != null) root.release(); } return(diag_info); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -