final Map<KijiColumnName, ColumnLayout> columnMap = Maps.newHashMap();
final Iterator<LocalityGroupDesc> itLGDesc = mDesc.getLocalityGroups().iterator();
while (itLGDesc.hasNext()) {
final LocalityGroupDesc lgDesc = itLGDesc.next();
final boolean isRename = (lgDesc.getRenamedFrom() != null);
final String refLGName = isRename ? lgDesc.getRenamedFrom() : lgDesc.getName();
lgDesc.setRenamedFrom(null);
if (isRename && (reference == null)) {
throw new InvalidLayoutException(String.format(
"Invalid rename: no reference table layout for locality group '%s'.", refLGName));
}
final LocalityGroupLayout refLGLayout =
(reference != null) ? reference.mLocalityGroupMap.get(refLGName) : null;
if (isRename && (refLGLayout == null)) {
throw new InvalidLayoutException(String.format(
"Invalid rename: cannot find reference locality group '%s'.", refLGName));
}
final ColumnId refLGId = refLGIdMap.remove(refLGName);
if (lgDesc.getDelete()) {
// This locality group is deleted:
if (refLGId == null) {
throw new InvalidLayoutException(String.format(
"Attempting to delete locality group '%s' unknown in reference layout.",
refLGName));
}
itLGDesc.remove();
continue;
}
// BloomType, block_size were introduced in version 1.2.
if (Versions.BLOCK_SIZE_LAYOUT_VERSION.compareTo(mLayoutVersion) > 0) {
if (lgDesc.getBlockSize() != null) {
// Cannot use max_filesize if this is the case.
throw new InvalidLayoutException(
"Support for specifying block_size begins with layout version "
+ Versions.BLOCK_SIZE_LAYOUT_VERSION);
}
if (lgDesc.getBloomType() != null) {
// Cannot use bloom_type if this is the case.
throw new InvalidLayoutException(
"Support for specifying bloom_type begins with layout version "
+ Versions.BLOCK_SIZE_LAYOUT_VERSION);
}
} else {
if (lgDesc.getBlockSize() != null && lgDesc.getBlockSize() <= 0) {
throw new InvalidLayoutException("block_size must be greater than 0");
}
}
final LocalityGroupLayout lgLayout = new LocalityGroupLayout(lgDesc, refLGLayout);