ygerzhedovich commented on code in PR #2563: URL: https://github.com/apache/ignite-3/pull/2563#discussion_r1319826809
########## modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/AbstractCreateIndexCommand.java: ########## @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.catalog.commands; + +import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.ensureNoTableOrIndexExistsWithGivenName; +import static org.apache.ignite.internal.catalog.CatalogParamsValidationUtils.validateIdentifier; +import static org.apache.ignite.internal.catalog.commands.CatalogUtils.schemaOrThrow; +import static org.apache.ignite.internal.catalog.commands.CatalogUtils.tableOrThrow; +import static org.apache.ignite.internal.util.CollectionUtils.copyOrNull; +import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty; +import static org.apache.ignite.lang.IgniteStringFormatter.format; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.ignite.internal.catalog.Catalog; +import org.apache.ignite.internal.catalog.CatalogValidationException; +import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor; +import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor; +import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; +import org.apache.ignite.internal.catalog.storage.NewIndexEntry; +import org.apache.ignite.internal.catalog.storage.ObjectIdGenUpdateEntry; +import org.apache.ignite.internal.catalog.storage.UpdateEntry; + +/** + * Abstract create index command. + * + * <p>Encapsulates common logic of index creation like validation and update entries generation. + */ +public abstract class AbstractCreateIndexCommand extends AbstractIndexCommand { + protected final String tableName; + + protected final boolean unique; + + protected final List<String> columns; + + AbstractCreateIndexCommand(String schemaName, String indexName, String tableName, boolean unique, List<String> columns) + throws CatalogValidationException { + super(schemaName, indexName); + + validate(tableName, columns); + + this.tableName = tableName; + this.unique = unique; + this.columns = copyOrNull(columns); + } + + protected abstract CatalogIndexDescriptor createDescriptor(int indexId, int tableId); + + @Override + public List<UpdateEntry> get(Catalog catalog) { + CatalogSchemaDescriptor schema = schemaOrThrow(catalog, schemaName); + + ensureNoTableOrIndexExistsWithGivenName(schema, indexName); + + CatalogTableDescriptor table = tableOrThrow(schema, tableName); + + assert columns != null; Review Comment: OMG, we are doing the IDEA happy. It's good enoght reason to have it ) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
