LOG.debug("Translating HBase column name '{}' to Kiji column name...", hbaseColumnName);
final ColumnId localityGroupID = ColumnId.fromByteArray(hbaseColumnName.getFamily());
final LocalityGroupLayout localityGroup =
mLayout.getLocalityGroupMap().get(mLayout.getLocalityGroupIdNameMap().get(localityGroupID));
if (localityGroup == null) {
throw new NoSuchColumnException(String.format("No locality group with ID %s in table %s.",
localityGroupID.getId(), mLayout.getName()));
}
// Parse the HBase qualifier as a byte[] in order to save a String instantiation
final byte[] hbaseQualifier = hbaseColumnName.getQualifier();
final int index = ArrayUtils.indexOf(hbaseQualifier, SEPARATOR);
if (index == -1) {
throw new NoSuchColumnException(String.format(
"Missing separator in HBase column %s.", hbaseColumnName));
}
final ColumnId familyID = ColumnId.fromString(Bytes.toString(hbaseQualifier, 0, index));
final String rawQualifier =
Bytes.toString(hbaseQualifier, index + 1, hbaseQualifier.length - index - 1);
final FamilyLayout family =
localityGroup.getFamilyMap().get(localityGroup.getFamilyIdNameMap().get(familyID));
if (family == null) {
throw new NoSuchColumnException(String.format(
"No family with ID %s in locality group %s of table %s.",
familyID.getId(), localityGroup.getName(), mLayout.getName()));
}
if (family.isGroupType()) {
// Group type family.
final ColumnId qualifierID = ColumnId.fromString(rawQualifier);
final ColumnLayout qualifier =
family.getColumnMap().get(family.getColumnIdNameMap().get(qualifierID));
if (qualifier == null) {
throw new NoSuchColumnException(String.format(
"No column with ID %s in family %s of table %s.",
qualifierID.getId(), family.getName(), mLayout.getName()));
}
final KijiColumnName kijiColumnName =
new KijiColumnName(family.getName(), qualifier.getName());