if (mNextIndex >= mKeyValues.length) {
return null;
}
final KeyValue next = mKeyValues[mNextIndex];
final HBaseColumnName hbaseColumn = new HBaseColumnName(
next.getFamily(),
next.getQualifier());
final KijiColumnName column = mColumnNameTranslator.toKijiColumnName(hbaseColumn);
// Validates that the column of the next KeyValue should be included in the iterator.
if (mColumn.isFullyQualified()) {
if (!Objects.equal(mColumn, column)) {
// The column of the next cell is not the requested column, do not return it.
return null;
}
} else {
if (!Objects.equal(column.getFamily(), mColumn.getFamily())) {
// The column of the next cell is not in the requested family, do not return it.
return null;
}
}
if ((null != mNextCell) && !Objects.equal(mNextCell.getColumn(), column)) {
// We've hit the next qualifier before the max versions; reset the current version count.
mCurrentVersions = 0;
}
if (mCurrentVersions < mMaxVersions) {
// decode the cell and return it.
mCurrentVersions++;
mNextIndex++;
return KijiCell.create(column, next.getTimestamp(), mDecoder.decodeCell(next.getValue()));
} else {
// Reset the current versions and try the next qualifier.
mCurrentVersions = 0;
final KeyValue nextQualifierKV = new KeyValue(
mEntityId.getHBaseRowKey(),
hbaseColumn.getFamily(),
Arrays.copyOf(hbaseColumn.getQualifier(), hbaseColumn.getQualifier().length + 1),
Long.MAX_VALUE,
new byte[0]);
mNextIndex = findInsertionPoint(mKeyValues, nextQualifierKV);
return getNextCell();
}