streaming_algorithms  0.0.5
A collection of streaming data algorithms
Typedefs | Functions
time_series.h File Reference

Time series data storage (stripped down circular buffer) More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for time_series.h:

Go to the source code of this file.

Typedefs

typedef struct sa_time_series_int sa_time_series_int
 

Functions

sa_time_series_intsa_create_time_series_int (int rows, uint64_t ns_per_row)
 Allocates and initializes the data structure. More...
 
void sa_init_time_series_int (sa_time_series_int *ts)
 Zeros out the time series. More...
 
int sa_add_time_series_int (sa_time_series_int *ts, uint64_t ns, int v)
 Adds the specified value to the time series row. More...
 
int sa_set_time_series_int (sa_time_series_int *ts, uint64_t ns, int v)
 Sets the time series row to the specified value. More...
 
int sa_get_time_series_int (sa_time_series_int *ts, uint64_t ns)
 Gets the value of the time series row. More...
 
uint64_t sa_timestamp_time_series_int (sa_time_series_int *ts)
 Returns the timestamp of the most recent row. More...
 
int sa_mp_time_series_int (sa_time_series_int *ts, uint64_t ns, int n, int m, double percent, double *mp[], int *mpi[])
 Computes the matrix profile for a time series or sub set of the series. More...
 
void sa_destroy_time_series_int (sa_time_series_int *ts)
 Free the associated memory. More...
 
char * sa_serialize_time_series_int (sa_time_series_int *ts, size_t *len)
 Serialize the internal state to a buffer. More...
 
int sa_deserialize_time_series_int (sa_time_series_int *ts, const char *buf, size_t len)
 Restores the internal state from the serialized output. More...
 

Detailed Description

Time series data storage (stripped down circular buffer)

Definition in file time_series.h.

Typedef Documentation

Definition at line 15 of file time_series.h.

Function Documentation

int sa_add_time_series_int ( sa_time_series_int ts,
uint64_t  ns,
int  v 
)

Adds the specified value to the time series row.

Parameters
tsPointer to time_series_int
nsTimestamp (nanoseconds since Jan 1 1970) associated with value
vValue to add
Returns
current value
sa_time_series_int* sa_create_time_series_int ( int  rows,
uint64_t  ns_per_row 
)

Allocates and initializes the data structure.

Parameters
rowsNumber of observation slots
ns_per_rowNanoseconds represented in each row
Returns
Pointer to time_series_int
int sa_deserialize_time_series_int ( sa_time_series_int ts,
const char *  buf,
size_t  len 
)

Restores the internal state from the serialized output.

Parameters
tsPointer to time_series_int
bufBuffer containing the output of serialize_time_series_int
lenLength of the buffer
Returns
0 = success 1 = invalid buffer length 2 = invalid cnt 3 = mis-matched dimensions
void sa_destroy_time_series_int ( sa_time_series_int ts)

Free the associated memory.

Parameters
tsPointer to time_series_int
int sa_get_time_series_int ( sa_time_series_int ts,
uint64_t  ns 
)

Gets the value of the time series row.

Parameters
tsPointer to time_series_int
nsTimestamp (nanoseconds since Jan 1 1970) of the row
Returns
current value
void sa_init_time_series_int ( sa_time_series_int ts)

Zeros out the time series.

Parameters
tsPointer to time_series_int
int sa_mp_time_series_int ( sa_time_series_int ts,
uint64_t  ns,
int  n,
int  m,
double  percent,
double *  mp[],
int *  mpi[] 
)

Computes the matrix profile for a time series or sub set of the series.

See: http://www.cs.ucr.edu/~eamonn/MatrixProfile.html

Parameters
tsPointer to time_series_int
nsThe start of the interval to analyze
nSequence length (<= ts->rows)
mSub-sequence length (n / 4 >= m > 3)
percentPercentage of data to base the calculation on (0.0 < percent <= 100). Use less than 100 to produce an estimate of the matrix profile trading accuracy for speed.
mpReturned pointer to the matrix profile array (MUST be freed by the caller)
mpiReturned pointer to the matrix profile index array (MUST be freed by the caller)
Returns
int Length of the returned matrix profile arrays (0 on failure). The mp/i pointers are not modified on failure.
char* sa_serialize_time_series_int ( sa_time_series_int ts,
size_t *  len 
)

Serialize the internal state to a buffer.

Parameters
tsPointer to time_series_int
lenLength of the returned buffer
Returns
char* Serialized representation MUST be freed by the caller
int sa_set_time_series_int ( sa_time_series_int ts,
uint64_t  ns,
int  v 
)

Sets the time series row to the specified value.

Parameters
tsPointer to time_series_int
nsTimestamp (nanoseconds since Jan 1 1970) associated with value
vValue to set
Returns
current value
uint64_t sa_timestamp_time_series_int ( sa_time_series_int ts)

Returns the timestamp of the most recent row.

Parameters
tsPointer to time_series_int
Returns
Timestamp (nanoseconds since Jan 1 1970)