int qual_len = 0;
int val_len = 1; // Reserve an extra byte for meta-data.
int last_delta = -1; // Time delta, extracted from the qualifier.
int ncells = cells.size();
for (int i = 0; i < ncells; i++) {
final Cell cell = cells.get(i);
final int delta = Internal.getOffsetFromQualifier(cell.qualifier);
// Because we sorted `cells' by qualifier, and because the time delta
// occupies the most significant bits, this should never trigger.
assert delta >= last_delta: ("WTF? It's supposed to be sorted: " + cells
+ " at " + i + " delta=" + delta
+ ", last_delta=" + last_delta);
// The only troublesome case is where we have two (or more) consecutive
// cells with the same time delta, but different flags or values.
if (delta == last_delta) {
// Find the previous cell. Because we potentially replace the one
// right before `i' with a tombstone, we might need to look further
// back a bit more.
Cell prev = Cell.SKIP;
// i > 0 because we can't get here during the first iteration.
// Also the first Cell cannot be Cell.SKIP, so `j' will never
// underflow. And even if it does, we'll get an exception.
for (int j = i - 1; prev == Cell.SKIP; j--) {
prev = cells.get(j);