private static List<ColumnDef> columnDefinitionsToThrift(CFMetaData metadata, Collection<ColumnDefinition> columns) { List<ColumnDef> thriftDefs = new ArrayList<>(columns.size()); for (ColumnDefinition def : columns) if (def.isPartOfCellName(metadata.isCQLTable(), metadata.isSuper())) thriftDefs.add(ThriftConversion.toThrift(metadata, def)); return thriftDefs; }
private static List<ColumnDef> columnDefinitionsToThrift(CFMetaData metadata, Collection<ColumnDefinition> columns) { List<ColumnDef> thriftDefs = new ArrayList<>(columns.size()); for (ColumnDefinition def : columns) if (def.isPartOfCellName(metadata.isCQLTable(), metadata.isSuper())) thriftDefs.add(ThriftConversion.toThrift(metadata, def)); return thriftDefs; }
/** * Returns a ColumnDefinition given a cell name. */ public ColumnDefinition getColumnDefinition(CellName cellName) { ColumnIdentifier id = cellName.cql3ColumnName(this); ColumnDefinition def = id == null ? getColumnDefinition(cellName.toByteBuffer()) // Means a dense layout, try the full column name : getColumnDefinition(id); // It's possible that the def is a PRIMARY KEY or COMPACT_VALUE one in case a concrete cell // name conflicts with a CQL column name, which can happen in 2 cases: // 1) because the user inserted a cell through Thrift that conflicts with a default "alias" used // by CQL for thrift tables (see #6892). // 2) for COMPACT STORAGE tables with a single utf8 clustering column, the cell name can be anything, // including a CQL column name (without this being a problem). // In any case, this is fine, this just mean that columnDefinition is not the ColumnDefinition we are // looking for. return def != null && def.isPartOfCellName() ? def : null; }
public void renameColumn(ColumnIdentifier from, ColumnIdentifier to) throws InvalidRequestException { ColumnDefinition def = getColumnDefinition(from); if (def == null) throw new InvalidRequestException(String.format("Cannot rename unknown column %s in keyspace %s", from, cfName)); if (getColumnDefinition(to) != null) throw new InvalidRequestException(String.format("Cannot rename column %s to %s in keyspace %s; another column of that name already exist", from, to, cfName)); if (def.isPartOfCellName()) { throw new InvalidRequestException(String.format("Cannot rename non PRIMARY KEY part %s", from)); } else if (def.isIndexed()) { throw new InvalidRequestException(String.format("Cannot rename column %s because it is secondary indexed", from)); } ColumnDefinition newDef = def.withNewName(to); // don't call addColumnDefinition/removeColumnDefition because we want to avoid recomputing // the CQL3 cfDef between those two operation addOrReplaceColumnDefinition(newDef); removeColumnDefinition(def); }
throw new InvalidRequestException(String.format("Cannot rename column %s to %s in keyspace %s; another column of that name already exist", from, to, cfName)); if (def.isPartOfCellName(isCQLTable(), isSuper()) && !isDense())
throw new InvalidRequestException(String.format("Cannot rename column %s to %s in keyspace %s; another column of that name already exist", from, to, cfName)); if (def.isPartOfCellName(isCQLTable(), isSuper()) && !isDense())
throw new InvalidRequestException(String.format("Cannot rename column %s to %s in keyspace %s; another column of that name already exist", from, to, cfName)); if (def.isPartOfCellName(isCQLTable(), isSuper()) && !isDense())
if (def.isPartOfCellName()) continue;
if (def.isPartOfCellName(false, isSuper)) continue;
if (def.isPartOfCellName(false, isSuper)) continue;