public SerializationHelper(CFMetaData metadata, int version, Flag flag, ColumnFilter columnsToFetch) { this.flag = flag; this.version = version; this.columnsToFetch = columnsToFetch; this.droppedColumns = metadata.getDroppedColumns(); }
public SerializationHelper(CFMetaData metadata, int version, Flag flag, ColumnFilter columnsToFetch) { this.flag = flag; this.version = version; this.columnsToFetch = columnsToFetch; this.droppedColumns = metadata.getDroppedColumns(); }
public SerializationHelper(CFMetaData metadata, int version, Flag flag, ColumnFilter columnsToFetch) { this.flag = flag; this.version = version; this.columnsToFetch = columnsToFetch; this.droppedColumns = metadata.getDroppedColumns(); }
public SerializationHelper(CFMetaData metadata, int version, Flag flag, ColumnFilter columnsToFetch) { this.flag = flag; this.version = version; this.columnsToFetch = columnsToFetch; this.droppedColumns = metadata.getDroppedColumns(); }
public boolean hasDroppedCollectionColumns() { for (DroppedColumn def : getDroppedColumns().values()) if (def.type instanceof CollectionType && def.type.isMultiCell()) return true; return false; }
public boolean hasDroppedCollectionColumns() { for (DroppedColumn def : getDroppedColumns().values()) if (def.type instanceof CollectionType && def.type.isMultiCell()) return true; return false; }
public boolean hasDroppedCollectionColumns() { for (DroppedColumn def : getDroppedColumns().values()) if (def.type instanceof CollectionType && def.type.isMultiCell()) return true; return false; }
public boolean hasDroppedCollectionColumns() { for (DroppedColumn def : getDroppedColumns().values()) if (def.type instanceof CollectionType && def.type.isMultiCell()) return true; return false; }
/** * Build a CQL String representation of Dropped Columns in the given Column Family. * * If the column was dropped once, but is now re-created `ADD` will be appended accordingly. */ @VisibleForTesting public static List<String> getDroppedColumnsAsCQL(CFMetaData metadata) { List<String> droppedColumns = new ArrayList<>(); for (Map.Entry<ByteBuffer, CFMetaData.DroppedColumn> entry: metadata.getDroppedColumns().entrySet()) { CFMetaData.DroppedColumn column = entry.getValue(); droppedColumns.add(toCQLDrop(metadata.ksName, metadata.cfName, column)); if (metadata.getColumnDefinition(entry.getKey()) != null) droppedColumns.add(toCQLAdd(metadata.ksName, metadata.cfName, metadata.getColumnDefinition(entry.getKey()))); } return droppedColumns; }
private static void addDroppedColumns(CFMetaData cfm, AbstractType<?> comparator, Map<String, Long> droppedTimes) { AbstractType<?> last = comparator.getComponents().get(comparator.componentsCount() - 1); Map<ByteBuffer, CollectionType> collections = last instanceof ColumnToCollectionType ? ((ColumnToCollectionType) last).defined : Collections.emptyMap(); for (Map.Entry<String, Long> entry : droppedTimes.entrySet()) { String name = entry.getKey(); ByteBuffer nameBytes = UTF8Type.instance.decompose(name); long time = entry.getValue(); AbstractType<?> type = collections.containsKey(nameBytes) ? collections.get(nameBytes) : BytesType.instance; cfm.getDroppedColumns().put(nameBytes, new CFMetaData.DroppedColumn(name, type, time)); } }
/** * Build a CQL String representation of Dropped Columns in the given Column Family. * * If the column was dropped once, but is now re-created `ADD` will be appended accordingly. */ @VisibleForTesting public static List<String> getDroppedColumnsAsCQL(CFMetaData metadata) { List<String> droppedColumns = new ArrayList<>(); for (Map.Entry<ByteBuffer, CFMetaData.DroppedColumn> entry: metadata.getDroppedColumns().entrySet()) { CFMetaData.DroppedColumn column = entry.getValue(); droppedColumns.add(toCQLDrop(metadata.ksName, metadata.cfName, column)); if (metadata.getColumnDefinition(entry.getKey()) != null) droppedColumns.add(toCQLAdd(metadata.ksName, metadata.cfName, metadata.getColumnDefinition(entry.getKey()))); } return droppedColumns; }
private static void addDroppedColumns(CFMetaData cfm, AbstractType<?> comparator, Map<String, Long> droppedTimes) { AbstractType<?> last = comparator.getComponents().get(comparator.componentsCount() - 1); Map<ByteBuffer, CollectionType> collections = last instanceof ColumnToCollectionType ? ((ColumnToCollectionType) last).defined : Collections.emptyMap(); for (Map.Entry<String, Long> entry : droppedTimes.entrySet()) { String name = entry.getKey(); ByteBuffer nameBytes = UTF8Type.instance.decompose(name); long time = entry.getValue(); AbstractType<?> type = collections.containsKey(nameBytes) ? collections.get(nameBytes) : BytesType.instance; cfm.getDroppedColumns().put(nameBytes, new CFMetaData.DroppedColumn(name, type, time)); } }
private static void addDroppedColumns(CFMetaData cfm, AbstractType<?> comparator, Map<String, Long> droppedTimes) { AbstractType<?> last = comparator.getComponents().get(comparator.componentsCount() - 1); Map<ByteBuffer, CollectionType> collections = last instanceof ColumnToCollectionType ? ((ColumnToCollectionType) last).defined : Collections.emptyMap(); for (Map.Entry<String, Long> entry : droppedTimes.entrySet()) { String name = entry.getKey(); ByteBuffer nameBytes = UTF8Type.instance.decompose(name); long time = entry.getValue(); AbstractType<?> type = collections.containsKey(nameBytes) ? collections.get(nameBytes) : BytesType.instance; cfm.getDroppedColumns().put(nameBytes, new CFMetaData.DroppedColumn(name, type, time)); } }
private static boolean isDroppedColumn(Cell c, CFMetaData meta) { Long droppedAt = meta.getDroppedColumns().get(c.name().cql3ColumnName(meta)); return droppedAt != null && c.timestamp() <= droppedAt; }
public boolean isDroppedColumn(Cell c, CFMetaData meta) { Long droppedAt = meta.getDroppedColumns().get(c.name().cql3ColumnName(meta)); return droppedAt != null && c.timestamp() <= droppedAt; }
private void removeDroppedColumns(ColumnFamily cf) { if (cf == null || cf.metadata.getDroppedColumns().isEmpty()) return; BatchRemoveIterator<Cell> iter = cf.batchRemoveIterator(); while (iter.hasNext()) if (isDroppedColumn(iter.next(), metadata)) iter.remove(); iter.commit(); }
public static Mutation.SimpleBuilder makeDropTableMutation(KeyspaceMetadata keyspace, CFMetaData table, 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(Tables).row(table.cfName).delete(); for (ColumnDefinition column : table.allColumns()) dropColumnFromSchemaMutation(table, column, builder); for (CFMetaData.DroppedColumn column : table.getDroppedColumns().values()) dropDroppedColumnFromSchemaMutation(table, column, timestamp, builder); for (TriggerMetadata trigger : table.getTriggers()) dropTriggerFromSchemaMutation(table, trigger, builder); for (IndexMetadata index : table.getIndexes()) dropIndexFromSchemaMutation(table, index, builder); return builder; }
public static Mutation.SimpleBuilder makeDropTableMutation(KeyspaceMetadata keyspace, CFMetaData table, 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(Tables).row(table.cfName).delete(); for (ColumnDefinition column : table.allColumns()) dropColumnFromSchemaMutation(table, column, builder); for (CFMetaData.DroppedColumn column : table.getDroppedColumns().values()) dropDroppedColumnFromSchemaMutation(table, column, timestamp, builder); for (TriggerMetadata trigger : table.getTriggers()) dropTriggerFromSchemaMutation(table, trigger, builder); for (IndexMetadata index : table.getIndexes()) dropIndexFromSchemaMutation(table, index, builder); return builder; }
public static Mutation.SimpleBuilder makeDropTableMutation(KeyspaceMetadata keyspace, CFMetaData table, 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(Tables).row(table.cfName).delete(); for (ColumnDefinition column : table.allColumns()) dropColumnFromSchemaMutation(table, column, builder); for (CFMetaData.DroppedColumn column : table.getDroppedColumns().values()) dropDroppedColumnFromSchemaMutation(table, column, timestamp, builder); for (TriggerMetadata trigger : table.getTriggers()) dropTriggerFromSchemaMutation(table, trigger, builder); for (IndexMetadata index : table.getIndexes()) dropIndexFromSchemaMutation(table, index, builder); return builder; }
private static void addViewToSchemaMutation(ViewDefinition view, boolean includeColumns, Mutation.SimpleBuilder builder) { CFMetaData table = view.metadata; Row.SimpleBuilder rowBuilder = builder.update(Views) .row(view.viewName) .add("include_all_columns", view.includeAllColumns) .add("base_table_id", view.baseTableId) .add("base_table_name", view.baseTableMetadata().cfName) .add("where_clause", view.whereClause) .add("id", table.cfId); addTableParamsToRowBuilder(table.params, rowBuilder); if (includeColumns) { for (ColumnDefinition column : table.allColumns()) addColumnToSchemaMutation(table, column, builder); for (CFMetaData.DroppedColumn column : table.getDroppedColumns().values()) addDroppedColumnToSchemaMutation(table, column, builder); } }