Pregunta

I'm using Hector to read data from a Cassandra DB. An example for a query:

ColumnQuery<String, String, String> cq = HFactory.createColumnQuery(KEYSPACE, stringSerializer, stringSerializer, stringSerializer);
cq.setColumnFamily(columnFamily).setKey("Some_Key").setName("Column_Name");
QueryResult<HColumn<String, String>> cqRes = cq.execute();

The answer I'm getting (the value of this column) looks like this:

[45404,2]

As far as I know A Column consists of a name, value and a timestamp (As mentioned here for example). I'm not writing to this DB, I only read from it. Is it possible that the datastamps are not written at all? Anyways, is there a sprcific way to pool it (the timestamp) using Hector?

¿Fue útil?

Solución

You can use the getClock() method of the column to get the timestamp. Every column has a timestamp in Cassandra. (For counters it's more complicated and they aren't exposed to the client.)

However, the timestamp is used for conflict resolution, to see which write wins. It should not be treated like a date field. If you want to date your records then add a separate date column. You can then have control over resolution, time zone, etc. and it can refer to the whole row rather than an individual column.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top