You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Hagos, A.S." <A....@tue.nl> on 2012/11/05 13:37:38 UTC
how to get timestamp from slicerange result
Hi ,
I am using cpp thrift client to manipulate data in cassandra.
I am unable to get the timestamp from a keyslice result.
Any ideas ?
The following is piece of my code to get column names and values from the result.
cass.set_keyspace(myks3);
string key = myrk3;
ColumnParent cparent;
cparent.column_family = mycf3;
Column c;
// get the entire row for a key
SliceRange sr;
sr.start = "";
sr.finish = "";
SlicePredicate sp;
sp.slice_range = sr;
sp.__isset.slice_range = true; // set __isset for the columns instead if you use them
KeyRange range;
range.start_key = key;
range.end_key = key;
range.__isset.start_key = true;
range.__isset.end_key = true;
range.count = 1; //it limits the search in only one row (default is 100)
vector<KeySlice> results;
cass.get_range_slices(results, cparent, sp, range, ConsistencyLevel::ONE);
for(size_t i=0; i<results.size(); i++){
for(size_t x=0; x<results[i].columns.size(); x++){
returnstrg << "\"" << results[i].columns[x].column.name.c_str();
returnstrg << "\":" << results[i].columns[x].column.value.c_str()<<std::endl;
.
greetings
Ambes
solved ...RE: how to get timestamp from slicerange result
Posted by "Hagos, A.S." <A....@tue.nl>.
I just figured it out ...
returnstrg << "\":" << results[i].columns[x].column.timestamp<<std::endl;
________________________________________
From: Hagos, A.S. [A.S.Hagos@tue.nl]
Sent: Monday, November 05, 2012 1:37 PM
To: user@cassandra.apache.org
Subject: how to get timestamp from slicerange result
Hi ,
I am using cpp thrift client to manipulate data in cassandra.
I am unable to get the timestamp from a keyslice result.
Any ideas ?
The following is piece of my code to get column names and values from the result.
cass.set_keyspace(myks3);
string key = myrk3;
ColumnParent cparent;
cparent.column_family = mycf3;
Column c;
// get the entire row for a key
SliceRange sr;
sr.start = "";
sr.finish = "";
SlicePredicate sp;
sp.slice_range = sr;
sp.__isset.slice_range = true; // set __isset for the columns instead if you use them
KeyRange range;
range.start_key = key;
range.end_key = key;
range.__isset.start_key = true;
range.__isset.end_key = true;
range.count = 1; //it limits the search in only one row (default is 100)
vector<KeySlice> results;
cass.get_range_slices(results, cparent, sp, range, ConsistencyLevel::ONE);
for(size_t i=0; i<results.size(); i++){
for(size_t x=0; x<results[i].columns.size(); x++){
returnstrg << "\"" << results[i].columns[x].column.name.c_str();
returnstrg << "\":" << results[i].columns[x].column.value.c_str()<<std::endl;
.
greetings
Ambes