在.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导入excel时遇到的版本问题
java中读取excel文件时对不同的版本提供了不同的读取方法,这就要求我们在读取excel文件时获取excel文件的版本信息从而通过不同的版本去使用不同的读取方式, 在WorkbookFactory ...
- Git入门仅这篇就够了
版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请表明出处:http://www.cnblogs.com/cavalier-/p/5978937.html 前言 大家好,我是Cavalier ...
- jquery双击事件
<html> <head><meta http-equiv="Content-Type" content="text/html; chars ...
- js复制内容加版权声明代码
$("body").on('copy', function (e) { if (typeof window.getSelection == "undefined" ...
- JS 获取FileUpload1控件地址
function openList() { //判断浏览器类型 var isIE = (document.all) ? true : false; ); ); ); var path = " ...
- 实现十进制无符号整数m到十六进制数的转换功能
/*利用顺序栈结构,编写算法函数void Dto16(unsigned int m)实现十进制无符号整数m到十六进制数的转换功能.*//******************************** ...
- java线程池初步理解
多线程基础准备 进程:程序的执行过程,持有资源和线程 线程:是系统中最小的执行单元,同一个进程可以有多个线程,线程共享进程资源 线程交互(同步synchronized):包括互斥和协作,互斥通过对象锁 ...
- iptables之LOG目标 被拦截包分析
iptables之LOG目标 问题 在iptables的INPUT链中发现有大量未知包被拦截,这种情况就有两种可能,一是自己的某个服务的iptables端口没有打开,二是服务器正在遭受攻击 分析 这就 ...
- catalina.properties
追踪 startup.bat set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" call "%EXECUTABLE%&q ...
- iscroll5 上拉,下拉 加载数据
我这里的思路是上拉时候只是加载第一页的内容,可根据实际情况修改其中的代码.请勿照搬.样式没怎么调,可以加载gif动画.1.没有数据时候,下拉可以加载数据.2.没有数据时候,点击也可以加载数据.3.其余 ...