MobilityDB  1.0
temporal_analyze.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * This MobilityDB code is provided under The PostgreSQL License.
4  *
5  * Copyright (c) 2016-2021, Université libre de Bruxelles and MobilityDB
6  * contributors
7  *
8  * MobilityDB includes portions of PostGIS version 3 source code released
9  * under the GNU General Public License (GPLv2 or later).
10  * Copyright (c) 2001-2021, PostGIS contributors
11  *
12  * Permission to use, copy, modify, and distribute this software and its
13  * documentation for any purpose, without fee, and without a written
14  * agreement is hereby granted, provided that the above copyright notice and
15  * this paragraph and the following two paragraphs appear in all copies.
16  *
17  * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
18  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
19  * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
20  * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
21  * OF SUCH DAMAGE.
22  *
23  * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
26  * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
27  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 
28  *
29  *****************************************************************************/
30 
36 #ifndef __TEMPORAL_ANALYZE_H__
37 #define __TEMPORAL_ANALYZE_H__
38 
39 #include <postgres.h>
40 #include <catalog/pg_type.h>
41 #include <commands/vacuum.h>
42 #include <utils/rangetypes.h>
43 #include <parser/parse_oper.h>
44 #include <statistics/extended_stats_internal.h>
45 
46 /*
47  * Extra data for compute_stats function
48  * Structure based on the ArrayAnalyzeExtraData from file array_typanalyze.c
49  */
50 typedef struct
51 {
52  /* Information about array element type */
53  Oid type_id;
54  Oid eq_opr;
55  Oid lt_opr;
56  bool typbyval;
57  int16 typlen;
58  char typalign;
59 
60  /* Information about the value part of array element */
65  int16 value_typlen;
67 
68  /* Information about the temporal part of array element */
73  int16 time_typlen;
75 
76  /*
77  * Lookup data for element type's comparison and hash functions (these are
78  * in the type's typcache entry, which we expect to remain valid over the
79  * lifespan of the ANALYZE run)
80  */
81  FmgrInfo *cmp;
82  FmgrInfo *hash;
83  FmgrInfo *value_cmp;
84  FmgrInfo *value_hash;
85  FmgrInfo *time_cmp;
86  FmgrInfo *time_hash;
87 
88  /* Saved state from std_typanalyze() */
89  AnalyzeAttrComputeStatsFunc std_compute_stats;
92 
93 /*
94  * Extra information used by the default analysis routines
95  */
96 typedef struct
97 {
98  int count;
99  int first;
100 } ScalarMCVItem;
101 
102 typedef struct
103 {
104  SortSupport ssup;
105  int *tupnoLink;
107 
108 /*****************************************************************************
109  * Statistics information for temporal types
110  *****************************************************************************/
111 
112 extern void temporal_extra_info(VacAttrStats *stats);
113 
114 extern void tinstant_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
115  int samplerows, double totalrows);
116 
117 extern void tsequenceset_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
118  int samplerows, double totalrows);
119 
120 /*****************************************************************************/
121 
122 extern Datum temporal_analyze(PG_FUNCTION_ARGS);
123 extern Datum tnumber_analyze(PG_FUNCTION_ARGS);
124 
125 extern Datum generic_analyze(FunctionCallInfo fcinfo,
126  void (*functemp)(VacAttrStats *, AnalyzeAttrFetchFunc, int, double));
127 
128 /*****************************************************************************/
129 
130 #endif
131 
int first
values[] index of first occurrence
Definition: temporal_analyze.h:99
FmgrInfo * time_cmp
Definition: temporal_analyze.h:85
Oid lt_opr
default less than operator&#39;s OID
Definition: temporal_analyze.h:55
Oid value_type_id
element type&#39;s OID
Definition: temporal_analyze.h:61
char value_typalign
Definition: temporal_analyze.h:66
char typalign
Definition: temporal_analyze.h:58
Definition: temporal_analyze.h:50
bool time_typbyval
physical properties of element type
Definition: temporal_analyze.h:72
Datum generic_analyze(FunctionCallInfo fcinfo, void(*functemp)(VacAttrStats *, AnalyzeAttrFetchFunc, int, double))
Generic analyze function for temporal columns.
Definition: temporal_analyze.c:544
FmgrInfo * hash
Definition: temporal_analyze.h:82
SortSupport ssup
Definition: temporal_analyze.h:104
Oid value_lt_opr
default less than operator&#39;s OID
Definition: temporal_analyze.h:63
Oid time_eq_opr
default equality operator&#39;s OID
Definition: temporal_analyze.h:70
FmgrInfo * value_hash
Definition: temporal_analyze.h:84
FmgrInfo * value_cmp
Definition: temporal_analyze.h:83
bool value_typbyval
physical properties of element type
Definition: temporal_analyze.h:64
Datum temporal_analyze(PG_FUNCTION_ARGS)
Compute the statistics for temporal columns where only the time dimension is considered.
Definition: temporal_analyze.c:577
Oid value_eq_opr
default equality operator&#39;s OID
Definition: temporal_analyze.h:62
Definition: temporal_analyze.h:96
void * std_extra_data
Definition: temporal_analyze.h:90
Oid time_type_id
element type&#39;s OID
Definition: temporal_analyze.h:69
char time_typalign
Definition: temporal_analyze.h:74
int16 value_typlen
Definition: temporal_analyze.h:65
void tinstant_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
Oid type_id
element type&#39;s OID
Definition: temporal_analyze.h:53
void temporal_extra_info(VacAttrStats *stats)
Collect extra information about the temporal type and its base and time types.
Definition: temporal_analyze.c:443
int * tupnoLink
Definition: temporal_analyze.h:105
FmgrInfo * time_hash
Definition: temporal_analyze.h:86
int16 typlen
Definition: temporal_analyze.h:57
bool typbyval
physical properties of element type
Definition: temporal_analyze.h:56
Datum tnumber_analyze(PG_FUNCTION_ARGS)
Compute the statistics for temporal number columns.
Definition: temporal_analyze.c:587
AnalyzeAttrComputeStatsFunc std_compute_stats
Definition: temporal_analyze.h:89
Oid time_lt_opr
default less than operator&#39;s OID
Definition: temporal_analyze.h:71
int16 time_typlen
Definition: temporal_analyze.h:73
void tsequenceset_compute_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
Oid eq_opr
default equality operator&#39;s OID
Definition: temporal_analyze.h:54
FmgrInfo * cmp
Definition: temporal_analyze.h:81
Definition: temporal_analyze.h:102
int count
Definition: temporal_analyze.h:98