static void addTypeToSchemaMutation(UserType type, Mutation.SimpleBuilder mutation) { mutation.update(Types) .row(type.getNameAsString()) .add("field_names", type.fieldNames().stream().map(FieldIdentifier::toString).collect(toList())) .add("field_types", type.fieldTypes().stream().map(AbstractType::asCQL3Type).map(CQL3Type::toString).collect(toList())); }
static void addTypeToSchemaMutation(UserType type, Mutation.SimpleBuilder mutation) { mutation.update(Types) .row(type.getNameAsString()) .add("field_names", type.fieldNames().stream().map(FieldIdentifier::toString).collect(toList())) .add("field_types", type.fieldTypes().stream().map(AbstractType::asCQL3Type).map(CQL3Type::toString).collect(toList())); }
private static void addDroppedColumnToSchemaMutation(CFMetaData table, CFMetaData.DroppedColumn column, Mutation.SimpleBuilder builder) { builder.update(DroppedColumns) .row(table.cfName, column.name) .add("dropped_time", new Date(TimeUnit.MICROSECONDS.toMillis(column.droppedTime))) .add("type", expandUserTypes(column.type).asCQL3Type().toString()); }
private static void dropColumnFromSchemaMutation(CFMetaData table, ColumnDefinition column, Mutation.SimpleBuilder builder) { // Note: we do want to use name.toString(), not name.bytes directly for backward compatibility (For CQL3, this won't make a difference). builder.update(Columns).row(table.cfName, column.name.toString()).delete(); }
@SuppressWarnings("deprecation") static Mutation getStoreMutation(Batch batch, int version) { PartitionUpdate.SimpleBuilder builder = PartitionUpdate.simpleBuilder(SystemKeyspace.LegacyBatchlog, batch.id); builder.row() .timestamp(batch.creationTime) .add("written_at", new Date(batch.creationTime / 1000)) .add("data", getSerializedMutations(version, batch.decodedMutations)) .add("version", version); return builder.buildAsMutation(); }
static Mutation makeStopSessionMutation(ByteBuffer sessionId, int elapsed, int ttl) { PartitionUpdate.SimpleBuilder builder = PartitionUpdate.simpleBuilder(Sessions, sessionId); builder.row() .ttl(ttl) .add("duration", elapsed); return builder.buildAsMutation(); }
public static void addTableExtensionsToSchemaMutation(CFMetaData table, Map<String, ByteBuffer> extensions, Mutation.SimpleBuilder builder) { Row.SimpleBuilder rowBuilder = builder.update(Tables) .row(table.cfName) .add("id", table.cfId) .add("flags", CFMetaData.flagsToStrings(table.flags())); rowBuilder.add("extensions", extensions); }
public static Mutation.SimpleBuilder makeCreateKeyspaceMutation(String name, KeyspaceParams params, long timestamp) { Mutation.SimpleBuilder builder = Mutation.simpleBuilder(Keyspaces.ksName, decorate(Keyspaces, name)) .timestamp(timestamp); builder.update(Keyspaces) .row() .add(KeyspaceParams.Option.DURABLE_WRITES.toString(), params.durableWrites) .add(KeyspaceParams.Option.REPLICATION.toString(), params.replication.asMap()); return builder; }
static Mutation makeStopSessionMutation(ByteBuffer sessionId, int elapsed, int ttl) { PartitionUpdate.SimpleBuilder builder = PartitionUpdate.simpleBuilder(Sessions, sessionId); builder.row() .ttl(ttl) .add("duration", elapsed); return builder.buildAsMutation(); }
public static Mutation.SimpleBuilder makeDropFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp) { // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631). Mutation.SimpleBuilder builder = makeCreateKeyspaceMutation(keyspace.name, keyspace.params, timestamp); builder.update(Functions).row(function.name().name, functionArgumentsList(function)).delete(); return builder; }
public static Mutation.SimpleBuilder makeDropFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp) { // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631). Mutation.SimpleBuilder builder = makeCreateKeyspaceMutation(keyspace.name, keyspace.params, timestamp); builder.update(Functions).row(function.name().name, functionArgumentsList(function)).delete(); return builder; }
private static void addIndexToSchemaMutation(CFMetaData table, IndexMetadata index, Mutation.SimpleBuilder builder) { builder.update(Indexes) .row(table.cfName, index.name) .add("kind", index.kind.toString()) .add("options", index.options); }
private static void dropColumnFromSchemaMutation(CFMetaData table, ColumnDefinition column, Mutation.SimpleBuilder builder) { // Note: we do want to use name.toString(), not name.bytes directly for backward compatibility (For CQL3, this won't make a difference). builder.update(Columns).row(table.cfName, column.name.toString()).delete(); }
public static Mutation.SimpleBuilder makeCreateKeyspaceMutation(String name, KeyspaceParams params, long timestamp) { Mutation.SimpleBuilder builder = Mutation.simpleBuilder(Keyspaces.ksName, decorate(Keyspaces, name)) .timestamp(timestamp); builder.update(Keyspaces) .row() .add(KeyspaceParams.Option.DURABLE_WRITES.toString(), params.durableWrites) .add(KeyspaceParams.Option.REPLICATION.toString(), params.replication.asMap()); return builder; }
public static Mutation.SimpleBuilder makeDropAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp) { // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631). Mutation.SimpleBuilder builder = makeCreateKeyspaceMutation(keyspace.name, keyspace.params, timestamp); builder.update(Aggregates).row(aggregate.name().name, functionArgumentsList(aggregate)).delete(); return builder; }
public static Mutation.SimpleBuilder makeCreateKeyspaceMutation(String name, KeyspaceParams params, long timestamp) { Mutation.SimpleBuilder builder = Mutation.simpleBuilder(Keyspaces.ksName, decorate(Keyspaces, name)) .timestamp(timestamp); builder.update(Keyspaces) .row() .add(KeyspaceParams.Option.DURABLE_WRITES.toString(), params.durableWrites) .add(KeyspaceParams.Option.REPLICATION.toString(), params.replication.asMap()); return builder; }
public static Mutation.SimpleBuilder makeDropViewMutation(KeyspaceMetadata keyspace, ViewDefinition view, long timestamp) { // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631). Mutation.SimpleBuilder builder = makeCreateKeyspaceMutation(keyspace.name, keyspace.params, timestamp); builder.update(Views).row(view.viewName).delete(); CFMetaData table = view.metadata; for (ColumnDefinition column : table.allColumns()) dropColumnFromSchemaMutation(table, column, builder); for (IndexMetadata index : table.getIndexes()) dropIndexFromSchemaMutation(table, index, builder); return builder; }
private static void addTriggerToSchemaMutation(CFMetaData table, TriggerMetadata trigger, Mutation.SimpleBuilder builder) { builder.update(Triggers) .row(table.cfName, trigger.name) .add("options", Collections.singletonMap("class", trigger.classOption)); }
private static void addTriggerToSchemaMutation(CFMetaData table, TriggerMetadata trigger, Mutation.SimpleBuilder builder) { builder.update(Triggers) .row(table.cfName, trigger.name) .add("options", Collections.singletonMap("class", trigger.classOption)); }
public static Mutation.SimpleBuilder makeDropAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp) { // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631). Mutation.SimpleBuilder builder = makeCreateKeyspaceMutation(keyspace.name, keyspace.params, timestamp); builder.update(Aggregates).row(aggregate.name().name, functionArgumentsList(aggregate)).delete(); return builder; }