MobilityDB 1.1
temporal_tile.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
30#ifndef __TEMPORAL_TILE_H__
31#define __TEMPORAL_TILE_H__
32
33/* MEOS */
34#include "temporal.h"
35
36#define MAXDIMS 4
37
38/*****************************************************************************/
39
44typedef struct SpanBucketState
45{
46 bool done;
47 int i;
49 Temporal *temp; /* NULL when generating bucket list, used for splitting */
56
61typedef struct TboxGridState
62{
63 bool done;
64 int i;
65 double xsize;
68 double value;
71
72/*****************************************************************************/
73
78typedef struct ValueTimeSplitState
79{
80 bool done;
81 int i;
87 int count;
89
90/*****************************************************************************/
91
92extern void span_bucket_set(Datum lower, Datum size, meosType basetype,
93 Span *span);
94extern Span *span_bucket_get(Datum lower, Datum size, meosType basetype);
96 Datum origin);
98
99extern void tbox_tile_get(double value, TimestampTz t, double xsize,
100 int64 tunits, TBox *box);
101extern TboxGridState *tbox_tile_state_make(const TBox *box, double xsize,
102 const Interval *duration, double xorigin, TimestampTz torigin);
104
105/*****************************************************************************/
106
107extern int64 interval_units(const Interval *interval);
108extern TimestampTz timestamptz_bucket1(TimestampTz timestamp, int64 tunits,
109 TimestampTz torigin);
110extern Datum datum_bucket(Datum value, Datum size, Datum offset,
111 meosType basetype);
112
113extern Temporal **temporal_time_split1(const Temporal *temp, TimestampTz start,
114 TimestampTz end, int64 tunits, TimestampTz torigin, int count,
115 TimestampTz **buckets, int *newcount);
116
117Temporal **
119 Datum vorigin, TimestampTz torigin, bool valuesplit, bool timesplit,
120 Datum **value_buckets, TimestampTz **time_buckets, int *newcount);
121
122/*****************************************************************************/
123
124#endif /* __TEMPORAL_TILE_H__ */
125
meosType
Enumeration that defines the built-in and temporal types used in MobilityDB.
Definition: meos_catalog.h:53
int64 TimestampTz
Definition: pg_ext_defs.in.h:19
uintptr_t Datum
Definition: pg_ext_defs.in.h:4
long int int64
Definition: pg_ext_defs.in.h:9
Definition: pg_ext_defs.in.h:24
Datum origin
Definition: temporal_tile.h:51
Datum minvalue
Definition: temporal_tile.h:52
Temporal * temp
Definition: temporal_tile.h:49
bool done
Definition: temporal_tile.h:46
int i
Definition: temporal_tile.h:47
Datum size
Definition: temporal_tile.h:50
Datum value
Definition: temporal_tile.h:54
Datum maxvalue
Definition: temporal_tile.h:53
meosType basetype
Definition: temporal_tile.h:48
Struct for storing the state that persists across multiple calls generating the bucket list.
Definition: temporal_tile.h:45
Structure to represent spans (a.k.a.
Definition: meos.h:70
Structure to represent temporal boxes.
Definition: meos.h:97
bool done
Definition: temporal_tile.h:63
int64 tunits
Definition: temporal_tile.h:66
double value
Definition: temporal_tile.h:68
TimestampTz t
Definition: temporal_tile.h:69
int i
Definition: temporal_tile.h:64
double xsize
Definition: temporal_tile.h:65
TBox box
Definition: temporal_tile.h:67
Struct for storing the state that persists across multiple calls generating the multidimensional grid...
Definition: temporal_tile.h:62
Structure to represent the common structure of temporal values of any temporal subtype.
Definition: meos.h:136
int count
Definition: temporal_tile.h:87
int i
Number of current tile.
Definition: temporal_tile.h:81
Datum size
Definition: temporal_tile.h:82
int64 tunits
Definition: temporal_tile.h:83
Temporal ** fragments
Definition: temporal_tile.h:86
Datum * value_buckets
Definition: temporal_tile.h:84
TimestampTz * time_buckets
Definition: temporal_tile.h:85
bool done
True when all tiles have been processed.
Definition: temporal_tile.h:80
Struct for storing the state that persists across multiple calls to output the temporal fragments.
Definition: temporal_tile.h:79
Definition: pgtz.h:42
Temporal ** temporal_time_split1(const Temporal *temp, TimestampTz start, TimestampTz end, int64 tunits, TimestampTz torigin, int count, TimestampTz **buckets, int *newcount)
Split a temporal value into fragments with respect to period buckets.
Definition: temporal_tile.c:874
void tbox_tile_get(double value, TimestampTz t, double xsize, int64 tunits, TBox *box)
Generate a tile from the a multidimensional grid.
Definition: temporal_tile.c:409
struct ValueTimeSplitState ValueTimeSplitState
Struct for storing the state that persists across multiple calls to output the temporal fragments.
Temporal ** temporal_value_time_split1(Temporal *temp, Datum size, Interval *duration, Datum vorigin, TimestampTz torigin, bool valuesplit, bool timesplit, Datum **value_buckets, TimestampTz **time_buckets, int *newcount)
Split a temporal value with respect to a base value and possibly a temporal grid.
Definition: temporal_tile.c:1412
TboxGridState * tbox_tile_state_make(const TBox *box, double xsize, const Interval *duration, double xorigin, TimestampTz torigin)
Create the initial state that persists across multiple calls of the function.
Definition: temporal_tile.c:436
void tbox_tile_state_next(TboxGridState *state)
Increment the current state to the next tile of the multidimensional grid.
Definition: temporal_tile.c:476
void span_bucket_state_next(SpanBucketState *state)
Increment the current state to the next bucket of the bucket list.
Definition: temporal_tile.c:123
struct SpanBucketState SpanBucketState
Struct for storing the state that persists across multiple calls generating the bucket list.
TimestampTz timestamptz_bucket1(TimestampTz timestamp, int64 tunits, TimestampTz torigin)
Return the initial timestamp of the bucket in which a timestamp falls.
Definition: temporal_tile.c:238
void span_bucket_set(Datum lower, Datum size, meosType basetype, Span *span)
Bucket and tile functions for temporal types.
Definition: temporal_tile.c:64
struct TboxGridState TboxGridState
Struct for storing the state that persists across multiple calls generating the multidimensional grid...
int64 interval_units(const Interval *interval)
Return the interval in the same representation as Postgres timestamps.
Definition: temporal_tile.c:226
Datum datum_bucket(Datum value, Datum size, Datum offset, meosType basetype)
Return the initial value of the bucket in which a number value falls.
Definition: temporal_tile.c:299
SpanBucketState * span_bucket_state_make(const Span *s, Datum size, Datum origin)
Create the initial state that persists across multiple calls of the function.
Definition: temporal_tile.c:100
Span * span_bucket_get(Datum lower, Datum size, meosType basetype)
Generate an integer or float span bucket from a bucket list.
Definition: temporal_tile.c:79