Module airvantage.table Airvantage proxy for staging database tables.
A #table instances should be created with asset.asset.newTable.

Type airvantage.table

airvantage.table.newTable(path, columns, storage, sendPolicy) Creates and returns a #table instance.

Type columnspec

columnspec.asfloat boolean to force encoding of doubles as float (default: false).
columnspec.consolidation consolidation method, mandatory for table:table.newConsolidation calls. Possible values are first, last,max,mean,median,middle,min,sum`.

Note: QuasiPeriodic Vector is not part of AWT-DA 2 and should not be used (it will not be choosen by smallest encoding).

columnspec.factor this is the DeltasVector factor, i.e. the precision to use when serializing floating point numbers. Set it to 1 to round to integer, 0.1 to round all numbers to 1/10 (that is 12.345 will be sent as 12.3). This field is mandatory for deltasvector serialization and optional for smallest (otherwise GCD will be computed, and non-integer numbers will cause fallback to vector).
columnspec.name column name
columnspec.period period for Quasi-periodic vector (number). Mandatory for quasiperiodicvector serialization.
columnspec.serialization serialization method. Possible values are fastest, smallest, list, deltasvector, quasiperiodicvector. Optional, defaults to list.

Type table

table:consolidate(dont_reset) Consolidate the table content to its consolidation table and empties it unless dont_reset is true.
table:newConsolidation(path, columns, storage, consoPolicy, sendPolicy) Creates a table where data will be consolidated.
table:pushRow(row) Adds a row of data to the table.
table:reset() Empty all content in the table.
table:send(dont_reset) Sends the table content to the server and empties it unless dont_reset is true.
table:setMaxRows(n) Sets the maximum number of rows for a given table.

Type airvantage.table

Field(s)

airvantage.table.newTable(path, columns, storage, sendPolicy)

Creates and returns a #table instance.

Parameters

Return values

  1. #table: to store and consolidate structured data.
  2. #nil, #string: error message.

Type columnspec

Column descriptors describes a table column with a name, a serialization method and some serialization options.

Depending on serialization methods, some fields can be either unused, optional or mandatory. Whenever a full column descriptor is expected, a simple string can be passed: in this case, the default serialization method and options will be used.

Field(s)

columnspec.asfloat

boolean to force encoding of doubles as float (default: false).

columnspec.consolidation

consolidation method, mandatory for table:table.newConsolidation calls. Possible values are first, last,max,mean,median,middle,min,sum`.

Note: QuasiPeriodic Vector is not part of AWT-DA 2 and should not be used (it will not be choosen by smallest encoding).

columnspec.factor

this is the DeltasVector factor, i.e. the precision to use when serializing floating point numbers. Set it to 1 to round to integer, 0.1 to round all numbers to 1/10 (that is 12.345 will be sent as 12.3). This field is mandatory for deltasvector serialization and optional for smallest (otherwise GCD will be computed, and non-integer numbers will cause fallback to vector).

#string columnspec.name

column name

columnspec.period

period for Quasi-periodic vector (number). Mandatory for quasiperiodicvector serialization.

columnspec.serialization

serialization method. Possible values are fastest, smallest, list, deltasvector, quasiperiodicvector. Optional, defaults to list.

Type table

Field(s)

table:consolidate(dont_reset)

Consolidate the table content to its consolidation table and empties it unless dont_reset is true.

Parameter

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.

table:newConsolidation(path, columns, storage, consoPolicy, sendPolicy)

Creates a table where data will be consolidated.
When a consolidation table is set, a new table (destination) with the same columns as source table will be created. Each time that rows in source are consolidated, it will flush everything from source and create in a single row in destination. The values in this row depend on consolidation method (average value, minimum, median, ...) which is set for each column. Note that all columns must have an associated consolidation method.

A table can have only one consolidation table (trying to set a consolidation twice will result in a error).

--create source and destination tables local src = asset:newTable('example', {'timestamp', 'temp'}, 'ram', 'never') local dst = src:newConsolidation('consolidated', { timestamp='median', temp='mean' }) -- fill data into src src:pushRow{ timestamp=1, temp=25 } src:pushRow{ timestamp=2, temp=28 } src:pushRow{ timestamp=3, temp=25 } src:consolidate() -- will create the row { timestamp=2, temp=26 } dst:send() -- send only consolidated data to server

The data can be consolidated by:

Note: a consolidation policy can be set only if the send policy of the source table is never (trying to call this method otherwise will result in a error). This means that automatic policies are mutually exclusive for sending and consolidating data. However ${racon.table:send} and ${racon.table:consolidate} methods are always available for more advanced use cases.

Note 2: when the policies of the consolidation of a source and the sending of its destination are the same, consolidation is guaranteed to be done first. However, they are in different policies and if both are triggered at the same time, the behavior is undefined.

Note 3: in order to be consolidated, data must be numeric, any other kind of value will result in inserting null in destination table.

Parameters

Return values

  1. #table: where consolidated data will be stored.
  2. nil followed by an error message otherwise.

table:pushRow(row)

Adds a row of data to the table.
The table needs to be created with racon.asset:newTable().

Parameter

Return values

  1. #string: "ok" on success.
  2. #nil, #string: error message otherwise.

table:reset()

Empty all content in the table.

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.

table:send(dont_reset)

Sends the table content to the server and empties it unless dont_reset is true.

Parameter

Return values

  1. "ok" on success.
  2. #nil, #string: error message otherwise.

table:setMaxRows(n)

Sets the maximum number of rows for a given table.
Once a table's number of rows reaches its max, table content is either sent or consolidated, depending on policies: never policies are not triggered. This means that if a table is consolidated (that is, its send policy is never), data will be consolidated and not sent. Table is emptyed after trigering policy.

Parameter

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.