MobilityDB
1.0
|
Functions for gathering statistics from temporal point columns. More...
#include "point/tpoint_analyze.h"
#include <assert.h>
#include <float.h>
#include <access/htup_details.h>
#include <executor/spi.h>
#include <utils/lsyscache.h>
#include "general/period.h"
#include "general/time_analyze.h"
#include "general/temporal.h"
#include "general/tempcache.h"
#include "general/temporal_util.h"
#include "general/temporal_analyze.h"
#include "point/postgis.h"
#include "point/tpoint.h"
#include "point/tpoint_spatialfuncs.h"
#include "npoint/tnpoint_spatialfuncs.h"
Macros | |
#define | STATISTIC_KIND_ND 102 |
Assign a number to the n-dimensional statistics kind. More... | |
#define | STATISTIC_KIND_2D 103 |
#define | STATISTIC_SLOT_ND 0 |
#define | STATISTIC_SLOT_2D 1 |
#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 | MIN_DIMENSION_WIDTH 0.000000001 |
Minimum width of a dimension that we'll bother trying to compute statistics on. More... | |
#define | MAX_DIMENSION_WIDTH 1.0E+20 |
Maximum 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... | |
Functions | |
static int | cmp_int (const void *a, const void *b) |
Integer comparison function for qsort. More... | |
int | nd_box_init (ND_BOX *a) |
Zero out an ND_BOX. More... | |
int | nd_box_init_bounds (ND_BOX *a) |
Prepare an ND_BOX for bounds calculation: set the maxes to the smallest thing possible and the mins to the largest. More... | |
static double | total_double (const double *vals, int nvals) |
Returns the sum of values of the double array. More... | |
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? Put the lowest cell addresses in ND_IBOX->min and the highest in ND_IBOX->max. More... | |
int | nd_box_intersects (const ND_BOX *a, const ND_BOX *b, int ndims) |
Returns true if ND_BOX a overlaps b, false otherwise. More... | |
double | nd_box_ratio_overlaps (const ND_BOX *b1, const ND_BOX *b2, int ndims) |
Returns the proportion of b2 that is covered by b1. More... | |
void | nd_box_from_gbox (const GBOX *gbox, ND_BOX *nd_box) |
Set the values of an ND_BOX from a GBOX. More... | |
static int | range_quintile (int *vals, int nvals) |
The difference between the fourth and first quintile values, the "inter-quintile range". 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... | |
static int | nd_box_expand (ND_BOX *nd_box, double expansion_factor) |
Expand an ND_BOX ever so slightly. More... | |
static 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 | 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 of the overlap counts per cell in a uniform partition of the extent of the dimension. 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) |
The gserialized_analyze_nd sets this function as a callback on the stats object when called by the ANALYZE command. More... | |
static void | tpoint_compute_stats (VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows) |
Compute the statistics for temporal point columns (callback function) More... | |
PGDLLEXPORT Datum | tpoint_analyze (PG_FUNCTION_ARGS) |
Compute the statistics for temporal point columns. More... | |
Functions for gathering statistics from temporal point 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 histrogram 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.