#include "btreecompact.h"
#include "btreefromsstree.h"
#include "basepacking.h"
#include <string>
#include <cfloat>
#include <algorithm>
Include dependency graph for btreecompactsstree.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
double | BTreeCompactSlice (const SoftPacking &spk, const string &outfilename) |
double | getTolerance (const HardBlockInfoType &blockinfo) |
Variables | |
const double | DEFAULT_SIDE_ACCURACY = 10000000 |
|
Definition at line 46 of file btreecompactsstree.cxx. References BTree::blockArea(), BTreeCompactor::compact(), getTolerance(), PrintAreas(), PrintDimensions(), PrintUtilization(), Save_bbb(), BTree::totalArea(), BTree::totalHeight(), and BTree::totalWidth().
00048 { 00049 SoftPackingHardBlockInfoType hardblockinfo(spk); 00050 BTreeFromSoftPacking btree(hardblockinfo, spk, 00051 getTolerance(hardblockinfo)); 00052 BTreeCompactor compactor(btree); 00053 00054 int numChanged = 0; 00055 int i = 0; 00056 00057 double orig_totalArea = compactor.totalArea(); 00058 double orig_blockArea = compactor.blockArea(); 00059 double spk_totalArea = spk.totalWidth * spk.totalHeight; 00060 printf("converted to B*-Tree: %.2lf (%.2lf%%) -> %.2lf (%.2lf%%)\n", 00061 spk_totalArea, (spk.deadspace / spk.blockArea) * 100, 00062 orig_totalArea, (orig_totalArea / orig_blockArea - 1)* 100); 00063 do 00064 { 00065 numChanged = compactor.compact(); 00066 00067 printf("round %d: %6d blks changed: %.2lf (%.2lf%%) -> %.2lf (%.2lf%%)\n", 00068 i, numChanged, orig_totalArea, 00069 (orig_totalArea / orig_blockArea - 1) * 100, 00070 compactor.totalArea(), 00071 (compactor.totalArea() / compactor.blockArea() - 1) * 100); 00072 i++; 00073 orig_totalArea = compactor.totalArea(); 00074 orig_blockArea = compactor.blockArea(); 00075 } while (numChanged != 0); 00076 00077 double final_blkArea = compactor.blockArea(); 00078 double final_deadspace = compactor.totalArea() - final_blkArea; 00079 cout << endl; 00080 cout << "After compaction, " << endl; 00081 cout << "blkArea: " << setw(11) << final_blkArea 00082 << " deadspace: " << setw(11) << final_deadspace 00083 << " (" << ((final_deadspace / final_blkArea) * 100) << "%)" << endl; 00084 00085 cout << endl; 00086 PrintDimensions(compactor.totalWidth(), compactor.totalHeight()); 00087 PrintAreas(final_deadspace, final_blkArea); 00088 cout << endl; 00089 PrintUtilization(final_deadspace, final_blkArea); 00090 cout << endl; 00091 00092 ofstream outfile; 00093 outfile.open(outfilename.c_str()); 00094 Save_bbb(outfile, BTreeOrientedPacking(compactor)); 00095 if (outfile.good()) 00096 cout << "Output successfully written to " << outfilename << endl; 00097 else 00098 cout << "Something wrong with the file " << outfilename << endl; 00099 outfile.close(); 00100 00101 return (compactor.totalArea() - compactor.blockArea()); 00102 } |
Here is the call graph for this function:
|
Definition at line 57 of file btreecompactsstree.h. References HardBlockInfoType::blocknum(), and DEFAULT_SIDE_ACCURACY. Referenced by BTreeCompactSlice().
00058 { 00059 double min_side = DBL_MAX; 00060 for (int i = 0; i < blockinfo.blocknum(); i++) 00061 min_side = min(min_side, 00062 min(blockinfo[i].width[0], blockinfo[i].height[0])); 00063 00064 return min_side / DEFAULT_SIDE_ACCURACY; 00065 } |
Here is the call graph for this function:
|
Definition at line 47 of file btreecompactsstree.h. Referenced by getTolerance(). |