Cassandra Batch_mutate()

时间:2010-05-06 18:01:50

标签: cassandra

请提供一个如何使用C#.net?

中的batch_mutate()的示例

提前致谢。

1 个答案:

答案 0 :(得分:2)

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

List<Mutation> columnsToadd = new List<Mutation>();
List<Column> customers = new List<Column>();

//List of SuperColumns

customers.Add(new Column() { Name = utf8Encoding.GetBytes("street"), Timestamp = timeStamp, Value = utf8Encoding.GetBytes("Test") });

customers.Add(new Column() { Name = utf8Encoding.GetBytes("Zip"), Timestamp = timeStamp, Value = utf8Encoding.GetBytes("Test") });

customers.Add(new Column() { Name = utf8Encoding.GetBytes("city"), Timestamp = timeStamp, Value = utf8Encoding.GetBytes("Test Hills") });

Dictionary<string, List<Mutation>> innerMap = new Dictionary<string, List<Mutation>>();
Mutation columns = new Mutation()
{
 Column_or_supercolumn = new ColumnOrSuperColumn() { Super_column = new SuperColumn() { Name = utf8Encoding.GetBytes("John1"), Columns = customers } }
};

columnsToadd.Add(columns);
ColumnPath nameColumnPath = new ColumnPath()
 {
       Column_family = "Super1",
       Super_column = utf8Encoding.GetBytes("John1"),
       Column = utf8Encoding.GetBytes("customers")
 };
 innerMap.Add("Super1", columnsToadd);
 dictionary.Add("Phatduckk", innerMap);
 client.batch_mutate("Keyspace1", dictionary, ConsistencyLevel.ONE);