}
quicksort(quantiles, quantiles + quantiles_count - 1);
- /* initialize rt_quantile */
+ /* initialize linked-list set */
*qlls_count = quantiles_count * 2;
RASTER_DEBUGF(4, "qlls_count = %d", *qlls_count);
*qlls = rtalloc(sizeof(struct quantile_llist) * *qlls_count);
}
}
+ else {
+ RASTER_DEBUGF(5, "skipping value at (x, y) = (%d, %d)", x, y);
+ }
z++;
}
RASTER_DEBUGF(5, "qll: (head, tail) = (%p, %p)", qll->head, qll->tail);
rtn[k].quantile = qll->quantile;
+ rtn[k].has_value = 0;
+
+ /* check that qll->head and qll->tail have value */
+ if (qll->head == NULL || qll->tail == NULL)
+ continue;
/* AL-GEQ */
if (qll->algeq)
else
qle = qll->tail;
- RASTER_DEBUGF(5, "qle: (value, count) = (%f, %d)", qle->value, qle->count);
-
exists = 0;
for (j = i + 1; j < *qlls_count; j++) {
if (FLT_EQ((*qlls)[j].quantile, qll->quantile)) {
else {
rtn[k].value = qle->value;
}
+ rtn[k].has_value = 1;
RASTER_DEBUGF(3, "(quantile, value) = (%f, %f)\n\n", rtn[k].quantile, rtn[k].value);
k++;
covquant2 = SPI_palloc(sizeof(struct rt_quantile_t) * count);
for (i = 0; i < count; i++) {
covquant2[i].quantile = covquant[i].quantile;
- covquant2[i].value = covquant[i].value;
+ covquant2[i].has_value = covquant[i].has_value;
+ if (covquant2[i].has_value)
+ covquant2[i].value = covquant[i].value;
}
if (NULL != covquant) pfree(covquant);
memset(nulls, FALSE, values_length);
values[0] = Float8GetDatum(covquant2[call_cntr].quantile);
- values[1] = Float8GetDatum(covquant2[call_cntr].value);
+ if (covquant2[call_cntr].has_value)
+ values[1] = Float8GetDatum(covquant2[call_cntr].value);
+ else
+ nulls[1] = TRUE;
/* build a tuple */
tuple = heap_form_tuple(tupdesc, values, nulls);