I'm writing code to change every TTL in every column over the whole database. As part of that, I want to set the timestamp as well. Setting timestamp works for all columns (maybe for the entire row -- my test data only has 1 column per row) except for the very first one. The timestamp for the first one remains the "current time".
Here is my code:
public <R,C> void updateTTLInAllRows(final ColumnFamily<R,C> cf, final Integer newTTL) throws ConnectionException
// Inserting data
final MutationBatch mutator = getKeyspace().prepareMutationBatch();
final OperationResult<Rows<R, C>> result =
for (Row<R, C> row : result.getResult())
final R rowKey = row.getKey();
final ColumnListMutation<C> mutationBatch = mutator.withRow(cf, rowKey);
for (Column<C> column : row.getColumns())
final C columnKey = column.getName();
final long timestamp = 1400000000000001L; // column.getTimestamp();
final ByteBuffer value = column.getByteBufferValue();
mutationBatch.putColumn(columnKey, value, newTTL);
As a secondary issue, if I call mutator.lockCurrentTimestamp() after the call to setTimestamp, I get a null pointer exception. I'm not really concerned about that one though, it's just fyi.
Which version of astyanax are you using? I wrote a unit test against the latest version and the timestamp is getting set correctly. I did see the NPE and will fix it.
One other thing to keep in mind is that setting the timestamp on the mutator will only take effect for the next withRow. To set the timestamp for columns in a row call mutationBatch.setTimestamp. This is by design.
Fix mutation timestamp override NPE.
Fix for Netflix#236.
Added a bunch of 'sample' functions to be used with the all rows
reader: row copier, column counter, row counter, row trace.