com.apama.memorystore
Event RowChanged


Sent to the application on every successful row commit in tables the application has subscribed to.

Supported in distributed stores only, and only for fields named in the schema (extra fields are not supported).

Events are sent for every change, whether from the local or a remote node, for tables where the subscribe method has been called.

The old and new values are provided as sequences. Access to previous and new values are thus available if the driver and distmemstore support it (and note the setting of rowChangedOldValueRequired); for example:
 
integer positionRowId := tbl.getFieldIndex("position");
RowChanged rowChanged;
on all RowChanged(storeName = STORE,
tableName = TABLE):rowChanged {
// we handle things simply by treating an update as a remove followed by an insert:
if (rowChanged.changeType = RowChanged.REMOVE or
rowChanged.changeType = RowChanged.UPDATE) {
position := position - float.parse(rowChanged.oldFieldValues[positionRowId]);
}
if rowChanged.changeType = RowChanged.INSERT or
rowChanged.changeType = RowChanged.UPDATE {
position := position + float.parse(rowChanged.newFieldValues[positionRowId]);
}
log "Position is now "+position.toString();
}
See Also:
com.apama.memorystore.Table#subscribeRowChanged() - for subscribing to RowChanged events

Constant Summary
 constant integerINSERT := 1

Value for changeType when a row is added to a table.
 constant integerREMOVE := 2

Value for changeType when a row is removed from a table.
 constant integerUPDATE := 3

Value for changeType when a row is modified in a table.
 
Member Summary
 integerchangeType

One of INSERT, REMOVE, UPDATE for rows being added, removed, updated.
 stringstoreName

Name of the store that the table is in.
 stringtableName

Name of the table that the row is in.
 stringkey

The key value for the changed row.
 sequence<string >oldFieldValues

Old values of the row, if available.
 sequence<string >newFieldValues

New values of the row.
 
Action Summary
 stringgetChangeTypeString()

Get a display string representing this event's change type.
 
Constant Detail

INSERT

constant integer INSERT := 1
Value for changeType when a row is added to a table.

REMOVE

constant integer REMOVE := 2
Value for changeType when a row is removed from a table.

UPDATE

constant integer UPDATE := 3
Value for changeType when a row is modified in a table.
Member Detail

changeType

integer changeType
One of INSERT, REMOVE, UPDATE for rows being added, removed, updated.

key

string key
The key value for the changed row.

newFieldValues

sequence<string > newFieldValues
New values of the row.

The new values of the row, in toString() format, in the order defined by the table's Schema.

For REMOVE, this will be an empty sequence, otherwise it will have as many entries as there are fields in the schema.

The field values can be recovered by using the parse method on the field's type (e.g. integer.parse(rc.newFieldValues[i])), except for strings which are inserted without any escaping, so do not need to be parsed.

Use Table.getFieldIndex() to efficiently map a field name to an index in this sequence (although consider caching the index in a variable to avoid unnecessary lookups).
See Also:
com.apama.memorystore.Table#getFieldIndex() - for mapping from field name to index.

oldFieldValues

sequence<string > oldFieldValues
Old values of the row, if available.

The old values of the row, in toString() format, in the order defined by the table's Schema. For UPDATE changeTypes, this is only populated if the storeFactory bean property rowChangedOldValueRequired is true (the default value is provider-specific).

For INSERT (or UPDATE if rowChangedOldValueRequired is false), this will be an empty sequence, otherwise it will have as many entries as there are fields in the schema.

The field values can be recovered by using the parse method on the field's type (e.g. integer.parse(rc.oldFieldValues[i])),except for strings which are inserted without any escaping, so do not need to be parsed.

Use Table.getFieldIndex() to efficiently map a field name to an index in this sequence (although consider caching the index in a variable to avoid unnecessary lookups).
See Also:
com.apama.memorystore.Table#getFieldIndex() - for mapping from field name to index.

storeName

string storeName
Name of the store that the table is in.

tableName

string tableName
Name of the table that the row is in.
Action Detail

getChangeTypeString

string getChangeTypeString()
Get a display string representing this event's change type.
Returns:
"INSERT", "REMOVE" or "UPDATE".