s7/scale7-pelops — Issue #52: Usage of microseconds instead of milliseconds for Cassandra timestamps
Author: goossth
Created: 2011-11-04 14:02:51+00:00
State: open

Hi there,

First off--thank you for this well coded and tremendously useful library!

I was wondering whether the following improvement could be made. Currently Pelops uses System.currentTimeMillis() to generate its timestamps which are used in the Cassandra columns. Apparently three zeros are being appended to this number, to turn the figure into an approximation of the system microseconds. However, on most JVMs, more time accuracy is available through the System.nanoTime() call. Instead of adding three zeros to the number of milliseconds, in my opinion it would be better to strip three digits off the number of nanoseconds and use that for a timestamp.

Example:

1320405627458000 - example timestamp currently stored in Cassandra when using Pelops
1320405627458 - example output of System.currentTimeMillis()
1320405627458444000 - example output of System.nanoTime()
1320405627458444 - example timestamp that could be stored in Cassandra through the use of nanoTime()

In cases where I rely on the timestamp to decide which column was added later, this makes a material difference.

Many thanks,
Thomas