PoeMac/C workers/percentile.c
double cm_query(cm_quantile *cm, double quantile) {
    uint64_t rank = (uint64_t)ceil(quantile * cm->num_values);
		uint64_t min_rank=0;
    uint64_t max_rank;
		uint64_t threshold = (uint64_t)ceil(cm_threshold(cm, rank) / 2.);

    cm_sample *prev = cm->samples;
    cm_sample *current = cm->samples;
    while (current) {
        max_rank = min_rank + current->width + current->delta;
        if (max_rank > rank + threshold || min_rank > rank) {
            break;
        }
        min_rank += current->width;
        prev = current;
        current = current->next;
    }
    return (prev) ? prev->value : 0;
}
/**
 * Queries for a quantile value
 * @arg cm_quantile The cm_quantile to query
 * @arg quantile The quantile to query
 * @return The value on success or 0.
 */
Queries for a quantile value
@arg cm_quantile The cm_quantile to query
@arg quantile The quantile to query
@return The value on success or 0.
Queries for a quantile value @arg cm_quantile The cm_quantile to query @arg quantile The quantile to query @return The value on success or 0 .
double cm_query(cm_quantile *cm, double quantile) {
    uint64_t rank = (uint64_t)ceil(quantile * cm->num_values);
		uint64_t min_rank=0;
    uint64_t max_rank;
		uint64_t threshold = (uint64_t)ceil(cm_threshold(cm, rank) / 2.);
    cm_sample *prev = cm->samples;
    cm_sample *current = cm->samples;
    while (current) {
        max_rank = min_rank + current->width + current->delta;
        if (max_rank > rank + threshold || min_rank > rank) {
            break;
        }
        min_rank += current->width;
        prev = current;
        current = current->next;
    }
    return (prev) ? prev->value : 0;
}
double cm_query ( cm_quantile * cm , double quantile ) { uint64_t rank = ( uint64_t ) ceil ( quantile * cm -> num_values ) ; uint64_t min_rank = 0 ; uint64_t max_rank ; uint64_t threshold = ( uint64_t ) ceil ( cm_threshold ( cm , rank ) / 2. ) ; cm_sample * prev = cm -> samples ; cm_sample * current = cm -> samples ; while ( current ) { max_rank = min_rank + current -> width + current -> delta ; if ( max_rank > rank + threshold || min_rank > rank ) { break ; } min_rank += current -> width ; prev = current ; current = current -> next ; } return ( prev ) ? prev -> value : 0 ; }
Queries for a quantile value
 @arg cm_quantile The cm_quantile to query
 @arg quantile The quantile to query
 @return The value on success or 0.
Queries for a quantile value @arg cm_quantile The cm_quantile to query @arg quantile The quantile to query @return The value on success or 0 .