/*
  * (non-Javadoc)
  *
  * @see
  * backtype.storm.contrib.cassandra.client.CassandraClient#writeTuple(backtype
  * .storm.tuple.Tuple,
  * backtype.storm.contrib.cassandra.bolt.mapper.TupleMapper)
  */
 @Override
 public void writeTuple(Tuple input, TupleMapper<T> tupleMapper) throws Exception {
   String columnFamilyName = tupleMapper.mapToColumnFamily(input);
   String rowKey = (String) tupleMapper.mapToRowKey(input);
   MutationBatch mutation = keyspace.prepareMutationBatch();
   ColumnFamily<String, T> columnFamily =
       new ColumnFamily<String, T>(
           columnFamilyName, StringSerializer.get(), this.getColumnNameSerializer(tupleMapper));
   this.addTupleToMutation(input, columnFamily, rowKey, mutation, tupleMapper);
   mutation.execute();
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * backtype.storm.contrib.cassandra.client.CassandraClient#writeTuples(java
  * .util.List, backtype.storm.contrib.cassandra.bolt.mapper.TupleMapper)
  */
 @Override
 public void writeTuples(List<Tuple> inputs, TupleMapper<T> tupleMapper) throws Exception {
   MutationBatch mutation = keyspace.prepareMutationBatch();
   for (Tuple input : inputs) {
     String columnFamilyName = tupleMapper.mapToColumnFamily(input);
     String rowKey = (String) tupleMapper.mapToRowKey(input);
     ColumnFamily<String, T> columnFamily =
         new ColumnFamily<String, T>(
             columnFamilyName, StringSerializer.get(), this.getColumnNameSerializer(tupleMapper));
     this.addTupleToMutation(input, columnFamily, rowKey, mutation, tupleMapper);
   }
   try {
     mutation.execute();
   } catch (Exception e) {
     LOG.error("Could not execute mutation.", e);
   }
 }
 private void addTupleToMutation(
     Tuple input,
     ColumnFamily<String, T> columnFamily,
     String rowKey,
     MutationBatch mutation,
     TupleMapper<T> tupleMapper) {
   Map<T, String> columns = tupleMapper.mapToColumns(input);
   for (Map.Entry<T, String> entry : columns.entrySet()) {
     mutation.withRow(columnFamily, rowKey).putColumn(entry.getKey(), entry.getValue(), null);
   }
 }