java - Cassandra triggers for updating a table when another is updated -
i going through triggers implementation in cassandra. wanted implement triggers update table old values of tables has been modified. suppose have table test_table in keyspace keyspace1. have table table_track in same keyspace columns columnname , columnvalue. when row updated in test_table, populate track_table row data(in test_table before update query executed) in columns columnname , columnvalue respectively.
i couldn't find proper documentation regarding cassandra triggers anywhere. managed somehow implement invertedindex , minor examples
public collection<mutation> augment(bytebuffer key, columnfamily update) { list<mutation> mutations = new arraylist<mutation>(update.getcolumncount()); (cell cell : update) { // skip row marker , other empty values, since lead empty key. if (cell.value().remaining() > 0) { mutation mutation = new mutation(properties.getproperty("keyspace"), cell.value()); mutation.add(properties.getproperty("columnfamily"), cell.name(), key, system.currenttimemillis()); mutations.add(mutation); } } return mutations; }
how can modify augment method implement functionality. tnx
you using wrong key create mutation instance
here working code
public collection<mutation> augment(bytebuffer key, columnfamily update) { list<mutation> mutations = new arraylist<mutation>(update.getcolumncount()); (cell cell : update) { if (cell.value().remaining() > 0) { mutation mutation = new mutation(properties.getproperty("keyspace"), key); mutation.add(properties.getproperty("columnfamily"), cell.name(), cell.value(), system.currenttimemillis()); mutations.add(mutation); } } return mutations; }
Comments
Post a Comment