mco_index_get_size

Return the size of the specified index .

Prototype

 
    MCO_RET	mco_index_get_size(	/*IN*/ mco_trans_h t,
                    /*IN*/ uint2 index_number,
                    /*OUT*/ mco_counter_t * size );
 

Arguments

t

The mco_trans_h transaction handle returned by mco_trans_start().

index_number

A 2-byte unsigned integer representing the index for which statistics are desired. Normally, the total number of indexes is first obtained by calling mco_index_stat_num() then iterating.from zero to the the total number minus 1.

size

The address of a mco_counter_t variable to receive the index size.

Description

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.)

Return Codes

MCO_S_OK The index size was returned successfully.

MCO_E_INVALID_HANDLE

Database handle not opened.

MCO_E_INDEXLIMIT

Invalid index number.

Example

     
    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);
                    }
                }
                ...
            }
        }
        ...
    }
     
 

Files

Header file:
mco.h
Source file:
mcodb.c
Library:
libmcolib.a