How to implement cass_result_last_row()?

已查看 11 次
跳至第一个未读帖子

Jacek

未读,
2016年4月14日 05:53:112016/4/14
收件人 DataStax C++ Driver for Apache Cassandra User Mailing List
Hi,

I'm looking for sth like cass_result_last_row() which will return last row from CassResult. Is it possible (somehow) now?

-Jacek

Michael Penick

未读,
2016年4月14日 18:13:572016/4/14
收件人 cpp-dri...@lists.datastax.com
Hi Jacek,

With the current API your application could create a result iterator and iterate to the last row. I admit this isn't ideal, esp. if you don't want the data in the intermediate rows (between the first and the last rows). I'm not opposed to adding a  cass_result_last_row() (or a cass_result_nth_row()), because it would be faster to do this in a tighter loop.  However, it's important to understand that the cost depends on the number of rows being skipped. Rows are not fixed length so you'd have to calculate the offset and traverse each row in the result set to get to the end. 

If you could add a story to the cpp-driver JIRA [1] with some details it would be greatly appreciated. 

Cheers,
Mike



-Jacek

--
You received this message because you are subscribed to the Google Groups "DataStax C++ Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpp-driver-us...@lists.datastax.com.

Michael Penick

未读,
2016年4月14日 18:23:432016/4/14
收件人 cpp-dri...@lists.datastax.com
Here's a potentially better way to handle this:

Could you reverse your result set and using "ORDER BY <column> DESC LIMIT 1" then use cass_result_first_row()?

Mike
回复全部
回复作者
转发
0 个新帖子