MobilityDB  1.0
temporal_tile.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 
31 #ifndef __TEMPORAL_TILE_H__
32 #define __TEMPORAL_TILE_H__
33 
34 #include <postgres.h>
35 #include <fmgr.h>
36 
37 #include "temporal.h"
38 
39 /*****************************************************************************/
40 
45 typedef struct RangeBucketState
46 {
47  bool done;
48  int i;
49  Oid basetypid;
50  Temporal *temp; /* NULL when generating bucket list, used for splitting */
51  Datum size;
52  Datum origin;
53  Datum minvalue;
54  Datum maxvalue;
55  Datum value;
57 
62 typedef struct PeriodBucketState
63 {
64  bool done;
65  int i;
66  int64 tunits;
67  int64 torigin;
68  TimestampTz mint;
69  TimestampTz maxt;
70  TimestampTz t;
72 
77 typedef struct TboxGridState
78 {
79  bool done;
80  int i;
81  double xsize;
82  int64 tunits;
84  double value;
85  TimestampTz t;
87 
88 /*****************************************************************************/
89 
94 typedef struct ValueSplitState
95 {
96  bool done;
97  Datum size;
98  Datum *buckets;
100  int i;
101  int count;
103 
108 typedef struct TimeSplitState
109 {
110  bool done;
111  int64 tunits;
112  TimestampTz *buckets;
114  int i;
115  int count;
117 
122 typedef struct ValueTimeSplitState
123 {
124  bool done;
126  TimestampTz *time_buckets;
128  int i;
129  int count;
131 
132 /*****************************************************************************/
133 
134 extern double float_bucket_internal(double value, double size,
135  double origin);
136 extern TimestampTz timestamptz_bucket_internal(TimestampTz timestamp,
137  int64 tunits, TimestampTz torigin);
138 extern int64 get_interval_units(Interval *interval);
139 
140 extern Datum number_bucket(PG_FUNCTION_ARGS);
141 extern Datum timestamptz_bucket(PG_FUNCTION_ARGS);
142 extern Datum range_bucket_list(PG_FUNCTION_ARGS);
143 extern Datum range_bucket(PG_FUNCTION_ARGS);
144 extern Datum period_bucket_list(PG_FUNCTION_ARGS);
145 extern Datum period_bucket(PG_FUNCTION_ARGS);
146 extern Datum tnumber_value_split(PG_FUNCTION_ARGS);
147 extern Datum temporal_time_split(PG_FUNCTION_ARGS);
148 extern Datum tbox_multidim_grid(PG_FUNCTION_ARGS);
149 extern Datum tbox_multidim_tile(PG_FUNCTION_ARGS);
150 extern Datum tnumber_value_time_split(PG_FUNCTION_ARGS);
151 
152 #endif /* __TEMPORAL_TILE_H__ */
153 
154 /*****************************************************************************/
Struct for storing the state that persists across multiple calls to output the temporal fragments...
Definition: temporal_tile.h:94
Datum tnumber_value_time_split(PG_FUNCTION_ARGS)
Split a temporal value into fragments with respect to period tiles.
Definition: temporal_tile.c:1888
bool done
Definition: temporal_tile.h:79
TimestampTz t
Definition: temporal_tile.h:70
struct TboxGridState TboxGridState
Struct for storing the state that persists across multiple calls generating the multidimensional grid...
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: temporal.h:241
Datum origin
Definition: temporal_tile.h:52
bool done
Definition: temporal_tile.h:64
TimestampTz t
Definition: temporal_tile.h:85
Datum value
Definition: temporal_tile.h:55
int i
Definition: temporal_tile.h:65
Oid basetypid
Definition: temporal_tile.h:49
bool done
Definition: temporal_tile.h:47
Temporal ** fragments
Definition: temporal_tile.h:99
Datum timestamptz_bucket(PG_FUNCTION_ARGS)
Return the initial timestamp of the bucket in which a timestamp falls.
Definition: temporal_tile.c:240
Datum tbox_multidim_tile(PG_FUNCTION_ARGS)
Generate a tile in a multidimensional grid for temporal numbers.
Definition: temporal_tile.c:1196
int64 tunits
Definition: temporal_tile.h:111
struct PeriodBucketState PeriodBucketState
Struct for storing the state that persists across multiple calls generating the bucket list...
bool done
Definition: temporal_tile.h:96
Datum * buckets
Definition: temporal_tile.h:98
Struct for storing the state that persists across multiple calls generating the bucket list...
Definition: temporal_tile.h:62
TimestampTz mint
Definition: temporal_tile.h:68
int64 get_interval_units(Interval *interval)
Returns the interval in the same representation as Postgres timestamps.
Definition: temporal_tile.c:230
Struct for storing the state that persists across multiple calls to output the temporal fragments...
Definition: temporal_tile.h:122
Basic functions for temporal types of any subtype.
int64 tunits
Definition: temporal_tile.h:66
Datum * value_buckets
Definition: temporal_tile.h:125
Struct for storing the state that persists across multiple calls generating the bucket list...
Definition: temporal_tile.h:45
Datum size
Definition: temporal_tile.h:97
Temporal ** fragments
Definition: temporal_tile.h:113
Struct for storing the state that persists across multiple calls to output the temporal fragments...
Definition: temporal_tile.h:108
Datum maxvalue
Definition: temporal_tile.h:54
int i
Definition: temporal_tile.h:80
struct TimeSplitState TimeSplitState
Struct for storing the state that persists across multiple calls to output the temporal fragments...
int64 torigin
Definition: temporal_tile.h:67
Datum range_bucket(PG_FUNCTION_ARGS)
Generate an integer or float range bucket in a bucket list for ranges.
Definition: temporal_tile.c:404
Structure to represent temporal boxes.
Definition: tbox.h:53
Datum temporal_time_split(PG_FUNCTION_ARGS)
Split a temporal value into fragments with respect to period buckets.
Definition: temporal_tile.c:951
bool done
Definition: temporal_tile.h:124
struct ValueTimeSplitState ValueTimeSplitState
Struct for storing the state that persists across multiple calls to output the temporal fragments...
Temporal * temp
Definition: temporal_tile.h:50
Datum range_bucket_list(PG_FUNCTION_ARGS)
Generate a range bucket list.
Definition: temporal_tile.c:331
int64 tunits
Definition: temporal_tile.h:82
struct RangeBucketState RangeBucketState
Struct for storing the state that persists across multiple calls generating the bucket list...
double float_bucket_internal(double value, double size, double origin)
Return the initial value of the bucket in which a float value falls.
Definition: temporal_tile.c:114
TimestampTz maxt
Definition: temporal_tile.h:69
int i
Definition: temporal_tile.h:48
int i
Definition: temporal_tile.h:114
TimestampTz timestamptz_bucket_internal(TimestampTz timestamp, int64 tunits, TimestampTz torigin)
Return the initial timestamp of the bucket in which a timestamp falls.
Definition: temporal_tile.c:188
int i
Definition: temporal_tile.h:128
Datum number_bucket(PG_FUNCTION_ARGS)
Return the initial value of the bucket in which an integer value falls.
Definition: temporal_tile.c:165
Datum tnumber_value_split(PG_FUNCTION_ARGS)
Split a temporal value into fragments with respect to period buckets.
Definition: temporal_tile.c:1754
double value
Definition: temporal_tile.h:84
Datum tbox_multidim_grid(PG_FUNCTION_ARGS)
Generate a multidimensional grid for temporal numbers.
Definition: temporal_tile.c:1124
TimestampTz * buckets
Definition: temporal_tile.h:112
bool done
Definition: temporal_tile.h:110
Datum period_bucket(PG_FUNCTION_ARGS)
Generate a bucket in a bucket list for periods.
Definition: temporal_tile.c:552
Datum minvalue
Definition: temporal_tile.h:53
int count
Definition: temporal_tile.h:101
struct ValueSplitState ValueSplitState
Struct for storing the state that persists across multiple calls to output the temporal fragments...
Datum size
Definition: temporal_tile.h:51
TimestampTz * time_buckets
Definition: temporal_tile.h:126
Temporal ** fragments
Definition: temporal_tile.h:127
int count
Definition: temporal_tile.h:115
double xsize
Definition: temporal_tile.h:81
Datum period_bucket_list(PG_FUNCTION_ARGS)
Generate a period bucket list.
Definition: temporal_tile.c:486
int i
Definition: temporal_tile.h:100
int count
Definition: temporal_tile.h:129
TBOX box
Definition: temporal_tile.h:83
Struct for storing the state that persists across multiple calls generating the multidimensional grid...
Definition: temporal_tile.h:77