在.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 ...
随机推荐
- 【转】Nginx服务器详细配置含注释
#使用的用户和组 user www www; #指定工作衍生进程数(一般等于CPU的总核数或总核数的两倍) worker_processes 8; #指定错误日志存放的路径,错误日志的记录级别可为de ...
- jxl 处理 Excel 样式
jxl 能够操作的 excel 样式: 1. Workbook的格式设置(代表一个excel文件) 2. Sheet的格式设置(代表一个表格) 3. Cell的格式设置(代表一个单元格) PS:此jx ...
- 确定比赛名次---HDU1285(拓扑排序)
http://acm.hdu.edu.cn/showproblem.php?pid=1285 题目大意: 给你每场比赛的成绩,让你根据成绩把排名弄出来 分析: 本来我是用普通方法写的,然后就一直wa, ...
- PHP 增删改查
<h1>主页面family</h1> <table width="100%" border="1px" cellpadding=& ...
- SharePoint 2013开发入门探索(二)- 列表操作
我们如何用代码对SharePoint列表做些例如增删改查的操作呢?如果您的程序可以部署到服务器上,就可以使用 服务器对象模型,因为服务器对象模型提供的功能最多,限制最少:否则可能要选择客户对象模型等其 ...
- iis下设置php最大执行时间
php在执行中常见错误: The FastCGI process exceeded configured request timeout: FastCGI process exceeded confi ...
- Object 转化为String时的一个问题 null->"null"
近日在工作出了一个较大的问题,导致被客户投诉. 事情大致是,某个功能里新增对用户手机的修改,在平台数据同步过程中,出现了将用户以前的要同步的数据,那时还没有手机号码所以是null,新功能上线后,将手机 ...
- Java学习笔记 04 类和对象
一.类和对象的概念 类 >>具有相同属性和行为的一类实体 对象 >>实物存在的实体.通常会将对象划分为两个部分,即静态部分和动态部分.静态部分指的是不能动的部分,被称为属性,任 ...
- android.util.TypedValue.applyDimension
先看一个例子: int size = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, context.getResourc ...
- CabArc to create or extract a cab file
CabArc n D:\test.cab D:\output\*.* CabArc x D:\test.cab -r -p D:\output\*.*