PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ nd_stats_value_index()

static int nd_stats_value_index ( const ND_STATS stats,
int *  indexes 
)
static

Given a position in the n-d histogram (i,j,k) return the position in the 1-d values array.

Definition at line 426 of file gserialized_estimate.c.

427 {
428  int d;
429  int accum = 1, vdx = 0;
430 
431  /* Calculate the index into the 1-d values array that the (i,j,k,l) */
432  /* n-d histogram coordinate implies. */
433  /* index = x + y * sizex + z * sizex * sizey + m * sizex * sizey * sizez */
434  for ( d = 0; d < (int)(stats->ndims); d++ )
435  {
436  int size = (int)(stats->size[d]);
437  if ( indexes[d] < 0 || indexes[d] >= size )
438  {
439  POSTGIS_DEBUGF(3, " bad index at (%d, %d)", indexes[0], indexes[1]);
440  return -1;
441  }
442  vdx += indexes[d] * accum;
443  accum *= size;
444  }
445  return vdx;
446 }
float4 size[ND_DIMS]

References ND_STATS_T::ndims, and ND_STATS_T::size.

Referenced by compute_gserialized_stats_mode(), estimate_join_selectivity(), and estimate_selectivity().

Here is the caller graph for this function: