Database Reference
In-Depth Information
* cf is map-like structure that holds column-name and
mutation to applied
* Collection<Mutation> is the collection of mutations
that you want to execute. If there is no new mutation,
return null
**/
public Collection<Mutation> augment(ByteBuffer key,
ColumnFamily cf)
/*
* TRIGGER LOGIC GOES HERE
*/
return null;
}
}
To use this trigger, you need to follow this syntax:
# Pattern to create a trigger
CREATE TRIGGER trigger_name
ON
table_name
USING 'fully.qualified.trigger.Name';
# Create a trigger
CREATE TRIGGER dummy_trigger_on_users
ON
users
USING 'com.mycompany.cassandra.DummyTrigger';
Triggers are executed before the mutation request is performed. Triggers can be helpful in
scenarios where you need to update another table based on mutations on a table, logging
specific mutation or creating notification on certain events, or anything that is specific to
your application.
There is an excellent example of trigger that generates an inverse index. The code can be
found in Cassandra 2.1 source code at https://git-wip-us.apache.org/repos/
asf?p=cassandra.git;a=blob_plain;f=examples/triggers/src/org/apache/cassandra/triggers/
InvertedIndex.java;hb=HEAD .
Search WWH ::




Custom Search