Return the size of the specified index.
MCO_RET mco_index_get_size( /*IN*/ mco_trans_h t,
/*IN*/ uint2 index_number,
/*OUT*/ mco_counter_t * size);
t
mco_trans_h transaction handle returned by mco_trans_start().index_number
mco_index_stat_num() then iterating from zero to the total number minus 1.size
mco_counter_t variable to receive the index size.The function returns the size of the index — the number of key values in the index structure (tree). This API is similar to the
mco_index_stat_get(), but is faster because it doesn't perform any calculations; thus it can be used frequently. (Note that mco_index_stat_get() can take a substantial amount of time to return and should not be called in performance critical paths of applications.)
MCO_S_OK
MCO_E_INVALID_HANDLE
MCO_E_INDEXLIMIT
Application snippet:
const char * dbname = "SimpleDb";
int main(int argc, char* argv[])
{
mco_db_h db;
MCO_RET rc;
mco_device_t dev;
mco_db_params_t db_params;
mco_trans_h t;
uint2 n_indexes;
mco_counter_t size;
int j;
...
rc = mco_db_open_dev(dbname, simple_get_dictionary(), &dev, 1, &db_params);
if (MCO_S_OK != rc)
{
rc = mco_db_connect(dbname, &db);
...
rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
if (MCO_S_OK == rc)
{
mco_index_stat_num(t, &n_indexes);
for (j = 0; j < n_indexes && MCO_S_OK == rc; j++)
{
rc = mco_index_get_size(t, j, &size);
if (MCO_S_OK == rc)
{
printf("Index number %d size is %4d\n\t\t\t",
j, size);
}
}
...
}
}
...
}