![]() |
MobilityDB 1.3
|
Generic functions for lifting functions and operators on temporal types. More...
#include "temporal/lifting.h"
#include <assert.h>
#include <postgres.h>
#include <utils/timestamp.h>
#include <meos.h>
#include <meos_internal.h>
#include "temporal/temporal_restrict.h"
#include "temporal/tsequence.h"
#include "temporal/tsequenceset.h"
#include "temporal/type_util.h"
#include "geo/tgeo_spatialfuncs.h"
Functions | |
static int | eafunc_tcontseq_tcontseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function (dispatch function) More... | |
static int | eafunc_tcontseq_tcontseq_discfn (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Span *inter) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tcontseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tcontseq_tinstant (const TSequence *seq, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tcontseq_tsequenceset (const TSequence *seq, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tdiscseq_tcontseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tdiscseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tdiscseq_tinstant (const TSequence *seq, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tdiscseq_tsequenceset (const TSequence *seq, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tdiscstepseq_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal discrete or step sequence and a base value. More... | |
int | eafunc_temporal_base (const Temporal *temp, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and a base value. More... | |
int | eafunc_temporal_temporal (const Temporal *temp1, const Temporal *temp2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tinstant_base (const TInstant *inst, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal instant and a base value. More... | |
static int | eafunc_tinstant_tcontseq (const TInstant *inst, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tinstant_tdiscseq (const TInstant *inst, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tinstant_tinstant (const TInstant *inst1, const TInstant *inst2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tinstant_tsequenceset (const TInstant *inst, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tlinearseq_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal continuous sequence and a base value. More... | |
static int | eafunc_tsequence_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal sequence and a base value (dispatch function) More... | |
static int | eafunc_tsequenceset_base (const TSequenceSet *ss, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal sequence set and a base value. More... | |
static int | eafunc_tsequenceset_tcontseq (const TSequenceSet *ss, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tsequenceset_tdiscseq (const TSequenceSet *ss, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tsequenceset_tinstant (const TSequenceSet *ss, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tsequenceset_tsequenceset (const TSequenceSet *ss1, const TSequenceSet *ss2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | eafunc_tstepseq_tstepseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Span *inter) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static void | lfinfo_invert_args (LiftedFunctionInfo *lfinfo) |
Invert the arguments of the lfinfo struct. More... | |
static Datum | tfunc_base (Datum value, LiftedFunctionInfo *lfinfo) |
Apply the variadic function with the optional arguments to a base value. More... | |
static Datum | tfunc_base_base (Datum value1, Datum value2, LiftedFunctionInfo *lfinfo) |
Temporal * | tfunc_tcontseq_tcontseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | tfunc_tcontseq_tcontseq_discfn (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Span *inter, TSequence **result) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | tfunc_tcontseq_tcontseq_dispatch (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, TSequence **result) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static int | tfunc_tcontseq_tcontseq_single (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Span *inter, TSequence **result) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TSequence * | tfunc_tcontseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TInstant * | tfunc_tcontseq_tinstant (const TSequence *seq, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function with an optional argument. More... | |
static Temporal * | tfunc_tcontseq_tsequenceset (const TSequence *seq, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TSequence * | tfunc_tdiscseq_tcontseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
TSequence * | tfunc_tdiscseq_tdiscseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TInstant * | tfunc_tdiscseq_tinstant (const TSequence *seq, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TSequence * | tfunc_tdiscseq_tsequenceset (const TSequence *seq, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
Temporal * | tfunc_temporal (const Temporal *temp, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value (dispatch function) More... | |
Temporal * | tfunc_temporal_base (const Temporal *temp, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and a base value (dispatch function) More... | |
Temporal * | tfunc_temporal_temporal (const Temporal *temp1, const Temporal *temp2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
TInstant * | tfunc_tinstant (const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Apply a lifted function with the optional arguments to a temporal instant. More... | |
TInstant * | tfunc_tinstant_base (const TInstant *inst, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and the base value. More... | |
static TInstant * | tfunc_tinstant_tcontseq (const TInstant *inst, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TInstant * | tfunc_tinstant_tdiscseq (const TInstant *inst, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
TInstant * | tfunc_tinstant_tinstant (const TInstant *inst1, const TInstant *inst2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TInstant * | tfunc_tinstant_tsequenceset (const TInstant *inst, const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
Temporal * | tfunc_tlinearseq_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and a base value. More... | |
static int | tfunc_tlinearseq_base_discfn (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo, TSequence **result) |
Apply a lifted function to a temporal value and a base value when the function has instantaneuous discontinuties. More... | |
static int | tfunc_tlinearseq_base_turnpt (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo, TSequence **result) |
Apply a lifted function to a temporal value and a base value when turning points should be added. More... | |
static int | tfunc_tlinearseq_tstepseq (const TSequence *seq1, const TSequence *seq2, LiftedFunctionInfo *lfinfo, Span *inter, TSequence **result) |
Synchronize two temporal values and apply to them a lifted function. More... | |
TSequence * | tfunc_tsequence (const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal sequence. More... | |
TSequence * | tfunc_tsequence_base (const TSequence *seq, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and a base value. More... | |
TSequenceSet * | tfunc_tsequenceset (const TSequenceSet *ss, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal sequence set. More... | |
TSequenceSet * | tfunc_tsequenceset_base (const TSequenceSet *ss, Datum value, LiftedFunctionInfo *lfinfo) |
Apply a lifted function to a temporal value and a base value. More... | |
static Temporal * | tfunc_tsequenceset_tcontseq (const TSequenceSet *ss, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TSequence * | tfunc_tsequenceset_tdiscseq (const TSequenceSet *ss, const TSequence *seq, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
static TInstant * | tfunc_tsequenceset_tinstant (const TSequenceSet *ss, const TInstant *inst, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted function. More... | |
TSequenceSet * | tfunc_tsequenceset_tsequenceset (const TSequenceSet *ss1, const TSequenceSet *ss2, LiftedFunctionInfo *lfinfo) |
Synchronize two temporal values and apply to them a lifted 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 round
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
tfloat_degrees => tfunc_temporal
applies the degrees
function to each instant.tfloatseq + base => tfunc_tsequence_base
applies the +
operator to each instant and results in a tfloatseq
.tfloatseq < base => tfunc_tlinearseq_base_discfn
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 => tfunc_tcontseq_tcontseq
synchronizes the sequences and applies the +
operator to each instant.tfloatseq * tfloatseq => tfunc_tcontseq_tcontseq
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 => tfunc_tcontseq_tcontseq_discfn
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.