tags:

views:

459

answers:

0

Can any one please give me an example on how to work on Cassandra batch_insert in C# thrift client?

If possible please let me know where am I going wrong in the following code.

Dictionary<string, Dictionary<string, List<Mutation>>> dictionary = 
    new Dictionary<string, Dictionary<string, List<Mutation>>>();
Dictionary<string, List<Mutation>> subColumns = 
    new Dictionary<string, List<Mutation>>();
List<Mutation> listOfMutations = new List<Mutation>();

listOfMutations.Add(new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("AA"), Value = utf8Encoding.GetBytes("Answer Automation"), Timestamp = timeStamp } } });
listOfMutations.Add(new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("CT"), Value = utf8Encoding.GetBytes("Call Tracker"), Timestamp = timeStamp } } });
listOfMutations.Add( new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("TL"), Value = utf8Encoding.GetBytes("Track That Lead"), Timestamp = timeStamp } } });
SuperColumn superColumn = new SuperColumn()
{
   Name = utf8Encoding.GetBytes("Indatus")
};

subColumns.Add("Super1", listOfMutations);
dictionary.Add("Indatus", subColumns);
client.batch_mutate("Keyspace1",dictionary, ConsistencyLevel.ONE);

I understand that SuperColumn struct expects List but I does not have a list of Columns. Rather I have List.

Thanks in Advance.