// The list of families that have been added to the scan
List<String> addedFamilies = new ArrayList<String>();
if (!addAll) {
for (int i : readColIDs) {
ColumnMapping colMap = columnsMapping.get(i);
if (colMap.hbaseRowKey) {
continue;
}
if (colMap.qualifierName == null) {
scan.addFamily(colMap.familyNameBytes);
addedFamilies.add(colMap.familyName);
} else {
if(!addedFamilies.contains(colMap.familyName)){
// add only if the corresponding family has not already been added
scan.addColumn(colMap.familyNameBytes, colMap.qualifierNameBytes);
}
}
empty = false;
}
}
// The HBase table's row key maps to a Hive table column. In the corner case when only the
// row key column is selected in Hive, the HBase Scan will be empty i.e. no column family/
// column qualifier will have been added to the scan. We arbitrarily add at least one column
// to the HBase scan so that we can retrieve all of the row keys and return them as the Hive
// tables column projection.
if (empty) {
for (int i = 0; i < columnsMapping.size(); i++) {
ColumnMapping colMap = columnsMapping.get(i);
if (colMap.hbaseRowKey) {
continue;
}
if (colMap.qualifierName == null) {