Preconditions.checkState(mState == State.OPEN,
"Can not put cell to an AtomicKijiPutter instance in state %s.", mState);
final KijiURI tableURI = mTable.getURI();
final FamilyLayout familyLayout = mCapsule.getLayout().getFamilyMap().get(family);
if (familyLayout == null) {
throw new IllegalArgumentException(
String.format("Unknown family '%s' in table %s.", family, tableURI));
}
final ColumnLayout columnLayout = familyLayout.getColumnMap().get(qualifier);
if (columnLayout == null) {
throw new IllegalArgumentException(
String.format("Unknown qualifier '%s' in family '%s' of table %s.",
qualifier, family, tableURI));
}
if (columnLayout.getDesc().getColumnSchema().getType() == SchemaType.COUNTER) {
throw new UnsupportedOperationException(
"Cassandra Kiji does not support puts to counter columns.");
}
final ColumnId localityGroupId = familyLayout.getLocalityGroup().getId();
if (mTableName == null) {
// first put in transaction; set the table.
mTableName = CassandraTableName.getLocalityGroupTableName(
tableURI, familyLayout.getLocalityGroup().getId());
} else {
Preconditions.checkArgument(mTableName.getLocalityGroupId().equals(localityGroupId),
"Kiji Cassandra does not support transactions across multiple locality groups.");
}
// In Cassandra Kiji, a write to HConstants.LATEST_TIMESTAMP should be a write with the
// current transaction time.
final long version;
if (timestamp == HConstants.LATEST_TIMESTAMP) {
version = mTimestamp;
} else {
version = timestamp;
}
int ttl = familyLayout.getLocalityGroup().getDesc().getTtlSeconds();
final KijiColumnName columnName = KijiColumnName.create(family, qualifier);
final CassandraColumnName cassandraColumn =
mCapsule.getColumnNameTranslator().toCassandraColumnName(columnName);