MobilityDB
1.0
|
Generic functions for lifting functions and operators on temporal types. More...
#include "general/lifting.h"
#include <assert.h>
#include <utils/timestamp.h>
#include "general/period.h"
#include "general/timeops.h"
#include "general/temporaltypes.h"
#include "general/temporal_util.h"
Functions | |
static Datum | tfunc_base (Datum value, LiftedFunctionInfo *lfinfo) |
TInstant * | tfunc_tinstant (const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Applies the function with the optional arguments to the temporal value. More... | |
TInstantSet * | tfunc_tinstantset (const TInstantSet *ti, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value. More... | |
TSequence * | tfunc_tsequence (const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value. More... | |
TSequenceSet * | tfunc_tsequenceset (const TSequenceSet *ts, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value. More... | |
Temporal * | tfunc_temporal (const Temporal *temp, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value (dispatch function) More... | |
static Datum | tfunc_base_base (Datum value1, Datum value2, LiftedFunctionInfo *lfinfo) |
TInstant * | tfunc_tinstant_base (const TInstant *inst, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value. More... | |
TInstantSet * | tfunc_tinstantset_base (const TInstantSet *ti, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value. More... | |
static int | tfunc_tsequence_base_scan (TSequence **result, const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value when no turning points should be added and when the function does not have instantaneous discontinuities. More... | |
static int | tfunc_tsequence_base_turnpt (TSequence **result, const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value when turning points should be added. More... | |
static int | tfunc_tsequence_base_discont (TSequence **result, const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value when the function has instantaneuous discontinuties. More... | |
Temporal * | tfunc_tsequence_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value. More... | |
TSequenceSet * | tfunc_tsequenceset_base (const TSequenceSet *ts, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value. More... | |
Temporal * | tfunc_temporal_base (const Temporal *temp, Datum value, LiftedFunctionInfo *lfinfo) |
Applies the function to the temporal value and the base value (dispatch function) More... | |
TInstant * | sync_tfunc_tinstant_tinstant (const TInstant *inst1, const TInstant *inst2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static TInstant * | sync_tfunc_tinstantset_tinstant (const TInstantSet *ti, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static void | lfinfo_invert (LiftedFunctionInfo *lfinfo) |
Invert the arguments of the lfinfo struct. More... | |
static TInstant * | sync_tfunc_tinstant_tinstantset (const TInstant *inst, const TInstantSet *ti, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static TInstant * | sync_tfunc_tsequence_tinstant (const TSequence *seq, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstant * | sync_tfunc_tinstant_tsequence (const TInstant *inst, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstant * | sync_tfunc_tsequenceset_tinstant (const TSequenceSet *ts, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstant * | sync_tfunc_tinstant_tsequenceset (const TInstant *inst, const TSequenceSet *ts, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
TInstantSet * | sync_tfunc_tinstantset_tinstantset (const TInstantSet *ti1, const TInstantSet *ti2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstantSet * | sync_tfunc_tsequence_tinstantset (const TSequence *seq, const TInstantSet *ti, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstantSet * | sync_tfunc_tinstantset_tsequence (const TInstantSet *ti, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstantSet * | sync_tfunc_tsequenceset_tinstantset (const TSequenceSet *ts, const TInstantSet *ti, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static TInstantSet * | sync_tfunc_tinstantset_tsequenceset (const TInstantSet *ti, const TSequenceSet *ts, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function with the optional argument. More... | |
static int | sync_tfunc_tsequence_tsequence_lineareq (TSequence **result, const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Period *inter) |
Synchronizes the temporal values and applies to them the function. More... | |
static int | sync_tfunc_tsequence_tsequence_linearstep (TSequence **result, const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Period *inter) |
Synchronizes the temporal values and applies to them the function. More... | |
static int | sync_tfunc_tsequence_tsequence_discont (TSequence **result, const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Period *inter) |
Synchronizes the temporal values and applies to them the function. More... | |
static int | sync_tfunc_tsequence_tsequence_dispatch (TSequence **result, const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function (dispatch function) More... | |
static Temporal * | sync_tfunc_tsequence_tsequence (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static TSequenceSet * | sync_tfunc_tsequenceset_tsequence (const TSequenceSet *ts, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static TSequenceSet * | sync_tfunc_tsequence_tsequenceset (const TSequence *seq, const TSequenceSet *ts, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
static TSequenceSet * | sync_tfunc_tsequenceset_tsequenceset (const TSequenceSet *ts1, const TSequenceSet *ts2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function. More... | |
Temporal * | sync_tfunc_temporal_temporal (const Temporal *temp1, const Temporal *temp2, LiftedFunctionInfo *lfinfo) |
Synchronizes the temporal values and applies to them the function (dispatch function) More... | |
Generic functions for lifting functions and operators on temporal types.
These functions are used for lifting arithmetic operators (+
, -
, *
, /
), Boolean operators (and
, or
, not
), comparisons (<
, <=
, >
, >=
), distance (<->
), spatial relationships (tcontains
), etc.
The lifting of functions and operators must take into account the following characteristic of the function to be lifted
degrees
for temporal floats or setPrecision
for temporal points.+
or <
) or spatial relationships functions (e.g.,tintersects
).+
or <
) for temporal numbers.tintersects
).tdwithin
).tfloat + tfloat
only needs to synchronize the arguments while tfloat * tfloat
requires in addition to add the turning point, which is the timestamp between the two consecutive synchronized instants in which the linear functions defined by the two segments are equal.Examples
tfloatseq * base => tfunc_tsequence_base
applies the *
operator to each instant and results in a tfloatseq
.tfloatseq < base => tfunc_tsequence_base_discont
applies the <
operator to each instant, if the sequence is equal to the base value in the middle of two consecutive instants add an instantaneous sequence at the crossing. The result is a tfloatseqset
.tfloatseq + tfloatseq => sync_tfunc_tsequence_tsequence
synchronizes the sequences and applies the +
operator to each instant.tfloatseq * tfloatseq => sync_tfunc_tsequence_tsequence
synchronizes the sequences possibly adding the turning points between two consecutive instants and applies the *
operator to each instant. The result is a tfloatseq
.tfloatseq < tfloatseq => sync_tfunc_tsequence_tsequence_discont
synchronizes the sequences, applies the <
operator to each instant, and if there is a crossing in the middle of two consecutive pairs of instants add an instant sequence at the crossing. The result is a tfloatseqset
.A struct named LiftedFunctionInfo
is used to describe the above characteristics of the function to be lifted. Such struct is filled by the calling function and is passed through the dispatch functions. To avoid code redundancy when coping with functions with 2, 3, and 4 arguments, variadic function pointers are used. The idea is sketched next.
An example of use of the lifting functions is given next.