The ts_create() function

The ts_create() function creates a time series.

Syntax

ts_timeseries *
ts_create(MI_CONNECTION *conn,
          mi_string     *calname,
          mi_datetime   *origin, 
          mi_integer    threshold, 
          mi_integer    flags, 
          MI_TYPEID     *typeid,
          mi_integer    nelem,
          mi_string      *container)

ts_timeseries *
ts_create(MI_CONNECTION *conn,
          mi_string     *calname,
          mi_datetime   *origin, 
          mi_integer    threshold, 
          MI_TYPEID     *typeid,
          mi_integer    nelem,
          mi_string      *container,
          mi_integer    hertz)

ts_timeseries *
ts_create(MI_CONNECTION *conn,
          mi_string     *calname,
          mi_datetime   *origin, 
          mi_integer    threshold, 
          mi_integer    flags, 
          MI_TYPEID     *typeid,
          mi_integer    nelem,
          mi_string      *container,
          mi_string      compression)
ts_timeseries *
ts_create(MI_CONNECTION *conn,
          mi_string     *calname,
          mi_datetime   *origin, 
          mi_integer    threshold, 
          mi_integer    flags, 
          MI_TYPEID     *typeid,
          mi_integer    nelem,
          mi_string      *container)
conn
A valid connection.
calname
The name of the calendar.
origin
The time series origin.
threshold
The time series threshold. If the time series stores this number or more elements, it is stored in a container. If the time series holds fewer than this number, it is stored directly in the row that contains it. threshold must be greater than or equal to 0 and less than 256.
flags
0 = Regular time series
1 = Irregular time series
3 = Hertz time series
5 = Compressed time series
typeid
The ID of the new type for the time series to be created.
nelems
The initial number of elements to create space for in the time series. This space is reclaimed if not used, after the time series is written into the database.
container
The container for holding the time series. Can be NULL if the time series can fit in a row or is not going to be assigned to a table.
hertz (Optional)
An integer 1-2047 or 100000 that specifies the number of records per second. Implicitly creates an irregular time series.
The value of the threshold parameter must be 0. The value of the flags parameter must be 3.
compression (Optional)
A string that includes a compression definition for each column in the TimeSeries subtype except the first column. For the syntax of the compression parameter and descriptions of the compression types and attributes, see TSCreateIrr function.
The value of the threshold parameter must be 0. The value of the flags parameter must be 5.

Description

The equivalent SQL function is TSCreate or TSCreateIrr.

If you include the hertz or compression parameter, you must run the ts_create() function within an explicit transaction.

Returns

A pointer to a new time series. The user can free this value by calling ts_free().