C++ C++;cassandra客户端选择int值
我正在尝试选择一个整数值,但无法选择 这是我的代码:C++ C++;cassandra客户端选择int值,c++,select,int,cassandra,C++,Select,Int,Cassandra,我正在尝试选择一个整数值,但无法选择 这是我的代码: cassandra_socket = boost::shared_ptr<TSocket>(new TSocket(host, port)); cassandra_transport = boost::shared_ptr<TFramedTransport>(new TFramedTransport(cassandra_socket)); protocol = boost::shared_ptr<TBinaryP
cassandra_socket = boost::shared_ptr<TSocket>(new TSocket(host, port));
cassandra_transport = boost::shared_ptr<TFramedTransport>(new TFramedTransport(cassandra_socket));
protocol = boost::shared_ptr<TBinaryProtocol>(new TBinaryProtocol(cassandra_transport));
cassandra_client = new CassandraClient(protocol);
try {
cassandra_transport->open();
cassandra_client->set_keyspace("MPS");
ColumnOrSuperColumn csc;
ColumnPath cpath;
cpath.column_family.assign("SubmitResposes_count");
/* This is required - thrift 'feature' */
cpath.__isset.column = true;
cpath.column = "Counter";
cassandra_client->get(csc, "1", cpath,org::apache::cassandra::ConsistencyLevel::ONE);
cout << "Value read is '" << csc.column.value << "'..." << endl;
}
catch (NotFoundException &nf) {
FORCE_TRACE(0, "NOT FOUND EXCEPTION ERROR: %s", nf.what());
} catch (InvalidRequestException &re) {
FORCE_TRACE(0, "INVALID REQUEST ERROR: %s", re.why);
} catch (TException &tx) {
FORCE_TRACE(0, "TEEXCEPTION ERROR: %s", tx.what());
}
您的密钥是int:
ID int primary key,
但您正在使用字符串键进行查询:
cassandra_client->get(csc, "1", cpath,org::apache::cassandra::ConsistencyLevel::ONE);
^^^
Cassandra正在尝试将字符串验证为int,这导致了此异常。函数“get”仅接受字符串如何使用整数键进行查询?您似乎在使用旧的thrift规范。该函数使用二进制键。您是否考虑过使用高级客户机而不是节俭?除非你有特定的理由,否则不建议直接使用节俭。
cassandra_client->get(csc, "1", cpath,org::apache::cassandra::ConsistencyLevel::ONE);
^^^