![]() |
MobilityDB 1.3
|
Functions for gathering statistics from spatiotemporal columns. More...
#include "pg_geo/tspatial_analyze.h"
#include <assert.h>
#include <float.h>
#include <math.h>
#include <postgres.h>
#include <meos.h>
#include <meos_internal.h>
#include <meos_internal_geo.h>
#include "temporal/set.h"
#include "temporal/temporal.h"
#include "pg_temporal/meos_catalog.h"
#include "pg_temporal/span_analyze.h"
#include "pg_temporal/temporal_analyze.h"
Macros | |
#define | MAX_DIMENSION_WIDTH 1.0E+20 |
Maximum width of a dimension that we'll bother trying to compute statistics on. More... | |
#define | MIN_DIMENSION_WIDTH 0.000000001 |
Minimum width of a dimension that we'll bother trying to compute statistics on. More... | |
#define | NUM_BINS 50 |
How many bins shall we use in figuring out the distribution? More... | |
#define | SDFACTOR 3.25 |
The SD factor restricts the side of the statistics histogram based on the standard deviation of the extent of the data. More... | |
#define | STATISTIC_KIND_2D 103 |
#define | STATISTIC_KIND_ND 102 |
Assign a number to the n-dimensional statistics kind. More... | |
#define | STATISTIC_SLOT_2D 1 |
#define | STATISTIC_SLOT_ND 0 |
Functions | |
static int | cmp_int (const void *a, const void *b) |
Integer comparison function for qsort. More... | |
static int | gbox_ndims (const GBOX *gbox) |
Given that geodetic boxes are X/Y/Z regardless of the underlying geometry dimensionality and other boxes are guided by HAS_Z/HAS_M in their dimesionality, we have a little utility function to make it easy. More... | |
void | gserialized_compute_stats (VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows, int mode) |
Function gserialized_analyze_nd sets this function as a callback on the stats object when called by the ANALYZE command. More... | |
static int | nd_box_array_distribution (const ND_BOX **nd_boxes, int num_boxes, const ND_BOX *extent, int ndims, double *distribution) |
Calculate how much a set of boxes is homogenously distributed or contentrated within one dimension, returning the range_quintile of the overlap counts per cell in a uniform partition of the extent of the dimension. More... | |
static int | nd_box_expand (ND_BOX *nd_box, float expansion_factor) |
Expand an ND_BOX ever so slightly. More... | |
static void | nd_box_from_gbox (const GBOX *gbox, ND_BOX *nd_box) |
Set the values of an ND_BOX from a GBOX. More... | |
int | nd_box_init (ND_BOX *a) |
Initialize to zero an ND_BOX. More... | |
static int | nd_box_init_bounds (ND_BOX *a) |
Prepare an ND_BOX for bounds calculation: set the maximum values to the smallest thing possible and the mininum values to the largest. More... | |
int | nd_box_intersects (const ND_BOX *a, const ND_BOX *b, int ndims) |
Return true if ND_BOX a overlaps b, false otherwise. More... | |
static int | nd_box_merge (const ND_BOX *source, ND_BOX *target) |
Expand the bounds of target to include source. More... | |
int | nd_box_overlap (const ND_STATS *nd_stats, const ND_BOX *nd_box, ND_IBOX *nd_ibox) |
What stats cells overlap with this ND_BOX? More... | |
double | nd_box_ratio_overlaps (const ND_BOX *b1, const ND_BOX *b2, int ndims) |
Return the proportion of b2 that is covered by b1. More... | |
int | nd_increment (ND_IBOX *ibox, int ndims, int *counter) |
Given an n-d index array (counter), and a domain to increment it in (ibox) increment it by one, unless it's already at the max of the domain, in which case return false. More... | |
int | nd_stats_value_index (const ND_STATS *stats, const int *indexes) |
Given a position in the n-d histogram (i,j,k), return the position in the 1-d values array. More... | |
static int | range_quintile (int *vals, int nvals) |
The difference between the fourth and first quintile values, the "inter-quintile range". More... | |
Datum | Spatialset_analyze (PG_FUNCTION_ARGS) |
Compute the statistics for spatial set columns. More... | |
void | spatialset_compute_stats (VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows) |
Compute the statistics for spatial set columns (callback function) More... | |
static double | total_double (const double *vals, int nvals) |
Return the sum of values of a double array. More... | |
Datum | Tspatial_analyze (PG_FUNCTION_ARGS) |
Compute the statistics for spatiotemporal columns. More... | |
void | tspatial_compute_stats (VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows) |
Compute the statistics for spatiotemporal columns (callback function) More... | |
Functions for gathering statistics from spatiotemporal columns.
Various kind of statistics are collected for both the value and the time dimensions of temporal types. The kind of statistics depends on the subtype of the temporal type, which is defined in the table schema by the typmod
attribute. Please refer to the PostgreSQL file pg_statistic_d.h
and the PostGIS file gserialized_estimate.c
for more information about the statistics collected.
For the spatial dimension, the statistics collected are the same for all subtypes. These statistics are obtained by calling the PostGIS function gserialized_analyze_nd
.
stakind
contains the type of statistics which is STATISTIC_SLOT_2D
.stanumbers
stores the 2D histogram of occurrence of features.stakind
contains the type of statistics which is STATISTIC_SLOT_ND
.stanumbers
stores the ND histogram of occurrence of features.For the time dimension, the statistics collected in Slots 3 and 4 depend on the subtype. Please refer to file temporal_analyze.c for more information.