org.apache.cassandra.config.CFMetaData Java Examples
The following examples show how to use
org.apache.cassandra.config.CFMetaData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mutation.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public String toString(boolean shallow) { StringBuilder buff = new StringBuilder("Mutation("); buff.append("keyspace='").append(keyspaceName).append('\''); buff.append(", key='").append(ByteBufferUtil.bytesToHex(key)).append('\''); buff.append(", modifications=["); if (shallow) { List<String> cfnames = new ArrayList<String>(modifications.size()); for (UUID cfid : modifications.keySet()) { CFMetaData cfm = Schema.instance.getCFMetaData(cfid); cfnames.add(cfm == null ? "-dropped-" : cfm.cfName); } buff.append(StringUtils.join(cfnames, ", ")); } else buff.append(StringUtils.join(modifications.values(), ", ")); return buff.append("])").toString(); }
Example #2
Source File: TriggerExecutorTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void sameKeySameCfPartialRowMutations() throws ConfigurationException, InvalidRequestException { CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerDefinition.create("test", SameKeySameCfPartialTrigger.class.getName())); ColumnFamily cf1 = makeCf(metadata, "k1v1", null); ColumnFamily cf2 = makeCf(metadata, "k2v1", null); Mutation rm1 = new Mutation(bytes("k1"), cf1); Mutation rm2 = new Mutation(bytes("k2"), cf2); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); Collections.sort(tmutations, new RmComparator()); List<ColumnFamily> mutatedCFs = new ArrayList<>(tmutations.get(0).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k1v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertNull(mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2"))); mutatedCFs = new ArrayList<>(tmutations.get(1).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k2v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertEquals(bytes("trigger"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")).value()); }
Example #3
Source File: DefsTables.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static void addColumnFamily(CFMetaData cfm) { assert Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName) == null; KSMetaData ksm = Schema.instance.getKSMetaData(cfm.ksName); ksm = KSMetaData.cloneWith(ksm, Iterables.concat(ksm.cfMetaData().values(), Collections.singleton(cfm))); logger.info("Loading {}", cfm); Schema.instance.load(cfm); // make sure it's init-ed w/ the old definitions first, // since we're going to call initCf on the new one manually Keyspace.open(cfm.ksName); Schema.instance.setKeyspaceDefinition(ksm); if (!StorageService.instance.isClientMode()) { Keyspace.open(ksm.name).initCf(cfm.cfId, cfm.cfName, true); MigrationManager.instance.notifyCreateColumnFamily(cfm); } }
Example #4
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #5
Source File: 986499_AddColumnFamily_0_t.java From coming with MIT License | 6 votes |
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException { super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion()); this.cfm = cfm; KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); if (ksm == null) throw new ConfigurationException("Keyspace does not already exist."); else if (ksm.cfMetaData().containsKey(cfm.cfName)) throw new ConfigurationException("CF is already defined in that keyspace."); else if (!Migration.isLegalName(cfm.cfName)) throw new ConfigurationException("Invalid column family name: " + cfm.cfName); KSMetaData newKsm = makeNewKeyspaceDefinition(ksm); rm = Migration.makeDefinitionMutation(newKsm, null, newVersion); }
Example #6
Source File: SliceByNamesReadCommand.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public long serializedSize(ReadCommand cmd, int version) { TypeSizes sizes = TypeSizes.NATIVE; SliceByNamesReadCommand command = (SliceByNamesReadCommand) cmd; int size = sizes.sizeof(command.isDigestQuery()); int keySize = command.key.remaining(); CFMetaData metadata = Schema.instance.getCFMetaData(cmd.ksName, cmd.cfName); size += sizes.sizeof(command.ksName); size += sizes.sizeof((short)keySize) + keySize; size += sizes.sizeof(command.cfName); size += sizes.sizeof(cmd.timestamp); size += metadata.comparator.namesQueryFilterSerializer().serializedSize(command.filter, version); return size; }
Example #7
Source File: RangeSliceCommand.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public RangeSliceCommand deserialize(DataInput in, int version) throws IOException { String keyspace = in.readUTF(); String columnFamily = in.readUTF(); long timestamp = in.readLong(); CFMetaData metadata = Schema.instance.getCFMetaData(keyspace, columnFamily); IDiskAtomFilter predicate = metadata.comparator.diskAtomFilterSerializer().deserialize(in, version); List<IndexExpression> rowFilter; int filterCount = in.readInt(); rowFilter = new ArrayList<>(filterCount); for (int i = 0; i < filterCount; i++) { rowFilter.add(IndexExpression.readFrom(in)); } AbstractBounds<RowPosition> range = AbstractBounds.serializer.deserialize(in, version).toRowBounds(); int maxResults = in.readInt(); boolean countCQL3Rows = in.readBoolean(); boolean isPaging = in.readBoolean(); return new RangeSliceCommand(keyspace, columnFamily, timestamp, predicate, range, rowFilter, maxResults, countCQL3Rows, isPaging); }
Example #8
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public String system_add_column_family(CfDef cf_def) throws InvalidRequestException, SchemaDisagreementException, TException { logger.debug("add_column_family"); try { ClientState cState = state(); String keyspace = cState.getKeyspace(); cState.hasKeyspaceAccess(keyspace, Permission.CREATE); cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero) CFMetaData cfm = CFMetaData.fromThrift(cf_def); CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions); cfm.addDefaultIndexNames(); if (!cfm.getTriggers().isEmpty()) state().ensureIsSuper("Only superusers are allowed to add triggers."); MigrationManager.announceNewColumnFamily(cfm); return Schema.instance.getVersion().toString(); } catch (RequestValidationException e) { throw ThriftConversion.toThrift(e); } }
Example #9
Source File: 986499_AddColumnFamily_0_s.java From coming with MIT License | 6 votes |
public void applyModels() throws IOException { KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName); ksm = makeNewKeyspaceDefinition(ksm); try { CFMetaData.map(cfm); } catch (ConfigurationException ex) { throw new IOException(ex); } Table.open(cfm.tableName); // make sure it's init-ed w/ the old definitions first, since we're going to call initCf on the new one manually DatabaseDescriptor.setTableDefinition(ksm, newVersion); if (!clientMode) Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName); if (!clientMode) CommitLog.instance().forceNewSegment(); }
Example #10
Source File: DirectoriesTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void testStandardDirs() { for (CFMetaData cfm : CFM) { Directories directories = new Directories(cfm); assertEquals(cfDir(cfm), directories.getDirectoryForNewSSTables()); Descriptor desc = new Descriptor(cfDir(cfm), KS, cfm.cfName, 1, Descriptor.Type.FINAL); File snapshotDir = new File(cfDir(cfm), File.separator + Directories.SNAPSHOT_SUBDIR + File.separator + "42"); assertEquals(snapshotDir, Directories.getSnapshotDirectory(desc, "42")); File backupsDir = new File(cfDir(cfm), File.separator + Directories.BACKUPS_SUBDIR); assertEquals(backupsDir, Directories.getBackupsDirectory(desc)); } }
Example #11
Source File: SelectStatementTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * Calls the <code>SelectStatement.buildBound</code> with the specified restrictions. * * @param restrictions the restrictions * @return the result from the method call to <code>SelectStatement.buildBound</code> * @throws InvalidRequestException if the method call throw an exception */ private static List<Composite> executeBuildBound(Restriction[] restrictions, Bound bound) throws InvalidRequestException { List<AbstractType<?>> types = new ArrayList<>(); for (int i = 0, m = restrictions.length; i < m; i++) types.add(Int32Type.instance); CompoundSparseCellNameType cType = new CompoundSparseCellNameType(types); CFMetaData cfMetaData = new CFMetaData("keyspace", "test", ColumnFamilyType.Standard, cType); List<ColumnDefinition> columnDefs = new ArrayList<>(); for (int i = 0, m = restrictions.length; i < m; i++) { ByteBuffer name = ByteBufferUtil.bytes("clustering_" + i); columnDefs.add(ColumnDefinition.clusteringKeyDef(cfMetaData, name, types.get(i), i)); } return SelectStatement.buildBound(bound, columnDefs, restrictions, false, cType, QueryOptions.DEFAULT); }
Example #12
Source File: BufferCounterCell.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Override public void validateFields(CFMetaData metadata) throws MarshalException { validateName(metadata); // We cannot use the value validator as for other columns as the CounterColumnType validate a long, // which is not the internal representation of counters contextManager.validateContext(value()); }
Example #13
Source File: DropIndexStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { CFMetaData cfm = findIndexedCF(); if (cfm == null) return; state.hasColumnFamilyAccess(cfm.ksName, cfm.cfName, Permission.ALTER); }
Example #14
Source File: Selection.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private static ColumnSpecification makeFunctionSpec(CFMetaData cfm, Selectable.WithFunction fun, AbstractType<?> returnType, ColumnIdentifier alias) throws InvalidRequestException { if (returnType == null) throw new InvalidRequestException(String.format("Unknown function %s called in selection clause", fun.functionName)); return new ColumnSpecification(cfm.ksName, cfm.cfName, alias == null ? new ColumnIdentifier(fun.toString(), true) : alias, returnType); }
Example #15
Source File: SelectStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public SelectStatement(CFMetaData cfm, int boundTerms, Parameters parameters, Selection selection, Term limit) { this.cfm = cfm; this.boundTerms = boundTerms; this.selection = selection; this.keyRestrictions = new Restriction[cfm.partitionKeyColumns().size()]; this.columnRestrictions = new Restriction[cfm.clusteringColumns().size()]; this.parameters = parameters; this.limit = limit; // Now gather a few info on whether we should bother with static columns or not for this statement initStaticColumnsInfo(); }
Example #16
Source File: Selection.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static Selection fromSelectors(CFMetaData cfm, List<RawSelector> rawSelectors) throws InvalidRequestException { if (requiresProcessing(rawSelectors)) { List<ColumnDefinition> defs = new ArrayList<ColumnDefinition>(); List<ColumnSpecification> metadata = new ArrayList<ColumnSpecification>(rawSelectors.size()); List<Selector> selectors = new ArrayList<Selector>(rawSelectors.size()); boolean collectTimestamps = false; boolean collectTTLs = false; for (RawSelector rawSelector : rawSelectors) { Selector selector = makeSelector(cfm, rawSelector, defs, metadata); selectors.add(selector); collectTimestamps |= selector.usesTimestamps(); collectTTLs |= selector.usesTTLs(); } return new SelectionWithProcessing(defs, metadata, selectors, collectTimestamps, collectTTLs); } else { List<ColumnDefinition> defs = new ArrayList<ColumnDefinition>(rawSelectors.size()); List<ColumnSpecification> metadata = new ArrayList<ColumnSpecification>(rawSelectors.size()); for (RawSelector rawSelector : rawSelectors) { assert rawSelector.selectable instanceof ColumnIdentifier.Raw; ColumnIdentifier id = (ColumnIdentifier) rawSelector.selectable.prepare(cfm); ColumnDefinition def = cfm.getColumnDefinition(id); if (def == null) throw new InvalidRequestException(String.format("Undefined name %s in selection clause", id)); defs.add(def); metadata.add(rawSelector.alias == null ? def : makeAliasSpec(cfm, def.type, rawSelector.alias)); } return new SimpleSelection(defs, metadata, false); } }
Example #17
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * This method returns the N endpoints that are responsible for storing the * specified key i.e for replication. * * @param keyspaceName keyspace name also known as keyspace * @param cf Column family name * @param key key for which we need to find the endpoint * @return the endpoint responsible for this key */ public List<InetAddress> getNaturalEndpoints(String keyspaceName, String cf, String key) { KSMetaData ksMetaData = Schema.instance.getKSMetaData(keyspaceName); if (ksMetaData == null) throw new IllegalArgumentException("Unknown keyspace '" + keyspaceName + "'"); CFMetaData cfMetaData = ksMetaData.cfMetaData().get(cf); if (cfMetaData == null) throw new IllegalArgumentException("Unknown table '" + cf + "' in keyspace '" + keyspaceName + "'"); return getNaturalEndpoints(keyspaceName, getPartitioner().getToken(cfMetaData.getKeyValidator().fromString(key))); }
Example #18
Source File: TestSelect.java From sstable-tools with Apache License 2.0 | 5 votes |
@Test public void testSelectCompositeFromSSTable() throws Exception { File path = Utils.getSSTable("ma", 1); String query = String.format("SELECT * FROM \"%s\"", path); CFMetaData cfdatatrue = CassandraUtils.tableFromCQL(new ByteArrayInputStream(Utils.CQL1.getBytes())); CFMetaData cfdata = CassandraUtils.tableFromSSTable(Utils.getSSTable("ma", 1)); Query q = new Query(query, Collections.singleton(path), cfdata); ResultSet result = q.getResults().getResultSet(); Assert.assertEquals(2, result.rows.size()); TableTransformer.dumpResults(cfdata, result, System.out); }
Example #19
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static void announceColumnFamilyUpdate(CFMetaData cfm, boolean fromThrift, boolean announceLocally) throws ConfigurationException { cfm.validate(); CFMetaData oldCfm = Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName); if (oldCfm == null) throw new ConfigurationException(String.format("Cannot update non existing column family '%s' in keyspace '%s'.", cfm.cfName, cfm.ksName)); oldCfm.validateCompatility(cfm); logger.info(String.format("Update ColumnFamily '%s/%s' From %s To %s", cfm.ksName, cfm.cfName, oldCfm, cfm)); announce(addSerializedKeyspace(oldCfm.toSchemaUpdate(cfm, FBUtilities.timestampMicros(), fromThrift), cfm.ksName), announceLocally); }
Example #20
Source File: TestSelect.java From sstable-tools with Apache License 2.0 | 5 votes |
@Test public void testSelectGroupBy() throws Exception { File path = Utils.getSSTable("mc", 1); String query = String.format("SELECT weatherstation_id, date, AVG(temperature) AS avg FROM \"%s\" GROUP BY weatherstation_id, date", path); CFMetaData cfdata = CassandraUtils.tableFromCQL(new ByteArrayInputStream(Utils.CQL5.getBytes())); Query q = new Query(query, Collections.singleton(path), cfdata); ResultSet result = q.getResults().getResultSet(); Assert.assertEquals(2, result.rows.size()); Assert.assertEquals("2016-04-03", TableTransformer.colValue(result, result.rows.get(0), 1)); Assert.assertEquals("71.5", TableTransformer.colValue(result, result.rows.get(0), 2)); Assert.assertEquals("2016-04-04", TableTransformer.colValue(result, result.rows.get(1), 1)); Assert.assertEquals("73.5", TableTransformer.colValue(result, result.rows.get(1), 2)); TableTransformer.dumpResults(cfdata, result, System.out); }
Example #21
Source File: TriggerExecutorTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private static ColumnFamily makeCf(CFMetaData metadata, String columnValue1, String columnValue2) { ColumnFamily cf = ArrayBackedSortedColumns.factory.create(metadata); if (columnValue1 != null) cf.addColumn(new BufferCell(getColumnName(metadata, "c1"), bytes(columnValue1))); if (columnValue2 != null) cf.addColumn(new BufferCell(getColumnName(metadata, "c2"), bytes(columnValue2))); return cf; }
Example #22
Source File: CompositesIndexOnRegular.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static CellNameType buildIndexComparator(CFMetaData baseMetadata, ColumnDefinition columnDef) { int prefixSize = columnDef.position(); List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(prefixSize + 1); types.add(SecondaryIndex.keyComparator); for (int i = 0; i < prefixSize; i++) types.add(baseMetadata.comparator.subtype(i)); return new CompoundDenseCellNameType(types); }
Example #23
Source File: CompactionInfo.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public CompactionInfo(CFMetaData cfm, OperationType tasktype, long completed, long total, String unit) { this.tasktype = tasktype; this.completed = completed; this.total = total; this.cfm = cfm; this.unit = unit; }
Example #24
Source File: RangeSliceCommand.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public long serializedSize(RangeSliceCommand rsc, int version) { long size = TypeSizes.NATIVE.sizeof(rsc.keyspace); size += TypeSizes.NATIVE.sizeof(rsc.columnFamily); size += TypeSizes.NATIVE.sizeof(rsc.timestamp); CFMetaData metadata = Schema.instance.getCFMetaData(rsc.keyspace, rsc.columnFamily); IDiskAtomFilter filter = rsc.predicate; size += metadata.comparator.diskAtomFilterSerializer().serializedSize(filter, version); if (rsc.rowFilter == null) { size += TypeSizes.NATIVE.sizeof(0); } else { size += TypeSizes.NATIVE.sizeof(rsc.rowFilter.size()); for (IndexExpression expr : rsc.rowFilter) { size += TypeSizes.NATIVE.sizeofWithShortLength(expr.column); size += TypeSizes.NATIVE.sizeof(expr.operator.ordinal()); size += TypeSizes.NATIVE.sizeofWithShortLength(expr.value); } } size += AbstractBounds.serializer.serializedSize(rsc.keyRange, version); size += TypeSizes.NATIVE.sizeof(rsc.maxResults); size += TypeSizes.NATIVE.sizeof(rsc.countCQL3Rows); size += TypeSizes.NATIVE.sizeof(rsc.isPaging); return size; }
Example #25
Source File: TriggerExecutorTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void noTriggerMutations() throws ConfigurationException, InvalidRequestException { CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerDefinition.create("test", NoOpTrigger.class.getName())); Mutation rm = new Mutation(bytes("k1"), makeCf(metadata, "v1", null)); assertNull(TriggerExecutor.instance.execute(Collections.singletonList(rm))); }
Example #26
Source File: SSTableIdentityIterator.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private SSTableIdentityIterator(CFMetaData metadata, DataInput in, String filename, DecoratedKey key, long dataSize, boolean checkData, SSTableReader sstable, ColumnSerializer.Flag flag) { assert !checkData || (sstable != null); this.in = in; this.filename = filename; this.key = key; this.dataSize = dataSize; this.flag = flag; this.validateColumns = checkData; Descriptor.Version dataVersion = sstable == null ? Descriptor.Version.CURRENT : sstable.descriptor.version; int expireBefore = (int) (System.currentTimeMillis() / 1000); columnFamily = ArrayBackedSortedColumns.factory.create(metadata); try { columnFamily.delete(DeletionTime.serializer.deserialize(in)); atomIterator = columnFamily.metadata().getOnDiskIterator(in, flag, expireBefore, dataVersion); } catch (IOException e) { if (sstable != null) sstable.markSuspect(); throw new CorruptSSTableException(e, filename); } }
Example #27
Source File: UpdateStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
protected ModificationStatement prepareInternal(CFMetaData cfm, VariableSpecifications boundNames, Attributes attrs) throws InvalidRequestException { UpdateStatement stmt = new UpdateStatement(ModificationStatement.StatementType.UPDATE, boundNames.size(), cfm, attrs); for (Pair<ColumnIdentifier.Raw, Operation.RawUpdate> entry : updates) { ColumnDefinition def = cfm.getColumnDefinition(entry.left.prepare(cfm)); if (def == null) throw new InvalidRequestException(String.format("Unknown identifier %s", entry.left)); Operation operation = entry.right.prepare(keyspace(), def); operation.collectMarkerSpecification(boundNames); switch (def.kind) { case PARTITION_KEY: case CLUSTERING_COLUMN: throw new InvalidRequestException(String.format("PRIMARY KEY part %s found in SET part", entry.left)); default: stmt.addOperation(operation); break; } } stmt.processWhereClause(whereClause, boundNames); return stmt; }
Example #28
Source File: DropTriggerStatement.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public boolean announceMigration(boolean isLocalOnly) throws ConfigurationException, InvalidRequestException { CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()).copy(); if (cfm.removeTrigger(triggerName)) { logger.info("Dropping trigger with name {}", triggerName); MigrationManager.announceColumnFamilyUpdate(cfm, false, isLocalOnly); return true; } if (!ifExists) throw new InvalidRequestException(String.format("Trigger %s was not found", triggerName)); return false; }
Example #29
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public String system_update_column_family(CfDef cf_def) throws InvalidRequestException, SchemaDisagreementException, TException { logger.debug("update_column_family"); try { if (cf_def.keyspace == null || cf_def.name == null) throw new InvalidRequestException("Keyspace and CF name must be set."); state().hasColumnFamilyAccess(cf_def.keyspace, cf_def.name, Permission.ALTER); CFMetaData oldCfm = Schema.instance.getCFMetaData(cf_def.keyspace, cf_def.name); if (oldCfm == null) throw new InvalidRequestException("Could not find column family definition to modify."); if (!oldCfm.isThriftCompatible()) throw new InvalidRequestException("Cannot modify CQL3 table " + oldCfm.cfName + " as it may break the schema. You should use cqlsh to modify CQL3 tables instead."); CFMetaData cfm = CFMetaData.fromThriftForUpdate(cf_def, oldCfm); CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions); cfm.addDefaultIndexNames(); if (!oldCfm.getTriggers().equals(cfm.getTriggers())) state().ensureIsSuper("Only superusers are allowed to add or remove triggers."); MigrationManager.announceColumnFamilyUpdate(cfm, true); return Schema.instance.getVersion().toString(); } catch (RequestValidationException e) { throw ThriftConversion.toThrift(e); } }
Example #30
Source File: SSTableWriter.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public SSTableWriter(String filename, long keyCount, long repairedAt, CFMetaData metadata, IPartitioner partitioner, MetadataCollector sstableMetadataCollector) { super(Descriptor.fromFilename(filename), components(metadata), metadata, partitioner); this.repairedAt = repairedAt; if (compression) { dataFile = SequentialWriter.open(getFilename(), descriptor.filenameFor(Component.COMPRESSION_INFO), metadata.compressionParameters(), sstableMetadataCollector); dbuilder = SegmentedFile.getCompressedBuilder((CompressedSequentialWriter) dataFile); } else { dataFile = SequentialWriter.open(new File(getFilename()), new File(descriptor.filenameFor(Component.CRC))); dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode()); } iwriter = new IndexWriter(keyCount, dataFile); this.sstableMetadataCollector = sstableMetadataCollector; }