// This should not happen for compact CF
throw new AssertionError();
}
thriftColumns.add(col);
}
cqlRows.add(new CqlRow(row.key.key, thriftColumns));
}
}
else if (cfDef.isComposite)
{
// Sparse case: group column in cqlRow when composite prefix is equal
if (row.cf == null)
continue;
CompositeType composite = (CompositeType)cfDef.cfm.comparator;
int last = composite.types.size() - 1;
ByteBuffer[] previous = null;
Map<ByteBuffer, IColumn> group = new HashMap<ByteBuffer, IColumn>();
for (IColumn c : row.cf)
{
if (c.isMarkedForDelete())
continue;
ByteBuffer[] current = composite.split(c.name());
// If current differs from previous, we've just finished a group
if (previous != null && !isSameRow(previous, current))
{
cqlRows.add(handleGroup(selection, row.key.key, previous, group, schema));
group = new HashMap<ByteBuffer, IColumn>();
}
// Accumulate the current column
group.put(current[last], c);
previous = current;
}
// Handle the last group
if (previous != null)
cqlRows.add(handleGroup(selection, row.key.key, previous, group, schema));
}
else
{
// Static case: One cqlRow for all columns
thriftColumns = new ArrayList<Column>();
// Respect selection order
for (Pair<CFDefinition.Name, ColumnIdentifier> p : selection)
{
CFDefinition.Name name = p.left;
ByteBuffer nameAsRequested = p.right.key;
if (name.kind == CFDefinition.Name.Kind.KEY_ALIAS)
{
addToSchema(schema, p);
thriftColumns.add(new Column(nameAsRequested).setValue(row.key.key).setTimestamp(-1L));
continue;
}
if (row.cf == null)
continue;
addToSchema(schema, p);
IColumn c = row.cf.getColumn(name.name.key);
Column col = new Column(name.name.key);
if (c != null && !c.isMarkedForDelete())
col.setValue(value(c)).setTimestamp(c.timestamp());
thriftColumns.add(col);
}
cqlRows.add(new CqlRow(row.key.key, thriftColumns));
}
}
// We don't allow reversed on range scan, but we do on multiget (IN (...)), so let's reverse the rows there too.
if (parameters.isColumnsReversed)
Collections.reverse(cqlRows);