The C
mco_seq_agg_sum_TYPE()
,mco_seq_agg_prd_TYPE()
andmco_seq_agg_avg()
functions compute the sum, product and average for the input sequence and return the result as a single element in the result sequence.Example
Following is an example code snippet demonstrating these functions:
void grand_aggregate(mco_db_h db) { mco_trans_h trans; mco_cursor_t quote_cursor; Quote quote; mco_seq_iterator_t close_iterator, sum_iterator, prd_iterator, avg_iterator; MCO_RET rc; ... for (rc = mco_cursor_first(trans, "e_cursor); rc != MCO_S_CURSOR_END; rc = mco_cursor_next(trans, "e_cursor)) { Quote_from_cursor(trans, "e_cursor, "e); /* Initialize iterators */ Quote_close_iterator("e, &close_iterator)); /* Construct operator's pipeline */ mco_seq_agg_sum_float(&sum_iterator, &close_iterator); mco_seq_agg_prd_float(&prd_iterator, &close_iterator); mco_seq_agg_avg_float(&avg_iterator, &close_iterator); ... } }