public CFMetaData addAllColumnDefinitions(Collection<ColumnDefinition> defs) { for (ColumnDefinition def : defs) addOrReplaceColumnDefinition(def); return this; }
public CFMetaData addColumnDefinition(ColumnDefinition def) throws ConfigurationException { if (columnMetadata.containsKey(def.name.bytes)) throw new ConfigurationException(String.format("Cannot add column %s, a column with the same name already exists", def.name)); return addOrReplaceColumnDefinition(def); }
public CFMetaData addColumnDefinition(ColumnDefinition def) throws ConfigurationException { if (columnMetadata.containsKey(def.name.bytes)) throw new ConfigurationException(String.format("Cannot add column %s, a column with the same name already exists", def.name)); return addOrReplaceColumnDefinition(def); }
public CFMetaData addColumnDefinition(ColumnDefinition def) throws ConfigurationException { if (columnMetadata.containsKey(def.name.bytes)) throw new ConfigurationException(String.format("Cannot add column %s, a column with the same name already exists", def.name)); return addOrReplaceColumnDefinition(def); }
public CFMetaData addColumnDefinition(ColumnDefinition def) throws ConfigurationException { if (columnMetadata.containsKey(def.name.bytes)) throw new ConfigurationException(String.format("Cannot add column %s, a column with the same name already exists", def.name)); return addOrReplaceColumnDefinition(def); }
public CFMetaData addColumnDefinition(ColumnDefinition def) throws ConfigurationException { if (columnMetadata.containsKey(def.name.bytes)) throw new ConfigurationException(String.format("Cannot add column %s, a column with the same name already exists", def.name)); return addOrReplaceColumnDefinition(def); }
public void addColumnMetadataFromAliases(List<ByteBuffer> aliases, AbstractType<?> comparator, ColumnDefinition.Kind kind) { if (comparator instanceof CompositeType) { CompositeType ct = (CompositeType)comparator; for (int i = 0; i < aliases.size(); ++i) { if (aliases.get(i) != null) { addOrReplaceColumnDefinition(new ColumnDefinition(this, aliases.get(i), ct.types.get(i), i, kind)); } } } else { assert aliases.size() <= 1; if (!aliases.isEmpty() && aliases.get(0) != null) addOrReplaceColumnDefinition(new ColumnDefinition(this, aliases.get(0), comparator, null, kind)); } }
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated) { AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated); if (t == null) return false; // We need to update this validator ... cfm.addOrReplaceColumnDefinition(def.withNewType(t)); return true; }
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated) { AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated); if (t == null) return false; // We need to update this validator ... cfm.addOrReplaceColumnDefinition(def.withNewType(t)); return true; }
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated) { AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated); if (t == null) return false; // We need to update this validator ... cfm.addOrReplaceColumnDefinition(def.withNewType(t)); return true; }
private List<ColumnDefinition> addDefaultKeyAliases(List<ColumnDefinition> pkCols) { for (int i = 0; i < pkCols.size(); i++) { if (pkCols.get(i) == null) { Integer idx = null; AbstractType<?> type = keyValidator; if (keyValidator instanceof CompositeType) { idx = i; type = ((CompositeType)keyValidator).types.get(i); } // For compatibility sake, we call the first alias 'key' rather than 'key1'. This // is inconsistent with column alias, but it's probably not worth risking breaking compatibility now. ByteBuffer name = ByteBufferUtil.bytes(i == 0 ? DEFAULT_KEY_ALIAS : DEFAULT_KEY_ALIAS + (i + 1)); ColumnDefinition newDef = ColumnDefinition.partitionKeyDef(this, name, type, idx); addOrReplaceColumnDefinition(newDef); pkCols.set(i, newDef); } } return pkCols; }
private ColumnDefinition addDefaultValueAlias(ColumnDefinition compactValueDef) { if (comparator.isDense()) { if (compactValueDef != null) return compactValueDef; ColumnDefinition newDef = ColumnDefinition.compactValueDef(this, ByteBufferUtil.bytes(DEFAULT_VALUE_ALIAS), defaultValidator); addOrReplaceColumnDefinition(newDef); return newDef; } else { assert compactValueDef == null; return null; } }
private List<ColumnDefinition> addDefaultColumnAliases(List<ColumnDefinition> ckCols) { for (int i = 0; i < ckCols.size(); i++) { if (ckCols.get(i) == null) { Integer idx; AbstractType<?> type; if (comparator.isCompound()) { idx = i; type = comparator.subtype(i); } else { idx = null; type = comparator.asAbstractType(); } ByteBuffer name = ByteBufferUtil.bytes(DEFAULT_COLUMN_ALIAS + (i + 1)); ColumnDefinition newDef = ColumnDefinition.clusteringKeyDef(this, name, type, idx); addOrReplaceColumnDefinition(newDef); ckCols.set(i, newDef); } } return ckCols; }
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); }
addOrReplaceColumnDefinition(oldDef.apply(def));
addOrReplaceColumnDefinition(def.withNewName(to)); addOrReplaceColumnDefinition(def.withNewName(to));
addOrReplaceColumnDefinition(def.withNewName(to)); addOrReplaceColumnDefinition(def.withNewName(to));
addOrReplaceColumnDefinition(def.withNewName(to)); addOrReplaceColumnDefinition(def.withNewName(to));
columnFamily)); cfm.addOrReplaceColumnDefinition(toUpdate.withNewType(TypeParser.parse(validator)));
private boolean updateDefinition(CFMetaData cfm, ColumnDefinition def, String keyspace, ByteBuffer toReplace, UserType updated) { AbstractType<?> t = updateWith(def.type, keyspace, toReplace, updated); if (t == null) return false; // We need to update this validator ... cfm.addOrReplaceColumnDefinition(def.withNewType(t)); // ... but if it's part of the comparator or key validator, we need to go update those too. switch (def.kind) { case PARTITION_KEY: cfm.keyValidator(updateWith(cfm.getKeyValidator(), keyspace, toReplace, updated)); break; case CLUSTERING_COLUMN: cfm.comparator = CellNames.fromAbstractType(updateWith(cfm.comparator.asAbstractType(), keyspace, toReplace, updated), cfm.comparator.isDense()); break; default: // If it's a collection, we still want to modify the comparator because the collection is aliased in it if (def.type instanceof CollectionType && def.type.isMultiCell()) { t = updateWith(cfm.comparator.asAbstractType(), keyspace, toReplace, updated); // If t == null, all relevant comparators were updated via updateWith, which reaches into types and // collections if (t != null) cfm.comparator = CellNames.fromAbstractType(t, cfm.comparator.isDense()); } break; } return true; }