在.net中使用aquiles访问Cassandra(三)
public void Remove(string columnFamily, IList<RowMutation> rowMutations)
{
if (string.IsNullOrWhiteSpace(columnFamily)) throw new ArgumentNullException("columnFamily"); Dictionary<byte[], Dictionary<string, List<Apache.Cassandra.Mutation>>> mutation_map = new Dictionary<byte[], Dictionary<string, List<Apache.Cassandra.Mutation>>>(); foreach (var rowMutation in rowMutations)
{
byte[] key = ByteEncoderHelper.UTF8Encoder.ToByteArray(rowMutation.Key); Dictionary<string, List<Apache.Cassandra.Mutation>> cfMutation = new Dictionary<string, List<Apache.Cassandra.Mutation>>();
List<Apache.Cassandra.Mutation> mutationList = new List<Apache.Cassandra.Mutation>(); Apache.Cassandra.Mutation mutation = new Apache.Cassandra.Mutation();
mutation.Deletion = new Deletion();
if (rowMutation.Mutations != null && rowMutation.Mutations.Count > )
{
mutation.Deletion.Predicate = new SlicePredicate()
{
Column_names = rowMutation.Mutations.Select(
m => ByteEncoderHelper.UTF8Encoder.ToByteArray(m.ColumnName)).ToList()
};
}
mutation.Deletion.Timestamp = DateTime.Now.ToUnixTimestamp();
mutationList.Add(mutation); cfMutation.Add(columnFamily, mutationList);
mutation_map.Add(key, cfMutation);
} if (mutation_map.Count == ) return;
_cluster.Execute(new ExecutionBlock(delegate(Apache.Cassandra.Cassandra.Client client)
{
client.batch_mutate(mutation_map, _consistencyLevel);
return null;
}), _keyspaceName); }
public void Remove(string columnFamily, string rowKey)
{
if (string.IsNullOrWhiteSpace(columnFamily)) throw new ArgumentNullException("columnFamily"); byte[] key = ByteEncoderHelper.UTF8Encoder.ToByteArray(rowKey); ColumnPath columnPath = new ColumnPath()
{
Column_family = columnFamily,
}; _cluster.Execute(new ExecutionBlock(delegate(Apache.Cassandra.Cassandra.Client client)
{
client.remove(key, columnPath, DateTime.Now.ToUnixTimestamp(), _consistencyLevel);
return null;
}), _keyspaceName);
}
public void Remove(string columnFamily, string rowKey, string columnName)
{
if (string.IsNullOrWhiteSpace(columnFamily)) throw new ArgumentNullException("columnFamily"); byte[] key = ByteEncoderHelper.UTF8Encoder.ToByteArray(rowKey); ColumnPath columnPath = new ColumnPath()
{
Column_family = columnFamily,
Column = ByteEncoderHelper.UTF8Encoder.ToByteArray(columnName)
}; _cluster.Execute(new ExecutionBlock(delegate(Apache.Cassandra.Cassandra.Client client)
{
client.remove(key, columnPath, DateTime.Now.ToUnixTimestamp(), _consistencyLevel);
return null;
}), _keyspaceName);
}
public void Remove(string columnFamily, IList<string> rowKeys)
{
IList<RowMutation> batchMutations = new List<RowMutation>();
foreach (string rowKey in rowKeys)
{
batchMutations.Add(new RowMutation(rowKey));
}
Remove(columnFamily, batchMutations);
}
public void Remove(string columnFamily, string rowKey, IList<string> columnNames)
{
IList<RowMutation> rowMutations = new List<RowMutation>(); RowMutation rowMutation = new RowMutation();
rowMutation.Key = rowKey; rowMutation.Mutations = new List<CellMutation>();
foreach (string columnName in columnNames)
{
rowMutation.Mutations.Add(new CellMutation(columnName));
}
rowMutations.Add(rowMutation); Remove(columnFamily, rowMutations);
}
在.net中使用aquiles访问Cassandra(三)的更多相关文章
- 在.net中使用aquiles访问Cassandra(一)
aquiles是.net下基于Thrift协议访问Cassandra的第三方类库,官方地址是: http://aquiles.codeplex.com/ 1.下载类库文件: http://aqui ...
- 在.net中使用aquiles访问Cassandra(二)
上文中我们已经建立了项目的基本结构,今天实现数据的修改.在NoSQL中,通常添加和修改都认为是对数据的一种Mutation. 1.建立描述修改Row的实体. public class RowMut ...
- 在.net中使用aquiles访问Cassandra(四)
数据的持久化我们都已经完成了,和所有应有程序一样,最重要的是要向用户展示数据.下面我们就推出这部分代码,读取任意行任何列: public IList<TRowResult> Execute ...
- 使用虚幻引擎中的C++导论(三-反射系统与迭代器)
使用虚幻引擎中的C++导论(三) 第一,这篇是我翻译的虚幻4官网的新手编程教程,原文传送门,有的翻译不太好,但大体意思差不多,请支持我O(∩_∩)O谢谢. 第二,某些细节操作,这篇文章省略了,如果有不 ...
- Android平台中实现对XML的三种解析方式
本文介绍在Android平台中实现对XML的三种解析方式. XML在各种开发中都广泛应用,Android也不例外.作为承载数据的一个重要角色,如何读写XML成为Android开发中一项重要的技能. 在 ...
- 客户机中PLSQL DEV访问虚拟机中的ORCLE11g,错误百出!
客户机中PLSQL DEV访问虚拟机中的ORCLE11g,错误百出! 创建时间: 2017/10/14 18:44 作者: CNSIMO 标签: ORACLE 忙了一下午,只有两个字形容:麻烦! ...
- Sql Server中的表访问方式Table Scan, Index Scan, Index Seek
1.oracle中的表访问方式 在oracle中有表访问方式的说法,访问表中的数据主要通过三种方式进行访问: 全表扫描(full table scan),直接访问数据页,查找满足条件的数据 通过row ...
- 转:Sql Server中的表访问方式Table Scan, Index Scan, Index Seek
0.参考文献 Table Scan, Index Scan, Index Seek SQL SERVER – Index Seek vs. Index Scan – Diffefence and Us ...
- 在Tomcat中部署web项目的三种方式
搬瓦工搭建SS教程 SSR免费节点:http://www.xiaokeli.me 在这里介绍在Tomcat中部署web项目的三种方式: 1.部署解包的webapp目录 2.打包的war文件 3.Man ...
随机推荐
- java UDP
UDP 与 tcp 连接的 区别 以及 两者的不同 UDp 1 面向的是无连接的网络方式 2 传输速度快 (但是容易发生丢包 ) 3 传输的数据的大小带有的限制 一般是在64k 范围内 tcp 1 ...
- 在ASP.NET MVC中使用Juqery实现页面局部刷新
自己做的一个实验,留作备忘,此实例包括扩一下几个文件: 1.MyMovieController.cs 2.Index.aspx 3.ViewUserControl1.ascx 4.movie类 其中M ...
- Everything搜索结果显示0 Object
比较过windows本身的文档搜索功能,Everything的本地文档搜索能力简直令人咋舌,更逆天的是软件本身体积很小. 问题:打开everything时,文件列表消失,软件下方信息为0 object ...
- flask_单元测试
我们现在可以试着在控制台向数据库添加一个用户: In[2]: import model; In[3]: from microblog import db; In[4]: u=model.User(ni ...
- WinForm程序全局捕捉异常处理办法
如何全局捕捉Winform程序异常呢,当然是从程序启动入口的Program类下的Main()方法定义了,下面看下这个类怎么写的吧 static class Program { static strin ...
- nginx简易安装
yum -y install perl-ExtUtils-Embed ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx ...
- shell 条件判断语句整理
常用系统变量 1) $0 当前程式的名称 2) $n 当前程式的第n个参数,n=1,2,…9 3) $* 当前程式的任何参数(不包括程式本身) 4) ...
- hdu 3397 Sequence operation(线段树:区间更新)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3397 题意:给你一个长度为n的0,1序列,支持下列五种操作, 操作0(0 a b):将a到b这个区间的 ...
- monodevelop 突然莫名其妙的将 warning 全部标记为 error
这是一个关于 monodevelop 的“坑” 我们在用 monodevelop 编译游戏脚本时, 通常会有一些警告,一般这些警告都是无害的, 不影响游戏运行.可是突然有一天, monodevelop ...
- Spring Batch 中文参考文档 V3.0.6 - 1 Spring Batch介绍
1 Spring Batch介绍 企业领域中许多应用系统需要采用批处理的方式在特定环境中运行业务操作任务.这种业务作业包括自动化,大量信息的复杂操作,他们不需要人工干预,并能高效运行.这些典型作业包括 ...