PostGIS  2.5.0dev-r@@SVN_REVISION@@
static ND_STATS* pg_nd_stats_from_tuple ( HeapTuple  stats_tuple,
int  mode 
)
static

Definition at line 874 of file gserialized_estimate.c.

References STATISTIC_KIND_2D, and STATISTIC_KIND_ND.

Referenced by gserialized_gist_sel(), and pg_get_nd_stats().

875 {
876  int stats_kind = STATISTIC_KIND_ND;
877  int rv;
878  ND_STATS *nd_stats;
879 
880  /* If we're in 2D mode, set the kind appropriately */
881  if ( mode == 2 ) stats_kind = STATISTIC_KIND_2D;
882 
883  /* Then read the geom status histogram from that */
884 
885 #if POSTGIS_PGSQL_VERSION < 100
886  float4 *floatptr;
887  int nvalues;
888 
889  rv = get_attstatsslot(stats_tuple, 0, 0, stats_kind, InvalidOid,
890  NULL, NULL, NULL, &floatptr, &nvalues);
891 
892  if ( ! rv ) {
893  POSTGIS_DEBUGF(2,
894  "no slot of kind %d in stats tuple", stats_kind);
895  return NULL;
896  }
897 
898  /* Clone the stats here so we can release the attstatsslot immediately */
899  nd_stats = palloc(sizeof(float) * nvalues);
900  memcpy(nd_stats, floatptr, sizeof(float) * nvalues);
901 
902  /* Clean up */
903  free_attstatsslot(0, NULL, 0, floatptr, nvalues);
904 #else /* PostgreSQL 10 or higher */
905  AttStatsSlot sslot;
906  rv = get_attstatsslot(&sslot, stats_tuple, stats_kind, InvalidOid,
907  ATTSTATSSLOT_NUMBERS);
908  if ( ! rv ) {
909  POSTGIS_DEBUGF(2,
910  "no slot of kind %d in stats tuple", stats_kind);
911  return NULL;
912  }
913 
914  /* Clone the stats here so we can release the attstatsslot immediately */
915  nd_stats = palloc(sizeof(float4) * sslot.nnumbers);
916  memcpy(nd_stats, sslot.numbers, sizeof(float4) * sslot.nnumbers);
917 
918  free_attstatsslot(&sslot);
919 #endif
920 
921  return nd_stats;
922 }
#define STATISTIC_KIND_2D
N-dimensional statistics structure.
#define STATISTIC_KIND_ND

Here is the caller graph for this function: