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.

Some distributed MemoryStore drivers support including new and old values in this event, some just new values, and others - such as TCStore - leave both sequences empty.

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
 integerINSERT := 1

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

Value for changeType when a row is removed from a table.
 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, or an empty sequence if not supported by this driver.
 sequence<string>newFieldValues

New values of the row, or an empty sequence if not supported by this driver.
 
Action summary
 stringgetChangeTypeString()

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

INSERT

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

REMOVE

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

UPDATE

            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<stringnewFieldValues
        
New values of the row, or an empty sequence if not supported by this driver.

This sequence is always blank when using TCStore.

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<stringoldFieldValues
        
Old values of the row, or an empty sequence if not supported by this driver.

This sequence is always blank when using TCStore or BigMemory.

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".