* Create new Column object with the time stamp passed to the constructor
* @param colName The column name
* @param colValue The column value
* @return An appropriate <code>Column</code> object
* @throws UnsupportedEncodingException
*/
public Column newColumn(String colName, String colValue) {
return newColumn(colName, toBytes(colValue));
}
/**
* Create new Column object with the time stamp passed to the constructor
* @param colName The column name
* @param colValue The column value
* @return An appropriate <code>Column</code> object
* @throws UnsupportedEncodingException
*/
public Column newColumn(byte[] colName, String colValue) {
return newColumn(colName, toBytes(colValue));
}
/**
* Create new Column object with the time stamp passed to the constructor
* @param colName The column name
* @param colValue The column value
* @return An appropriate <code>Column</code> object
* @throws UnsupportedEncodingException
*/
public Column newColumn(String colName, byte[] colValue) {
return newColumn(toBytes(colName), colValue);
}
/**
* Create new Column object with the time stamp passed to the constructor
* @param colName The column name
* @param colValue The column value
* @return An appropriate <code>Column</code> object
* @throws UnsupportedEncodingException
*/
public Column newColumn(byte[] colName, byte[] colValue) {
return new Column(colName, colValue, timestamp);
}
/**
* Create a list of <code>Column</code> objects.
* @param columns The columns from which to compose the list
* @return A list of <code>Column</code> objects
*/
public List<Column> newColumnList(Column... columns) {
ArrayList<Column> list = new ArrayList<Column>(columns.length);
for (Column column : columns)
list.add(column);
return list;
}
/**
* Get the default time stamp used by this <code>Mutator</code> instance as a byte[].
* @param microsToMillis If the time stamp is UTC microseconds (as is a self-constructed time stamp), whether to convert this into a standard milliseconds value
* @return A byte array containing the time stamp <code>long</code> value
*/
public byte[] getMutationTimestamp(boolean microsToMillis) {
long result = timestamp;
if (microsToMillis)
result /= 1000;
return NumberHelper.toBytes(result);
}
/**
* Get the raw time stamp value used by this <code>Mutator</code> instance.
* @return The raw time stamp value being used
*/
public long getMutationTimestampValue() {
return timestamp;
}
@SuppressWarnings("serial")
class MutationList extends ArrayList<Mutation> {}
@SuppressWarnings("serial")
class MutationsByCf extends HashMap<String, List<Mutation>> {}
@SuppressWarnings("serial")
class MutationsByKey extends HashMap<String, Map<String, List<Mutation>>> {}
private final Map<String, Map<String, List<Mutation>>> batch;
private final long timestamp;
/**
* Create a batch mutation operation.
* @param keyspace The keyspace the batch mutation will modify