title: How to populate a Mutation for a different Cassandra table in a trigger
body: <p>I'm trying to implement a Cassandra trigger such that when there is an update or a delete on keyspace1.tableA, the trigger will add a row to keyspace1.tableB.</p>
  
  <p>The names of the columns in tableB are completely different than the columns in tableA.</p>
  
  <p>I'm working with Cassandra 2.1, no option to move to a more recent version.  Looking at the InvertedIndex trigger example at <a href="https://github.com/apache/cassandra/blob/cassandra-2.1/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java" rel="nofollow">https://github.com/apache/cassandra/blob/cassandra-2.1/examples/triggers/src/org/apache/cassandra/triggers/InvertedIndex.java</a> I can see the basics of adding a mutation:</p>
  
  <p>From the InvertedIndex example:</p>
  
  <pre><code>    for (Cell cell : update)
      {
          // Skip the row marker and other empty values, since they lead to an empty key.
          if (cell.value().remaining() &gt; 0)
          {
              Mutation mutation = new Mutation(properties.getProperty("keyspace"), cell.value());
              mutation.add(properties.getProperty("columnfamily"), cell.name(), key, System.currentTimeMillis());
              mutations.add(mutation);
          }
      }
  </code></pre>
  
  <p>The challenge is that in this example, the cell name being passed to mutation.add is cell.name() which is an existing object whose name we can just take using that function.</p>
  
  <p>For now, I'm just trying to store the time a change was made to tableA, so tableB has two columns:</p>
  
  <ul>
  <li>changetime timeuuid</li>
  <li>operation text</li>
  </ul>
  
  <p>I need to add a mutation that will add a row to tableB with the changetime and operation performed.  How can I add such a row mutation in Cassandra 2.1.12?</p>
  
  <p>I have tried this but I am getting a null pointer exception in the trigger:</p>
  
  <pre><code>...
  String keycol = "changetime";
  ByteBuffer uuidKey = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes()); 
  ColumnIdentifier ci = new ColumnIdentifier(keycol, false);
  CellName cn = CellNames.simpleSparse(ci);
  mutation = new Mutation(keyspace, uuidKey);
  mutation.add(tableName,cn, uuidKey, System.currentTimeMillis());
  ...
  </code></pre>
  
  <p>Any assistance would be much appreciated - I have no knowledge of Cassandra internals so no amount of detail is too much information.</p>