/* * stats_dump_class_stats () - Dumps the given statistics about a class * return: * class_stats(in): statistics to be printed * fpp(in): */ void stats_dump_class_statistics (CLASS_STATS * class_stats, FILE * fpp) { int i, j, k; const char *prefix = ""; time_t tloc; if (class_stats == NULL) { return; } fprintf (fpp, "\nCLASS STATISTICS\n"); fprintf (fpp, "****************\n"); tloc = (time_t) class_stats->time_stamp; fprintf (fpp, " Timestamp: %s", ctime (&tloc)); fprintf (fpp, " Total Pages in Class Heap: %d\n", class_stats->heap_size); fprintf (fpp, " Total Objects: %d\n", class_stats->num_objects); fprintf (fpp, " Number of attributes: %d\n", class_stats->n_attrs); for (i = 0; i < class_stats->n_attrs; i++) { fprintf (fpp, "\n Atrribute :\n"); fprintf (fpp, " id: %d\n", class_stats->attr_stats[i].id); fprintf (fpp, " Type: "); switch (class_stats->attr_stats[i].type) { case DB_TYPE_INTEGER: fprintf (fpp, "DB_TYPE_INTEGER \n"); break; case DB_TYPE_BIGINT: fprintf (fpp, "DB_TYPE_BIGINT \n"); break; case DB_TYPE_SHORT: fprintf (fpp, "DB_TYPE_SHORT \n"); break; case DB_TYPE_FLOAT: fprintf (fpp, "DB_TYPE_FLOAT \n"); break; case DB_TYPE_DOUBLE: fprintf (fpp, "DB_TYPE_DOUBLE \n"); break; case DB_TYPE_STRING: fprintf (fpp, "DB_TYPE_STRING \n"); break; case DB_TYPE_OBJECT: fprintf (fpp, "DB_TYPE_OBJECT \n"); break; case DB_TYPE_SET: fprintf (fpp, "DB_TYPE_SET \n"); break; case DB_TYPE_MULTI_SET: fprintf (fpp, "DB_TYPE_MULTI_SET \n"); break; case DB_TYPE_SEQUENCE: fprintf (fpp, "DB_TYPE_SEQUENCE \n"); break; case DB_TYPE_TIME: fprintf (fpp, "DB_TYPE_TIME \n"); break; case DB_TYPE_UTIME: fprintf (fpp, "DB_TYPE_UTIME \n"); break; case DB_TYPE_DATETIME: fprintf (fpp, "DB_TYPE_DATETIME \n"); break; case DB_TYPE_MONETARY: fprintf (fpp, "DB_TYPE_MONETARY \n"); break; case DB_TYPE_DATE: fprintf (fpp, "DB_TYPE_DATE \n"); break; case DB_TYPE_ELO: fprintf (fpp, "DB_TYPE_ELO \n"); break; case DB_TYPE_VARIABLE: fprintf (fpp, "DB_TYPE_VARIABLE \n"); break; case DB_TYPE_SUB: fprintf (fpp, "DB_TYPE_SUB \n"); break; case DB_TYPE_POINTER: fprintf (fpp, "DB_TYPE_POINTER \n"); break; case DB_TYPE_NULL: fprintf (fpp, "DB_TYPE_NULL \n"); break; case DB_TYPE_NUMERIC: fprintf (fpp, "DB_TYPE_NUMERIC \n"); break; case DB_TYPE_BIT: fprintf (fpp, "DB_TYPE_BIT \n"); break; case DB_TYPE_VARBIT: fprintf (fpp, "DB_TYPE_VARBIT \n"); break; case DB_TYPE_CHAR: fprintf (fpp, "DB_TYPE_CHAR \n"); break; case DB_TYPE_NCHAR: fprintf (fpp, "DB_TYPE_NCHARL \n"); break; case DB_TYPE_VARNCHAR: fprintf (fpp, "DB_TYPE_VARNCHARL \n"); break; default: break; } stats_print_min_max (&(class_stats->attr_stats[i]), fpp); fprintf (fpp, " BTree statistics:\n"); for (j = 0; j < class_stats->attr_stats[i].n_btstats; j++) { BTREE_STATS *bt_statsp = &class_stats->attr_stats[i].bt_stats[j]; fprintf (fpp, " BTID: { %d , %d }\n", bt_statsp->btid.vfid.volid, bt_statsp->btid.vfid.fileid); fprintf (fpp, " Cardinality: %d (", bt_statsp->keys); prefix = ""; for (k = 0; k < bt_statsp->key_size; k++) { fprintf (fpp, "%s%d", prefix, bt_statsp->pkeys[k]); prefix = ","; } fprintf (fpp, ") ,"); fprintf (fpp, " Total Pages: %d , Leaf Pages: %d ," " Height: %d\n", bt_statsp->pages, bt_statsp->leafs, bt_statsp->height); } fprintf (fpp, "\n"); } fprintf (fpp, "\n\n"); }
/* * stats_dump () - Dumps the given statistics about a class * return: * classname(in): The name of class to be printed * fp(in): */ void stats_dump (const char *class_name_p, FILE * file_p) { MOP class_mop; CLASS_STATS *class_stats_p; SM_CLASS *smclass_p; int i, j, k; const char *name_p; const char *prefix_p = ""; time_t tloc; class_mop = sm_find_class (class_name_p); if (class_mop == NULL) { return; } smclass_p = sm_get_class_with_statistics (class_mop); if (smclass_p == NULL) { return; } class_stats_p = smclass_p->stats; if (class_stats_p == NULL) { return; } fprintf (file_p, "\nCLASS STATISTICS\n"); fprintf (file_p, "****************\n"); fprintf (file_p, " Class name: %s", class_name_p); tloc = (time_t) class_stats_p->time_stamp; fprintf (file_p, " Timestamp: %s", ctime (&tloc)); fprintf (file_p, " Total pages in class heap: %d\n", class_stats_p->heap_size); fprintf (file_p, " Total objects: %d\n", class_stats_p->num_objects); fprintf (file_p, " Number of attributes: %d\n", class_stats_p->n_attrs); for (i = 0; i < class_stats_p->n_attrs; i++) { name_p = sm_get_att_name (class_mop, class_stats_p->attr_stats[i].id); fprintf (file_p, " Atrribute: %s\n", (name_p ? name_p : "not found")); fprintf (file_p, " id: %d\n", class_stats_p->attr_stats[i].id); fprintf (file_p, " Type: "); switch (class_stats_p->attr_stats[i].type) { case DB_TYPE_INTEGER: fprintf (file_p, "DB_TYPE_INTEGER\n"); break; case DB_TYPE_BIGINT: fprintf (file_p, "DB_TYPE_BIGINT\n"); break; case DB_TYPE_FLOAT: fprintf (file_p, "DB_TYPE_FLOAT\n"); break; case DB_TYPE_DOUBLE: fprintf (file_p, "DB_TYPE_DOUBLE\n"); break; case DB_TYPE_STRING: fprintf (file_p, "DB_TYPE_STRING\n"); break; case DB_TYPE_OBJECT: fprintf (file_p, "DB_TYPE_OBJECT\n"); break; case DB_TYPE_SET: fprintf (file_p, "DB_TYPE_SET\n"); break; case DB_TYPE_MULTI_SET: fprintf (file_p, "DB_TYPE_MULTI_SET\n"); break; case DB_TYPE_SEQUENCE: fprintf (file_p, "DB_TYPE_SEQUENCE\n"); break; case DB_TYPE_TIME: fprintf (file_p, "DB_TYPE_TIME\n"); break; case DB_TYPE_UTIME: fprintf (file_p, "DB_TYPE_UTIME\n"); break; case DB_TYPE_DATETIME: fprintf (file_p, "DB_TYPE_DATETIME\n"); break; case DB_TYPE_MONETARY: fprintf (file_p, "DB_TYPE_MONETARY\n"); break; case DB_TYPE_DATE: fprintf (file_p, "DB_TYPE_DATE\n"); break; case DB_TYPE_ELO: fprintf (file_p, "DB_TYPE_ELO\n"); break; case DB_TYPE_VARIABLE: fprintf (file_p, "DB_TYPE_VARIABLE\n"); break; case DB_TYPE_SUB: fprintf (file_p, "DB_TYPE_SUB\n"); break; case DB_TYPE_POINTER: fprintf (file_p, "DB_TYPE_POINTER\n"); break; case DB_TYPE_NULL: fprintf (file_p, "DB_TYPE_NULL\n"); break; case DB_TYPE_NUMERIC: fprintf (file_p, "DB_TYPE_NUMERIC\n"); break; case DB_TYPE_BIT: fprintf (file_p, "DB_TYPE_BIT\n"); break; case DB_TYPE_VARBIT: fprintf (file_p, "DB_TYPE_VARBIT\n"); break; case DB_TYPE_CHAR: fprintf (file_p, "DB_TYPE_CHAR\n"); break; case DB_TYPE_NCHAR: fprintf (file_p, "DB_TYPE_NCHARL\n"); break; case DB_TYPE_VARNCHAR: fprintf (file_p, "DB_TYPE_VARNCHARL\n"); break; case DB_TYPE_DB_VALUE: fprintf (file_p, "DB_TYPE_DB_VALUE\n"); break; default: fprintf (file_p, "UNKNOWN_TYPE\n"); break; } stats_print_min_max (&(class_stats_p->attr_stats[i]), file_p); fprintf (file_p, " B+tree statistics:\n"); for (j = 0; j < class_stats_p->attr_stats[i].n_btstats; j++) { BTREE_STATS *bt_statsp = &class_stats_p->attr_stats[i].bt_stats[j]; fprintf (file_p, " BTID: { %d , %d }\n", bt_statsp->btid.vfid.volid, bt_statsp->btid.vfid.fileid); fprintf (file_p, " Cardinality: %d (", bt_statsp->keys); prefix_p = ""; for (k = 0; k < bt_statsp->key_size; k++) { fprintf (file_p, "%s%d", prefix_p, bt_statsp->pkeys[k]); prefix_p = ","; } fprintf (file_p, ") ,"); fprintf (file_p, " Total pages: %d , Leaf pages: %d ," " Height: %d\n", bt_statsp->pages, bt_statsp->leafs, bt_statsp->height); } fprintf (file_p, "\n"); } fprintf (file_p, "\n\n"); }