"Expecting exactly one column in URI, got: %s", columnURI);
final KijiColumnName column = columnURI.getColumns().get(0);
// TODO(???) the layout updater interface is currently HBase specific.
// We should make a backend agnostic API for layout updates.
final HBaseKiji kiji = (HBaseKiji) Kiji.Factory.open(columnURI);
try {
final Function<KijiTableLayout, TableLayoutDesc> update =
new Function<KijiTableLayout, TableLayoutDesc>() {
/** {@inheritDoc} */
@Override
public TableLayoutDesc apply(final KijiTableLayout refLayout) {
Preconditions.checkNotNull(refLayout);
try {
final TableLayoutDesc refDesc = refLayout.getDesc();
return new TableLayoutBuilder(refDesc, kiji)
.withLayoutId(nextLayoutId(refDesc.getLayoutId()))
.withWriter(column, writerSchema)
.withWritten(column, writerSchema)
.build();
} catch (InvalidLayoutException ile) {
LOG.error("Internal error while updating table layout in DEVELOPER mode: {}", ile);
throw new InternalKijiError(ile);
} catch (IOException ioe) {
LOG.error("I/O error while updating table layout in DEVELOPER mode: {}", ioe);
throw new KijiIOException(ioe);
}
}
};
try {
final HBaseTableLayoutUpdater updater =
new HBaseTableLayoutUpdater(kiji, columnURI, update);
try {
updater.update();
} finally {
updater.close();
}
} catch (KeeperException ke) {
throw new IOException(ke);
}
} finally {
kiji.release();
}
}