This function collects information about the distribution of free disk space.
MCO_RET mco_disk_get_alloc_info(
/* IN */ mco_db_h con,
/* OUT */ mco_disk_alloc_info_t* unaligned,
/* OUT */ mco_disk_alloc_info_t* aligned);
This function collects information about the distribution of free space in the database file. During database operations, the engine may allocate or deallocate space within the file, potentially creating holes. This function analyzes those holes and returns the results in a
mco_disk_alloc_info_tstructure, which includes a histogram of hole counters.The
mco_disk_alloc_info_tstructure is defined as follows:typedef struct { mco_size_t allocated; mco_size_t used; mco_counter_t profile[MCO_DISK_FRAG_PROFILE_SIZE]; } mco_disk_alloc_info_t;The fields of the
mco_disk_alloc_info_tstructure are:
mco_size_t allocated– total size of all allocated pages (both used and free)mco_size_t used– total size of used pagesmco_counter_t profile[MCO_DISK_FRAG_PROFILE_SIZE]– histogram of hole countersSpecifically,
profile[0]counts holes that are 1 in-memory page in size,profile[1]counts holes of 2 pages, and so on.Note: This function scans all bitmap pages in the database file and may take a significant amount of time to complete.
MCO_S_OKThe function completed successfully.MCO_E_UNSUPPORTEDUnsupported call.
...
#define CHECK(func) { MCO_RET rc_ = func; if (rc_ != MCO_S_OK) { \
printf("\nCall \"" #func "\" at %s:%d failed , code = %d\n\t(%s)\n", __FILE__, __LINE__, rc_, mco_ret_string(rc_, 0)); \
dbg_exit(rc_); }}
...
mco_disk_alloc_info_t unaligned, aligned;
mco_offs_t allocated, used, total_allocated, total_used;
...
CHECK(mco_disk_get_alloc_info(db, &unaligned, &aligned));
CHECK(mco_disk_get_allocated_space(db, &allocated, &used));
total_allocated = unaligned.allocated + aligned.allocated;
total_used = unaligned.used + aligned.used;
...
printf("alloc_info: alloc %lld(bytes), used %lld(bytes)\n",
(mco_int8)total_allocated, (mco_int8)total_used);
printf("allocated_space: alloc %lld(bytes), used %lld(bytes)\n\n",
(mco_int8)allocated, (mco_int8)used);
...