How to retrieve the timestamp from cassandra?

左心房为你撑大大i 提交于 2019-12-30 05:59:49

问题


In the below cassandra, "get result"..we can able to retrieve the column name and values. But how to retrieve the timestamp..Is there any better idea to get the values by using timestamp

[default@sample]get user[bob];                                        
=> (column=name, value=bobdroid, timestamp=1335361733545850)
=> (column=email, value=bob@gmail.com, timestamp=1335361733545850)
=> (column=age, value=23, timestamp=1335361733545850)
=> (column=password, value=MTIz, timestamp=1335361733545850)
Returned 4 results.
Elapsed time: 4 msec(s).

回答1:


It's not recommended to use column Cassandra timestamps directly in client code; ideally, you should add your own timestamps in whatever form is most appropriate to your schema. But if you really want to, it can be done through the thrift interface (and, by extension, certain libraries using the thrift interface).

For the pycassa case, you just need to add include_timestamp=True to the arguments for your .get() call. For the CQL, cqlsh, and cassandra-cli cases, I believe there's totally no way to get the timestamp, sorry.




回答2:


Just ran across this thread, and found that the answer is out of date. CQL now exposes the internal timestamps using the writetime() function:

select key,columnfoo,writetime(columnfoo) from tablebar;


来源:https://stackoverflow.com/questions/10346839/how-to-retrieve-the-timestamp-from-cassandra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!