MobilityDB
1.0
|
Bucket and tile functions for temporal types. More...
#include <postgres.h>
#include <assert.h>
#include <float.h>
#include <funcapi.h>
#include <access/htup_details.h>
#include <utils/builtins.h>
#include <utils/datetime.h>
#include "general/temporal_tile.h"
#include "general/tempcache.h"
#include "general/period.h"
#include "general/periodset.h"
#include "general/timeops.h"
#include "general/rangetypes_ext.h"
#include "general/temporal.h"
#include "general/temporal_util.h"
Functions | |
static int | int_bucket_internal (int value, int size, int offset) |
Return the initial value of the bucket in which an integer value falls. More... | |
double | float_bucket_internal (double value, double size, double offset) |
Return the initial value of the bucket in which a float value falls. More... | |
static Datum | number_bucket_internal (Datum value, Datum size, Datum offset, Oid type) |
Return the initial value of the bucket in which a number value falls. More... | |
PGDLLEXPORT Datum | number_bucket (PG_FUNCTION_ARGS) |
Return the initial value of the bucket in which an integer value falls. More... | |
TimestampTz | timestamptz_bucket_internal (TimestampTz timestamp, int64 size, TimestampTz offset) |
Return the initial timestamp of the bucket in which a timestamp falls. More... | |
int64 | get_interval_units (Interval *interval) |
Returns the interval in the same representation as Postgres timestamps. More... | |
PGDLLEXPORT Datum | timestamptz_bucket (PG_FUNCTION_ARGS) |
Return the initial timestamp of the bucket in which a timestamp falls. More... | |
static RangeType * | range_bucket_get (Datum value, Datum size, Oid type) |
Generate an integer or float range bucket from a bucket list. More... | |
static RangeBucketState * | range_bucket_state_make (Temporal *temp, RangeType *r, Datum size, Datum origin) |
Create the initial state that persists across multiple calls of the function. More... | |
static void | range_bucket_state_next (RangeBucketState *state) |
Increment the current state to the next bucket of the bucket list. More... | |
Datum | range_bucket_list (PG_FUNCTION_ARGS) |
Generate a range bucket list. More... | |
Datum | range_bucket (PG_FUNCTION_ARGS) |
Generate an integer or float range bucket in a bucket list for ranges. More... | |
static Period * | period_bucket_get (TimestampTz t, int64 tunits, TimestampTz torigin) |
Generate period bucket from a bucket list. More... | |
static PeriodBucketState * | period_bucket_state_make (Period *p, int64 tunits, TimestampTz torigin) |
Create the initial state that persists across multiple calls of the function. More... | |
static void | period_bucket_state_next (PeriodBucketState *state) |
Increment the current state to the next bucket of the bucket list. More... | |
Datum | period_bucket_list (PG_FUNCTION_ARGS) |
Generate a period bucket list. More... | |
Datum | period_bucket (PG_FUNCTION_ARGS) |
Generate a bucket in a bucket list for periods. More... | |
TimeSplitState * | time_split_state_make (int64 tunits, TimestampTz *buckets, Temporal **fragments, int count) |
Create the initial state that persists across multiple calls of the function. More... | |
void | time_split_state_next (TimeSplitState *state) |
Increment the current state to output the next split. More... | |
static TInstant ** | tinstant_time_split (const TInstant *inst, int64 tunits, TimestampTz torigin, TimestampTz **buckets, int *newcount) |
Split a temporal value into an array of fragments according to time buckets. More... | |
static TInstantSet ** | tinstantset_time_split (const TInstantSet *ti, TimestampTz start, TimestampTz end, int64 tunits, int count, TimestampTz **buckets, int *newcount) |
Split a temporal value into an array of fragments according to time buckets. More... | |
static int | tsequence_time_split1 (TSequence **result, TimestampTz *times, const TSequence *seq, TimestampTz start, TimestampTz end, int64 tunits, int count) |
Split a temporal value into an array of fragments according to period buckets. More... | |
static TSequence ** | tsequence_time_split (const TSequence *seq, TimestampTz start, TimestampTz end, int64 tunits, int count, TimestampTz **buckets, int *newcount) |
Split a temporal value into an array of fragments according to period buckets. More... | |
static TSequenceSet ** | tsequenceset_time_split (const TSequenceSet *ts, TimestampTz start, TimestampTz end, int64 tunits, int count, TimestampTz **buckets, int *newcount) |
Split a temporal value into an array of disjoint fragments. More... | |
Temporal ** | temporal_time_split_internal (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 (dispatch function). More... | |
Datum | temporal_time_split (PG_FUNCTION_ARGS) |
Split a temporal value into fragments with respect to period buckets. More... | |
static TBOX * | tbox_tile_get (double value, TimestampTz t, double xsize, int64 tunits) |
Generate a tile from the a multidimensional grid. More... | |
static TboxGridState * | tbox_tile_state_make (TBOX *box, double xsize, int64 tunits, double xorigin, TimestampTz torigin) |
Create the initial state that persists across multiple calls of the function. More... | |
static void | tbox_tile_state_next (TboxGridState *state) |
Increment the current state to the next tile of the multidimensional grid. More... | |
Datum | tbox_multidim_grid (PG_FUNCTION_ARGS) |
Generate a multidimensional grid for temporal numbers. More... | |
Datum | tbox_multidim_tile (PG_FUNCTION_ARGS) |
Generate a tile in a multidimensional grid for temporal numbers. More... | |
ValueSplitState * | value_split_state_make (Datum size, Datum *buckets, Temporal **fragments, int count) |
Create the initial state that persists across multiple calls of the function. More... | |
void | value_split_state_next (ValueSplitState *state) |
Increment the current state to output the next split. More... | |
static int | bucket_position (Datum value, Datum size, Datum origin, Oid type) |
Get the bucket number in the bucket space that contains the value. More... | |
static TInstant ** | tnumberinst_value_split (const TInstant *inst, Datum start_bucket, Datum size, Datum **buckets, int *newcount) |
Split a temporal value into an array of fragments according to value buckets. More... | |
static TInstantSet ** | tnumberinstset_value_split (const TInstantSet *ti, Datum start_bucket, Datum size, int count, Datum **buckets, int *newcount) |
Split a temporal value into an array of fragments according to value buckets. More... | |
static void | tnumberseq_step_value_split (TSequence **result, int *numseqs, int numcols, const TSequence *seq, Datum start_bucket, Datum size, int count) |
Split a temporal value into an array of fragments according to value buckets. More... | |
static void | tnumberseq_linear_value_split (TSequence **result, int *numseqs, int numcols, const TSequence *seq, Datum start_bucket, Datum size, int count) |
Split a temporal value into an array of fragments according to value buckets. More... | |
static TSequenceSet ** | tnumberseq_value_split (const TSequence *seq, Datum start_bucket, Datum size, int count, Datum **buckets, int *newcount) |
Split a temporal value into an array of fragments according to value buckets. More... | |
static TSequenceSet ** | tnumberseqset_value_split (const TSequenceSet *ts, Datum start_bucket, Datum size, int count, Datum **buckets, int *newcount) |
Split a temporal value into an array of fragments according to value buckets. More... | |
Temporal ** | tnumber_value_split_internal (Temporal *temp, Datum start_bucket, Datum size, int count, Datum **buckets, int *newcount) |
Datum | tnumber_value_split (PG_FUNCTION_ARGS) |
Split a temporal value into fragments with respect to period buckets. More... | |
ValueTimeSplitState * | value_time_split_state_make (Datum *value_buckets, TimestampTz *time_buckets, Temporal **fragments, int count) |
Create the initial state that persists across multiple calls of the function. More... | |
void | value_time_split_state_next (ValueTimeSplitState *state) |
Increment the current state to the next tile of the multidimensional grid. More... | |
Datum | tnumber_value_time_split (PG_FUNCTION_ARGS) |
Split a temporal value into fragments with respect to period tiles. More... | |
Bucket and tile functions for temporal types.
The time bucket functions are inspired from TimescaleDB. https://docs.timescale.com/latest/api#time_bucket