QtCassandra 程序2
来源:互联网 发布:荷塘月色淘宝论坛官网 编辑:程序博客网 时间:2024/06/16 04:27
/*
* Text:
* context_management.cpp
*
* Description:
* Create contexts, check that they exist, drop contexts, check that
* they were removed.
*
* Documentation:
* Run with no options.
* Fails if the test cannot find the expected contexts or can find
* the non-expected contexts.
*
* License:
* Copyright (c) 2011 Made to Order Software Corp.
*
* http://snapwebsites.org/
* contact@m2osw.com
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QtCassandra/QCassandra.h>
#include <QtCore/QDebug>
#include <thrift-gencpp-cassandra/cassandra_types.h>
int main(int argc, char *argv[])
{
QtCassandra::QCassandra cassandra;
cassandra.connect();
qDebug() << "Working on Cassandra Cluster Named" << cassandra.clusterName();
QSharedPointer<QtCassandra::QCassandraContext> context(cassandra.context("qt_cassandra_test_context"));
context->setStrategyClass("org.apache.cassandra.locator.SimpleStrategy"); // default is LocalStrategy
//context->setDurableWrites(false); // by default this is 'true'
context->setReplicationFactor(1); // by default this is undefined
QSharedPointer<QtCassandra::QCassandraTable> table(context->table("qt_cassandra_test_table"));
//table->setComment("Our test table.");
table->setColumnType("Standard"); // Standard or Super
table->setKeyValidationClass("BytesType");
table->setDefaultValidationClass("BytesType");
table->setComparatorType("BytesType");
table->setKeyCacheSavePeriodInSeconds(14400);
table->setMemtableFlushAfterMins(60);
//table->setMemtableThroughputInMb(247);
//table->setMemtableOperationsInMillions(1.1578125);
table->setGcGraceSeconds(864000);
table->setMinCompactionThreshold(4);
table->setMaxCompactionThreshold(22);
table->setReplicateOnWrite(1);
// Column definitions can be used to make sure the content is valid.
// It is also required if you want to index on such and such column
// using the internal Cassandra indexing mechanism.
QSharedPointer<QtCassandra::QCassandraColumnDefinition> column1(table->columnDefinition("qt_cassandra_test_column1"));
column1->setValidationClass("UTF8Type");
QSharedPointer<QtCassandra::QCassandraColumnDefinition> column2(table->columnDefinition("qt_cassandra_test_column2"));
column2->setValidationClass("IntegerType");
try {
context->create();
qDebug() << "Done!";
}
catch(org::apache::cassandra::InvalidRequestException& e) {
qDebug() << "Exception is [" << e.why.c_str() << "]";
}
// now that it's created, we can access it with the [] operator
QtCassandra::QCassandraTable& t(cassandra["qt_cassandra_test_context"]["qt_cassandra_test_table"]);
context->drop();
}
// vim: ts=4 sw=4 et
- QtCassandra 程序2
- QtCassandra 程序
- QtCassandra 程序1
- 【程序2】
- 【程序2】
- 程序2
- 程序2
- 程序2
- 程序2
- 程序2-1 SCRNSIZE程序
- 普通程序猿 文艺程序猿 2B程序猿
- 普通程序猿 文艺程序猿 2B程序猿
- 2种程序创建程序的方法
- 第十七周上机程序阅读程序2
- Libevent示例程序2 socket程序
- 程序清单 17.2 & 程序清单 17.2.2
- 第十五周程序-阅读程序-2
- S3C2440裸机程序【2】串口uart程序
- 浅谈MySQL Buffer学习及思考
- 程序员技术练级攻略 新入职程序员应该看的
- linux下Erlang安装,解决pthread/ethr_event.c:98: Fatal error in wait__(): Function not implemented 问题
- 将Show In菜单添加至视图或编辑器的右键菜单中
- 同一台机器安装不同版本的oracle数据库的注意点
- QtCassandra 程序2
- Metasploit使用问题记录及攻击测试代码
- 羌笛声声胡笳怨,此心长寄天涯远
- linux一些用到的命令。
- 3.JavaScript工作原理
- C++静态成员函数学习
- 心得10--网络编程1
- sql sqlserver 创建数据库 数据表 循环 合并表的几个例子
- IJG是什么,有哪些优点 IJG VS IJL