use of org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableDropColumnOperation in project ignite by apache.
the class GridQueryProcessor method processSchemaOperationLocal.
/**
* Process schema operation.
*
* @param op Operation.
* @param type Type descriptor.
* @param depId Cache deployment ID.
* @param cancelTok Cancel token.
* @throws SchemaOperationException If failed.
*/
@SuppressWarnings("StatementWithEmptyBody")
public void processSchemaOperationLocal(SchemaAbstractOperation op, QueryTypeDescriptorImpl type, IgniteUuid depId, SchemaIndexOperationCancellationToken cancelTok) throws SchemaOperationException {
if (log.isDebugEnabled())
log.debug("Started local index operation [opId=" + op.id() + ']');
String cacheName = op.cacheName();
GridCacheAdapter cache = ctx.cache().internalCache(cacheName);
if (cache == null || !F.eq(depId, cache.context().dynamicDeploymentId()))
throw new SchemaOperationException(SchemaOperationException.CODE_CACHE_NOT_FOUND, cacheName);
try {
if (op instanceof SchemaIndexCreateOperation) {
final SchemaIndexCreateOperation op0 = (SchemaIndexCreateOperation) op;
QueryIndexDescriptorImpl idxDesc = QueryUtils.createIndexDescriptor(type, op0.index());
GridCacheContext cctx = cache.context();
SchemaIndexCacheFilter filter = new TableCacheFilter(cctx, op0.tableName());
SchemaIndexCacheVisitor visitor = new SchemaIndexCacheVisitorImpl(cctx, filter, cancelTok, op0.parallel());
idx.dynamicIndexCreate(op0.schemaName(), op0.tableName(), idxDesc, op0.ifNotExists(), visitor);
} else if (op instanceof SchemaIndexDropOperation) {
SchemaIndexDropOperation op0 = (SchemaIndexDropOperation) op;
idx.dynamicIndexDrop(op0.schemaName(), op0.indexName(), op0.ifExists());
} else if (op instanceof SchemaAlterTableAddColumnOperation) {
SchemaAlterTableAddColumnOperation op0 = (SchemaAlterTableAddColumnOperation) op;
processDynamicAddColumn(type, op0.columns());
idx.dynamicAddColumn(op0.schemaName(), op0.tableName(), op0.columns(), op0.ifTableExists(), op0.ifNotExists());
} else if (op instanceof SchemaAlterTableDropColumnOperation) {
SchemaAlterTableDropColumnOperation op0 = (SchemaAlterTableDropColumnOperation) op;
processDynamicDropColumn(type, op0.columns());
idx.dynamicDropColumn(op0.schemaName(), op0.tableName(), op0.columns(), op0.ifTableExists(), op0.ifExists());
} else
throw new SchemaOperationException("Unsupported operation: " + op);
} catch (Exception e) {
if (e instanceof SchemaOperationException)
throw (SchemaOperationException) e;
else
throw new SchemaOperationException("Schema change operation failed: " + e.getMessage(), e);
}
}
Aggregations