AGING Clause

Specifies the data aging policy.

Syntax

AGES EVERY agingTime SET agingField [maxAgingFieldValue TIMES] [FROM agingTimeField]

Components

agingTime

The time interval,specified in hours, minutes, seconds, milliseconds, or microseconds, after which the data aging process begins. It may be specified using a combination of the allowed units (for example, 3 MINUTES 30 SECONDS).

Can also be specified using the interval parameter.

agingField

The field in the record that is incremented by 1 every time the agingTime period elapses and no activity has occurred on the record.

maxAgingFieldValue

(Optional) The maximum value that agingField is incremented to. If not specified, agingField is incremented once.

Can also be specified by the interval parameter.

agingTimeField

(Optional) The field containing the start time for the aging process. For example, if the period of time specified in the agingTime column has elapsed, the data aging process begins.

If not specified, the internal row time is used. If specified, the field must contain a valid start time.

Usage

If data records have not been updated or deleted within a predefined period, they are considered to have aged. When a data record ages, notifications are sent as update events to subscribers of the window.
Note: You can only use the AGING clause with windows.

When the predefined time period (agingTime) elapses, an integer field in the record (agingField) is incremented once, or until a predefined maximum value (maxAgingFieldValue) is reached. The start time of the aging process is specified through the (agingTimeField) field in the record.

If the start time is not explicitly specified, the internal row time is used. When the aging process begins, agingField defaults to 0, and it is incremented by 1 whenever the predefined time period elapses. If a record is updated after aging commences, agingField resets to 0 and the process restarts. If a record is deleted, no aging updates are generated.

When insert is received, the count field sets to 0, the insert is passed through, and aging begins.

Aging starts only after the specified inactivity period. If the data ages every five seconds, then the record must remain inactive for five seconds before it starts counting. A record is considered inactive when no updates or deletes have occurred.

When delete is received, aging stops and the delete is passed through. An update of a record resets the counting to 0.

Example

This example creates an output window named AgingWindow. The age column for the output window updates every 10 seconds 20 times.

CREATE  OUTPUT  WINDOW AgingWindow
  SCHEMA (
     AgeColumn integer, 
     Symbol STRING, 
     Ts bigdatetime )
  PRIMARY KEY (Symbol)
  AGES EVERY 10 SECONDS SET AgeColumn 20 TIMES
 AS 
  SELECT 1 as AgeColumn, 
  TradesWindow.Symbol AS Symbol, 
  TradesWindow.Ts AS Ts
 FROM TradesWindow 
;