MobilityDB 1.1
tpoint_analyze.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2023, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
27 *
28 *****************************************************************************/
29
34#ifndef __TPOINT_ANALYZE_H__
35#define __TPOINT_ANALYZE_H__
36
37/* PostgreSQL */
38#include <postgres.h>
39#include <commands/vacuum.h>
40/* PostGIS */
41#include <liblwgeom.h>
42
43/*****************************************************************************/
44
50#define ND_DIMS 4
51
57typedef struct ND_BOX_T
58{
62
66typedef struct ND_IBOX_T
67{
71
78typedef struct ND_STATS_T
79{
80 /* Dimensionality of the histogram. */
82
83 /* Size of n-d histogram in each dimension. */
85
86 /* Lower-left (min) and upper-right (max) spatial bounds of histogram. */
88
89 /* How many rows in the table itself? */
91
92 /* How many rows were in the sample that built this histogram? */
94
95 /* How many not-Null/Empty features were in the sample? */
97
98 /* How many features actually got sampled in the histogram? */
100
101 /* How many cells in histogram? (sizex*sizey*sizez*sizem) */
103
104 /* How many cells did those histogram features cover? */
105 /* Since we are pro-rating coverage, this number should */
106 /* now always equal histogram_features */
108
109 /* Variable length # of floats for histogram */
112
113extern int nd_box_init(ND_BOX *a);
114extern int nd_box_overlap(const ND_STATS *nd_stats, const ND_BOX *nd_box, ND_IBOX *nd_ibox);
115extern int nd_box_intersects(const ND_BOX *a, const ND_BOX *b, int ndims);
116extern double nd_box_ratio_overlaps(const ND_BOX *b1, const ND_BOX *b2, int ndims);
117extern int nd_increment(ND_IBOX *ibox, int ndims, int *counter);
118extern int nd_stats_value_index(const ND_STATS *stats, const int *indexes);
119
120extern void tpoint_compute_stats(VacAttrStats *stats,
121 AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows);
122
123/*****************************************************************************/
124
125#endif
float float4
Definition: c.h:569
float4 max[ND_DIMS]
Definition: tpoint_analyze.h:60
float4 min[ND_DIMS]
Definition: tpoint_analyze.h:59
N-dimensional box type for calculations, to avoid doing explicit axis conversions from GBOX in all ca...
Definition: tpoint_analyze.h:58
int max[ND_DIMS]
Definition: tpoint_analyze.h:69
int min[ND_DIMS]
Definition: tpoint_analyze.h:68
N-dimensional box index type.
Definition: tpoint_analyze.h:67
float4 value[1]
Definition: tpoint_analyze.h:110
float4 histogram_features
Definition: tpoint_analyze.h:99
float4 size[ND_DIMS]
Definition: tpoint_analyze.h:84
float4 not_null_features
Definition: tpoint_analyze.h:96
float4 histogram_cells
Definition: tpoint_analyze.h:102
float4 cells_covered
Definition: tpoint_analyze.h:107
float4 ndims
Definition: tpoint_analyze.h:81
float4 table_features
Definition: tpoint_analyze.h:90
ND_BOX extent
Definition: tpoint_analyze.h:87
float4 sample_features
Definition: tpoint_analyze.h:93
N-dimensional statistics structure.
Definition: tpoint_analyze.h:79
struct ND_STATS_T ND_STATS
N-dimensional statistics structure.
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 high...
Definition: tpoint_analyze.c:194
int nd_box_intersects(const ND_BOX *a, const ND_BOX *b, int ndims)
Return true if ND_BOX a overlaps b, false otherwise.
Definition: tpoint_analyze.c:227
#define ND_DIMS
Functions for gathering statistics from temporal point columns.
Definition: tpoint_analyze.h:50
int nd_box_init(ND_BOX *a)
Zero out an ND_BOX.
Definition: tpoint_analyze.c:139
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.
Definition: tpoint_analyze.c:374
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.
Definition: tpoint_analyze.c:242
void tpoint_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int sample_rows, double total_rows)
Compute the statistics for temporal point columns (callback function)
Definition: tpoint_analyze.c:1044
struct ND_IBOX_T ND_IBOX
N-dimensional box index type.
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,...
Definition: tpoint_analyze.c:331
struct ND_BOX_T ND_BOX
N-dimensional box type for calculations, to avoid doing explicit axis conversions from GBOX in all ca...