else if (cfDef.hasCollections)
{
componentIndex--;
}
cfm.addColumnDefinition(new ColumnDefinition(columnName.key,
type,
null,
null,
null,
componentIndex));
break;
case ALTER:
if (name == null)
throw new InvalidRequestException(String.format("Column %s was not found in table %s", columnName, columnFamily()));
switch (name.kind)
{
case KEY_ALIAS:
AbstractType<?> newType = validator.getType();
if (newType instanceof CounterColumnType)
throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", columnName));
if (cfDef.hasCompositeKey)
{
List<AbstractType<?>> newTypes = new ArrayList<AbstractType<?>>(((CompositeType) cfm.getKeyValidator()).types);
newTypes.set(name.position, newType);
cfm.keyValidator(CompositeType.getInstance(newTypes));
}
else
{
cfm.keyValidator(newType);
}
break;
case COLUMN_ALIAS:
assert cfDef.isComposite;
List<AbstractType<?>> newTypes = new ArrayList<AbstractType<?>>(((CompositeType) cfm.comparator).types);
newTypes.set(name.position, validator.getType());
cfm.comparator = CompositeType.getInstance(newTypes);
break;
case VALUE_ALIAS:
cfm.defaultValidator(validator.getType());
break;
case COLUMN_METADATA:
ColumnDefinition column = cfm.getColumnDefinition(columnName.key);
column.setValidator(validator.getType());
cfm.addColumnDefinition(column);
break;
}
break;
case DROP:
if (cfDef.isCompact)
throw new InvalidRequestException("Cannot drop columns from a compact CF");
if (name == null)
throw new InvalidRequestException(String.format("Column %s was not found in table %s", columnName, columnFamily()));
switch (name.kind)
{
case KEY_ALIAS:
case COLUMN_ALIAS:
throw new InvalidRequestException(String.format("Cannot drop PRIMARY KEY part %s", columnName));
case COLUMN_METADATA:
ColumnDefinition toDelete = null;
for (ColumnDefinition columnDef : cfm.getColumn_metadata().values())
{
if (columnDef.name.equals(columnName.key))
toDelete = columnDef;
}