airvantage.table
Airvantage proxy for staging database tables.
airvantage.table
airvantage.table.newTable(path, columns, storage, sendPolicy) | Creates and returns a #table instance. |
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 |
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 . |
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. |
airvantage.table
airvantage.table.newTable(path, columns, storage, sendPolicy)
path
:
(relative to the asset root) where the data will be sent.
columns
:
list of either racon.table.columnspec or column names (to
use default values).
storage
:
either "file" or "ram", how the table must be persisted.
sendPolicy
:
name of the policy controlling when the table content is
sent to the server.
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.
columnspec.asfloat
columnspec.consolidation
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
deltasvector
serialization and optional for
smallest
(otherwise GCD will be computed, and non-integer numbers will
cause fallback to vector).
columnspec.name
columnspec.period
quasiperiodicvector
serialization.
columnspec.serialization
fastest
,
smallest
, list
, deltasvector
, quasiperiodicvector
. Optional,
defaults to list
.
table
table:consolidate(dont_reset)
dont_reset
:
if true, the table content is not emptied after being
consolidated.
table:newConsolidation(path, columns, storage, consoPolicy, sendPolicy)
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.
path
:
(relative to the asset root) where the data will be sent.
columns
:
either a list of racon.table.columnspec with consolidation
field and the same names as source table which associate each column
name (key) to its consolidation method (value), like in example.
storage
:
either "file" or "ram", how the table must be persisted.
consoPolicy
:
name of the policy controlling when the source table
content is consolidated.
sendPolicy
:
name of the policy controlling when the destination table
content is sent to the server.
table:pushRow(row)
row
:
table of key/value pairs,
value must be a #columnspec,
keys must match creation column names.
table:reset()
table:send(dont_reset)
dont_reset
:
if true, the table content is not emptied after being sent.
table:setMaxRows(n)
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.
n
:
max number of rows accepted in the table.