Top C Sequence Functions

In addition to the static C functions listed below, for each class that contains one or more sequence fields, a classname_primary_key_name_top() functions is generated. The function has the following prototype:

 
    MCO_RET      classname_primary_key_name_top                   ( mco_trans_h t, 
                        /*IN*/ mco_cursor_h cursor, 
                        /*IN-OUT*/mco_size_t* n, 
                        /*OUT*/char keys[][21], 
                        /*OUT*/double* aggregates, 
                        MCO_RET (*aggregate)(mco_trans_h t, 
                            Quote* handle, 
                            /*OUT*/double* result, 
                            void* ctx), 
                        MCO_RET (*filter)(mco_trans_h t, 
                            mco_cursor_h cursor, 
                            void* ctx), 
                        void* ctx)
    {
     

 

The following static C functions take an input sequence and scalar integer top arguments and produce result sequences of the same TYPE as described in the table below:

mco_seq_top_max_TYPE()

Return in sequence result of the same TYPE the top N maximum values

 
    MCO_RET mco_seq_top_max_TYPE(mco_seq_iterator_h result, 
            mco_seq_iterator_h input, 
            mco_size_t top);
             
mco_seq_top_min_TYPE()

Return in sequence result of the same TYPE the top N minimum values

 
    MCO_RET mco_seq_top_min_TYPE(mco_seq_iterator_h result, 
            mco_seq_iterator_h input, 
            mco_size_t top);
             
mco_seq_top_pos_max_TYPE()

Return in integer sequence result the positions of the top N maximum values

 
    MCO_RET mco_seq_top_pos_max_TYPE(mco_seq_iterator_h result, 
            mco_seq_iterator_h input, 
            mco_size_t top);
     
mco_seq_top_pos_min_TYPE()

Return in integer sequence result the positions of the top N minimum values

 
    MCO_RET mco_seq_top_pos_min_TYPE(mco_seq_iterator_h result, 
            mco_seq_iterator_h input, 
            mco_size_t top);
             

Example

Following is an example code snippet demonstrating one of these functions:

         
    {
        mco_trans_h trans;
        mco_cursor_t quote_cursor;
        Quote quote;
        mco_seq_iterator_t high_iterator, result_iterator;
        MCO_RET rc;
        ...
         
        for (rc = mco_cursor_first(trans, &quote_cursor); 
            rc != MCO_S_CURSOR_END; 
            rc = mco_cursor_next(trans, &quote_cursor)) 
        {
            Quote_from_cursor(trans, &quote_cursor, &quote);
            Quote_high_iterator(&quote, &high_iterator);
            ...
            rc = mco_seq_top_max_float(&result_iterator,  &high_iterator, 20);
            
            ...
        }
        ...
    }