@SuppressWarnings("unchecked")
public void incrementCountColumns(List<Tuple> inputs, TupleCounterMapper<K,C> tupleMapper) throws Exception {
Map<String, MutationBatch> mutations = new HashMap<String, MutationBatch>();
for (Tuple input : inputs) {
String keyspace = tupleMapper.mapToKeyspace(input);
MutationBatch mutation = mutations.get(keyspace);
if(mutation == null) {
mutation = getKeyspace(keyspace).prepareMutationBatch();
mutations.put(keyspace, mutation);
}
String columnFamilyName = tupleMapper.mapToColumnFamily(input);
K rowKey = tupleMapper.mapToRowKey(input);
long incrementAmount = tupleMapper.mapToIncrementAmount(input);
ColumnFamily<K, C> columnFamily = new ColumnFamily<K, C>(columnFamilyName,
(Serializer<K>) serializerFor(tupleMapper.getKeyClass()),
(Serializer<C>) serializerFor(tupleMapper.getColumnNameClass()));
for (C columnName : tupleMapper.mapToColumnList(input)) {
mutation.withRow(columnFamily, rowKey).incrementCounterColumn(columnName, incrementAmount);
}
}
for(String key : mutations.keySet()) {
mutations.get(key).execute();
}