実際のコードの再投稿
// cassandra is a connected org::apache::cassandra::CassandraClient
// statement is a CqlPreparedResult
// result is a CqlResult
// CF declaration is:
/*
CREATE COLUMNFAMILY xp (
cid ascii PRIMARY KEY,
exp4 counter,
exp2 counter,
exp3 counter,
exp1 counter
) WITH
comment='' AND
comparator=text AND
read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
default_validation=counter AND
min_compaction_threshold=4 AND
max_compaction_threshold=32 AND
replicate_on_write=True AND
compaction_strategy_class='SizeTieredCompactionStrategy' AND
compression_parameters:sstable_compression='org.apache.cassandra.io.compress.SnappyCompressor';
*/
std::vector<std::string> values;
values.resize(2);
values[0]="1";
values[1]="103";
cassandra->prepare_cql_query(statement,"update xp set exp2 = exp2 + ? where cid=?",Compression::NONE);
int32_t handle=statement.itemId;
try {
cassandra->execute_prepared_cql_query(result,handle,values);
}
catch(InvalidRequestException &e) {
cout << __LINE__ << " " << e.why << " "<< e.what() << endl;
}
// throws '?' is an invalid value, should be a long.
values.resize(1);
values[0]="103";
cassandra->prepare_cql_query(statement,"update xp set exp2 = exp2 + 1 where cid=?",Compression::NONE);
handle=statement.itemId;
cassandra->execute_prepared_cql_query(result,handle,values);
//works
問題は、バイナリデータを渡すことができないという事実にあるようです。long の実際の表現を含む文字列を渡そうとしましたが、成功しませんでした。データを読み取るときも同じ問題ですが、管理できると思います(返された文字列をスキャンし、最後の手段として一度に1バイトずつ変換します)
カウンター、c++、および cql を使用して成功した人はいますか?