COOPY » Guide
version 0.6.5
|
00001 #include <coopy/MergeOutputStats.h> 00002 #include <coopy/SheetSchema.h> 00003 00004 using namespace std; 00005 using namespace coopy::cmp; 00006 using namespace coopy::store; 00007 00008 bool MergeOutputStats::flush() { 00009 if (active) { 00010 SimpleSheetSchema ss; 00011 if (sheet_name=="") { 00012 sheet_name = "sheet"; 00013 } 00014 ss.setSheetName(sheet_name.c_str()); 00015 ss.addColumn("nature",ColumnType("TEXT")); 00016 ss.addColumn("operation",ColumnType("TEXT")); 00017 ss.addColumn("count",ColumnType("INTEGER")); 00018 if (getOutputBook()!=NULL) { 00019 ops = getOutputBook()->provideSheet(ss); 00020 } 00021 if (!ops.isValid()) { 00022 fprintf(stderr,"* Could not generate stats sheet\n"); 00023 exit(1); 00024 return false; 00025 } 00026 ops.deleteData(); 00027 00028 const CompareFlags& flags = getFlags(); 00029 Poly<SheetRow> row; 00030 00031 if (flags.canSchema()) { 00032 row = ops.insertRow(); 00033 row->setCell(0,SheetCell("column",false)); 00034 row->setCell(1,SheetCell("all",false)); 00035 row->setCell(2,SheetCell::makeInt(ct_col)); 00036 row->flush(); 00037 row = ops.insertRow(); 00038 row->setCell(0,SheetCell("column",false)); 00039 row->setCell(1,SheetCell("insert",false)); 00040 row->setCell(2,SheetCell::makeInt(ct_col_insert)); 00041 row->flush(); 00042 row = ops.insertRow(); 00043 row->setCell(0,SheetCell("column",false)); 00044 row->setCell(1,SheetCell("delete",false)); 00045 row->setCell(2,SheetCell::makeInt(ct_col_delete)); 00046 row->flush(); 00047 row = ops.insertRow(); 00048 row->setCell(0,SheetCell("column",false)); 00049 row->setCell(1,SheetCell("move",false)); 00050 row->setCell(2,SheetCell::makeInt(ct_col_move)); 00051 row->flush(); 00052 row = ops.insertRow(); 00053 row->setCell(0,SheetCell("column",false)); 00054 row->setCell(1,SheetCell("rename",false)); 00055 row->setCell(2,SheetCell::makeInt(ct_col_rename)); 00056 row->flush(); 00057 } 00058 00059 if (flags.canInsert()||flags.canDelete()||flags.canUpdate()) { 00060 row = ops.insertRow(); 00061 row->setCell(0,SheetCell("row",false)); 00062 row->setCell(1,SheetCell("all",false)); 00063 row->setCell(2,SheetCell::makeInt(ct_row)); 00064 row->flush(); 00065 row = ops.insertRow(); 00066 row->setCell(0,SheetCell("row",false)); 00067 row->setCell(1,SheetCell("insert",false)); 00068 row->setCell(2,SheetCell::makeInt(ct_row_insert)); 00069 row->flush(); 00070 row = ops.insertRow(); 00071 row->setCell(0,SheetCell("row",false)); 00072 row->setCell(1,SheetCell("delete",false)); 00073 row->setCell(2,SheetCell::makeInt(ct_row_delete)); 00074 row->flush(); 00075 row = ops.insertRow(); 00076 row->setCell(0,SheetCell("row",false)); 00077 row->setCell(1,SheetCell("move",false)); 00078 row->setCell(2,SheetCell::makeInt(ct_row_move)); 00079 row->flush(); 00080 row = ops.insertRow(); 00081 row->setCell(0,SheetCell("row",false)); 00082 row->setCell(1,SheetCell("update",false)); 00083 row->setCell(2,SheetCell::makeInt(ct_row_update)); 00084 row->flush(); 00085 } 00086 } 00087 ops.clear(); 00088 active = false; 00089 ct_col = ct_col_insert = ct_col_delete = ct_col_move = ct_col_rename = 0; 00090 ct_row = ct_row_insert = ct_row_delete = ct_row_move = ct_row_update = 0; 00091 return true; 00092 } 00093 00094 00095 bool MergeOutputStats::changeColumn(const OrderChange& change) { 00096 active = true; 00097 ct_col++; 00098 switch (change.mode) { 00099 case ORDER_CHANGE_INSERT: 00100 ct_col_insert++; 00101 break; 00102 case ORDER_CHANGE_DELETE: 00103 ct_col_delete++; 00104 break; 00105 case ORDER_CHANGE_MOVE: 00106 ct_col_move++; 00107 break; 00108 case ORDER_CHANGE_RENAME: 00109 ct_col_rename++; 00110 break; 00111 } 00112 return true; 00113 } 00114 00115 bool MergeOutputStats::changeRow(const RowChange& change) { 00116 if (change.mode == ROW_CHANGE_CONTEXT) return true; 00117 active = true; 00118 ct_row++; 00119 switch (change.mode) { 00120 case ROW_CHANGE_INSERT: 00121 ct_row_insert++; 00122 break; 00123 case ROW_CHANGE_DELETE: 00124 ct_row_delete++; 00125 break; 00126 case ROW_CHANGE_MOVE: 00127 ct_row_move++; 00128 break; 00129 case ROW_CHANGE_UPDATE: 00130 ct_row_update++; 00131 break; 00132 } 00133 return true; 00134 }