public ColumnDefinition getColumnDefinitionForIndex(String indexName) { for (ColumnDefinition def : allColumns()) { if (indexName.equals(def.getIndexName())) return def; } return null; }
public static Selection wildcard(CFMetaData cfm) { List<ColumnDefinition> all = new ArrayList<>(cfm.allColumns().size()); Iterators.addAll(all, cfm.allColumnsInSelectOrder()); return new SimpleSelection(cfm, all, true); }
public static CFMetaData fromThriftForUpdate(CfDef cf_def, CFMetaData toUpdate) throws InvalidRequestException, ConfigurationException { return internalFromThrift(cf_def, toUpdate.allColumns()); }
public static Selection wildcard(CFMetaData cfm) { List<ColumnDefinition> all = new ArrayList<>(cfm.allColumns().size()); Iterators.addAll(all, cfm.allColumnsInSelectOrder()); return new SimpleSelection(cfm, all, true); }
private static Set<String> existingIndexNames(String cfToExclude) { Set<String> indexNames = new HashSet<>(); for (ColumnFamilyStore cfs : ColumnFamilyStore.all()) if (cfToExclude == null || !cfs.name.equals(cfToExclude)) for (ColumnDefinition cd : cfs.metadata.allColumns()) indexNames.add(cd.getIndexName()); return indexNames; }
public static Selection wildcard(CFMetaData cfm) { List<ColumnDefinition> all = new ArrayList<>(cfm.allColumns().size()); Iterators.addAll(all, cfm.allColumnsInSelectOrder()); return new SimpleSelection(cfm, all, true); }
public static CFMetaData fromThriftForUpdate(CfDef cf_def, CFMetaData toUpdate) throws org.apache.cassandra.exceptions.InvalidRequestException, ConfigurationException { return internalFromThrift(cf_def, false, toUpdate.allColumns(), toUpdate.isDense()); }
public static Selection wildcardWithGroupBy(CFMetaData cfm, VariableSpecifications boundNames) { List<RawSelector> rawSelectors = new ArrayList<>(cfm.allColumns().size()); Iterator<ColumnDefinition> iter = cfm.allColumnsInSelectOrder(); while (iter.hasNext()) { ColumnDefinition.Raw raw = ColumnDefinition.Raw.forColumn(iter.next()); rawSelectors.add(new RawSelector(raw, null)); } return fromSelectors(cfm, rawSelectors, boundNames, true); }
public static CFMetaData fromThriftForUpdate(CfDef cf_def, CFMetaData toUpdate) throws org.apache.cassandra.exceptions.InvalidRequestException, ConfigurationException { return internalFromThrift(cf_def, false, toUpdate.allColumns(), toUpdate.isDense()); }
public static Selection wildcardWithGroupBy(CFMetaData cfm, VariableSpecifications boundNames) { List<RawSelector> rawSelectors = new ArrayList<>(cfm.allColumns().size()); Iterator<ColumnDefinition> iter = cfm.allColumnsInSelectOrder(); while (iter.hasNext()) { ColumnDefinition.Raw raw = ColumnDefinition.Raw.forColumn(iter.next()); rawSelectors.add(new RawSelector(raw, null)); } return fromSelectors(cfm, rawSelectors, boundNames, true); }
/** * This updates the columns stored which are dependent on the base CFMetaData. */ public void updateDefinition(ViewDefinition definition) { this.definition = definition; List<ColumnDefinition> nonPKDefPartOfViewPK = new ArrayList<>(); for (ColumnDefinition baseColumn : baseCfs.metadata.allColumns()) { ColumnDefinition viewColumn = getViewColumn(baseColumn); if (viewColumn != null && !baseColumn.isPrimaryKeyColumn() && viewColumn.isPrimaryKeyColumn()) nonPKDefPartOfViewPK.add(baseColumn); } this.baseNonPKColumnsInViewPK = nonPKDefPartOfViewPK; }
/** * This updates the columns stored which are dependent on the base CFMetaData. */ public void updateDefinition(ViewDefinition definition) { this.definition = definition; List<ColumnDefinition> nonPKDefPartOfViewPK = new ArrayList<>(); for (ColumnDefinition baseColumn : baseCfs.metadata.allColumns()) { ColumnDefinition viewColumn = getViewColumn(baseColumn); if (viewColumn != null && !baseColumn.isPrimaryKeyColumn() && viewColumn.isPrimaryKeyColumn()) nonPKDefPartOfViewPK.add(baseColumn); } this.baseNonPKColumnsInViewPK = nonPKDefPartOfViewPK; }
private ColumnDefinition findIndexedColumn(CFMetaData cfm) { for (ColumnDefinition column : cfm.allColumns()) { if (column.getIndexType() != null && column.getIndexName() != null && column.getIndexName().equals(indexName)) return column; } return null; } }
public void toSchema(Mutation mutation, long timestamp) { toSchemaNoColumnsNoTriggers(mutation, timestamp); for (TriggerDefinition td : triggers.values()) td.toSchema(mutation, cfName, timestamp); for (ColumnDefinition cd : allColumns()) cd.toSchema(mutation, timestamp); }
public ColumnIdentifier getIdentifier(CFMetaData cfm) { if (!cfm.isStaticCompactTable()) return ColumnIdentifier.getInterned(text, true); AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType(); if (thriftColumnNameType instanceof UTF8Type) return ColumnIdentifier.getInterned(text, true); // We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use // thriftColumnNameType ByteBuffer bufferName = ByteBufferUtil.bytes(text); for (ColumnDefinition def : cfm.allColumns()) { if (def.name.bytes.equals(bufferName)) return def.name; } return ColumnIdentifier.getInterned(thriftColumnNameType, thriftColumnNameType.fromString(text), text); }
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; }
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; }
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; }
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; }