public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { state.hasKeyspaceAccess(keyspace(), Permission.ALTER); }
private static List<AbstractType<?>> updateTypes(List<AbstractType<?>> toUpdate, String keyspace, ByteBuffer toReplace, UserType updated) { // But this can also be nested. List<AbstractType<?>> updatedTypes = null; for (int i = 0; i < toUpdate.size(); i++) { AbstractType<?> t = updateWith(toUpdate.get(i), keyspace, toReplace, updated); if (t == null) continue; if (updatedTypes == null) updatedTypes = new ArrayList<>(toUpdate); updatedTypes.set(i, t); } return updatedTypes; }
.orElseThrow(() -> new InvalidRequestException(String.format("No user type named %s exists.", name))); UserType updated = makeUpdatedType(toUpdate, ksm); boolean modified = false; for (ColumnDefinition def : copy.allColumns()) modified |= updateDefinition(copy, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.announceColumnFamilyUpdate(copy, isLocalOnly); boolean modified = false; for (ColumnDefinition def : copy.metadata.allColumns()) modified |= updateDefinition(copy.metadata, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.announceViewUpdate(copy, isLocalOnly); continue; AbstractType<?> upd = updateWith(ut, toUpdate.keyspace, toUpdate.name, updated); if (upd != null) MigrationManager.announceTypeUpdate((UserType) upd, isLocalOnly); return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
throw new InvalidRequestException(String.format("No user type named %s exists.", name)); UserType updated = makeUpdatedType(toUpdate); boolean modified = false; for (ColumnDefinition def : copy.allColumns()) modified |= updateDefinition(copy, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.announceColumnFamilyUpdate(copy, false, isLocalOnly); continue; AbstractType<?> upd = updateWith(ut, toUpdate.keyspace, toUpdate.name, updated); if (upd != null) MigrationManager.announceTypeUpdate((UserType) upd, isLocalOnly);
List<AbstractType<?>> updatedTypes = updateTypes(ut.fieldTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new UserType(ut.keyspace, ut.name, new ArrayList<>(ut.fieldNames()), updatedTypes); List<AbstractType<?>> updatedTypes = updateTypes(tt.allTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new TupleType(updatedTypes); List<AbstractType<?>> updatedTypes = updateTypes(ct.types, keyspace, toReplace, updated); return updatedTypes == null ? null : CompositeType.getInstance(updatedTypes); for (Map.Entry<ByteBuffer, CollectionType> entry : ctct.defined.entrySet()) AbstractType<?> t = updateWith(entry.getValue(), keyspace, toReplace, updated); if (t == null) continue; AbstractType<?> t = updateWith(((ListType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> t = updateWith(((SetType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> k = updateWith(mt.getKeysType(), keyspace, toReplace, updated); AbstractType<?> v = updateWith(mt.getValuesType(), keyspace, toReplace, updated); if (k == null && v == null) return null;
.orElseThrow(() -> new InvalidRequestException(String.format("No user type named %s exists.", name))); UserType updated = makeUpdatedType(toUpdate, ksm); boolean modified = false; for (ColumnDefinition def : copy.allColumns()) modified |= updateDefinition(copy, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.announceColumnFamilyUpdate(copy, isLocalOnly); boolean modified = false; for (ColumnDefinition def : copy.metadata.allColumns()) modified |= updateDefinition(copy.metadata, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.announceViewUpdate(copy, isLocalOnly); continue; AbstractType<?> upd = updateWith(ut, toUpdate.keyspace, toUpdate.name, updated); if (upd != null) MigrationManager.announceTypeUpdate((UserType) upd, isLocalOnly); return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
List<AbstractType<?>> updatedTypes = updateTypes(ut.fieldTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new UserType(ut.keyspace, ut.name, new ArrayList<>(ut.fieldNames()), updatedTypes, type.isMultiCell()); List<AbstractType<?>> updatedTypes = updateTypes(tt.allTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new TupleType(updatedTypes); List<AbstractType<?>> updatedTypes = updateTypes(ct.types, keyspace, toReplace, updated); return updatedTypes == null ? null : CompositeType.getInstance(updatedTypes); AbstractType<?> t = updateWith(((ListType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> t = updateWith(((SetType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> k = updateWith(mt.getKeysType(), keyspace, toReplace, updated); AbstractType<?> v = updateWith(mt.getValuesType(), keyspace, toReplace, updated); if (k == null && v == null) return null;
.orElseThrow(() -> new InvalidRequestException(String.format("No user type named %s exists.", name))); UserType updated = makeUpdatedType(toUpdate, ksm); boolean modified = false; for (ColumnDefinition def : copy.allColumns()) modified |= updateDefinition(copy, def, toUpdate.keyspace, toUpdate.name, updated); if (modified && doAnnounce) MigrationManager.announceColumnFamilyUpdate(copy, isLocalOnly); boolean modified = false; for (ColumnDefinition def : copy.metadata.allColumns()) modified |= updateDefinition(copy.metadata, def, toUpdate.keyspace, toUpdate.name, updated); if (modified && doAnnounce) MigrationManager.announceViewUpdate(copy, isLocalOnly); continue; AbstractType<?> upd = updateWith(ut, toUpdate.keyspace, toUpdate.name, updated); if (upd != null && doAnnounce) MigrationManager.announceTypeUpdate((UserType) upd, isLocalOnly); return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
List<AbstractType<?>> updatedTypes = updateTypes(ut.fieldTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new UserType(ut.keyspace, ut.name, new ArrayList<>(ut.fieldNames()), updatedTypes, type.isMultiCell()); List<AbstractType<?>> updatedTypes = updateTypes(tt.allTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new TupleType(updatedTypes); List<AbstractType<?>> updatedTypes = updateTypes(ct.types, keyspace, toReplace, updated); return updatedTypes == null ? null : CompositeType.getInstance(updatedTypes); AbstractType<?> t = updateWith(((ListType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> t = updateWith(((SetType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> k = updateWith(mt.getKeysType(), keyspace, toReplace, updated); AbstractType<?> v = updateWith(mt.getValuesType(), keyspace, toReplace, updated); if (k == null && v == null) return null;
private static List<AbstractType<?>> updateTypes(List<AbstractType<?>> toUpdate, String keyspace, ByteBuffer toReplace, UserType updated) { // But this can also be nested. List<AbstractType<?>> updatedTypes = null; for (int i = 0; i < toUpdate.size(); i++) { AbstractType<?> t = updateWith(toUpdate.get(i), keyspace, toReplace, updated); if (t == null) continue; if (updatedTypes == null) updatedTypes = new ArrayList<>(toUpdate); updatedTypes.set(i, t); } return updatedTypes; }
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { state.hasKeyspaceAccess(keyspace(), Permission.ALTER); }
.orElseThrow(() -> new InvalidRequestException(String.format("No user type named %s exists.", name))); UserType updated = makeUpdatedType(toUpdate, ksm); ksm = ksm.withSwapped(ksm.types.without(updated.name).with(updated)); Mutation.SimpleBuilder builder = SchemaKeyspace.makeCreateKeyspaceMutation(ksm.name, FBUtilities.timestampMicros()); boolean modified = false; for (ColumnDefinition def : copy.allColumns()) modified |= updateDefinition(copy, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.buildColumnFamilyUpdate(copy, null, builder); boolean modified = false; for (ColumnDefinition def : copy.metadata.allColumns()) modified |= updateDefinition(copy.metadata, def, toUpdate.keyspace, toUpdate.name, updated); if (modified) MigrationManager.addViewUpdateToMutationBuilder(copy, builder); continue; AbstractType<?> upd = updateWith(ut, toUpdate.keyspace, toUpdate.name, updated); if (upd != null) SchemaKeyspace.addTypeToSchemaMutation((UserType) upd, builder); events.add(new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName())); return updated;
List<AbstractType<?>> updatedTypes = updateTypes(ut.fieldTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new UserType(ut.keyspace, ut.name, new ArrayList<>(ut.fieldNames()), updatedTypes, type.isMultiCell()); List<AbstractType<?>> updatedTypes = updateTypes(tt.allTypes(), keyspace, toReplace, updated); return updatedTypes == null ? null : new TupleType(updatedTypes); List<AbstractType<?>> updatedTypes = updateTypes(ct.types, keyspace, toReplace, updated); return updatedTypes == null ? null : CompositeType.getInstance(updatedTypes); AbstractType<?> t = updateWith(((ListType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> t = updateWith(((SetType)type).getElementsType(), keyspace, toReplace, updated); if (t == null) return null; AbstractType<?> k = updateWith(mt.getKeysType(), keyspace, toReplace, updated); AbstractType<?> v = updateWith(mt.getValuesType(), keyspace, toReplace, updated); if (k == null && v == null) return null;
private static List<AbstractType<?>> updateTypes(List<AbstractType<?>> toUpdate, String keyspace, ByteBuffer toReplace, UserType updated) { // But this can also be nested. List<AbstractType<?>> updatedTypes = null; for (int i = 0; i < toUpdate.size(); i++) { AbstractType<?> t = updateWith(toUpdate.get(i), keyspace, toReplace, updated); if (t == null) continue; if (updatedTypes == null) updatedTypes = new ArrayList<>(toUpdate); updatedTypes.set(i, t); } return updatedTypes; }
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { state.hasKeyspaceAccess(keyspace(), Permission.ALTER); }
private static List<AbstractType<?>> updateTypes(List<AbstractType<?>> toUpdate, String keyspace, ByteBuffer toReplace, UserType updated) { // But this can also be nested. List<AbstractType<?>> updatedTypes = null; for (int i = 0; i < toUpdate.size(); i++) { AbstractType<?> t = updateWith(toUpdate.get(i), keyspace, toReplace, updated); if (t == null) continue; if (updatedTypes == null) updatedTypes = new ArrayList<>(toUpdate); updatedTypes.set(i, t); } return updatedTypes; }