public void setColumns(string keyspace, Object columnFamily, byte[] key, IDictionary <object, object> map, int ttl) { client.set_keyspace(keyspace); long timestamp = createTimestamp(); Dictionary <byte[], Dictionary <string, List <Mutation> > > mutation_map = new Dictionary <byte[], Dictionary <string, List <Mutation> > >(); Dictionary <string, List <Mutation> > columnFamilyKey = new Dictionary <string, List <Mutation> >(); List <Mutation> mutationList = new List <Mutation>(); foreach (Object name in map.Keys) { Object value = null; map.TryGetValue(name, out value); if (value != null) { Mutation mutation = new Mutation(); Column column = new Column(); column.Name = name.ToByteArray(); column.Value = value.ToByteArray(); column.Timestamp = createTimestamp(); if (ttl != 0) { column.Ttl = ttl; } mutation.Column_or_supercolumn = new ColumnOrSuperColumn(); mutation.Column_or_supercolumn.Column = column; mutationList.Add(mutation); } } columnFamilyKey.Add(columnFamily.ToString(), mutationList); mutation_map.Add(key, columnFamilyKey); client.batch_mutate(mutation_map, consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { var mutationMap = TranslateMutations(); cassandraClient.batch_mutate(mutationMap, consistencyLevel); }