This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch ignite-17580 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 7be2c70b8bb68931824dc78b37b3e29d3d90f83e Author: amashenkov <[email protected]> AuthorDate: Mon Aug 29 16:52:51 2022 +0300 Drop modification builders. --- .../schema/modification/AlterColumnBuilder.java | 77 --------------- .../modification/TableModificationBuilder.java | 83 ---------------- .../ignite/schema/modification/package-info.java | 22 ----- .../modification/AlterColumnBuilderImpl.java | 75 --------------- .../modification/TableModificationBuilderImpl.java | 106 --------------------- 5 files changed, 363 deletions(-) diff --git a/modules/api/src/main/java/org/apache/ignite/schema/modification/AlterColumnBuilder.java b/modules/api/src/main/java/org/apache/ignite/schema/modification/AlterColumnBuilder.java deleted file mode 100644 index d2dbf8606a..0000000000 --- a/modules/api/src/main/java/org/apache/ignite/schema/modification/AlterColumnBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.schema.modification; - -import org.apache.ignite.schema.definition.ColumnType; - -/** - * Alter column builder. - * - * <p>NOTE: Only safe actions that can be applied automatically on-fly are allowed. - */ -public interface AlterColumnBuilder { - /** - * Renames a column. - * - * @param newName New column name. - * @return {@code this} for chaining. - */ - AlterColumnBuilder withNewName(String newName); - - /** - * Convert column to a new type. - * - * <p>Note: New type must be compatible with old. - * - * @param newType New column type. - * @return {@code this} for chaining. - */ - AlterColumnBuilder convertTo(ColumnType newType); - - /** - * Sets new column default value. - * - * @param defaultValue Default value. - * @return {@code this} for chaining. - */ - AlterColumnBuilder withNewDefault(Object defaultValue); - - /** - * Set nullability attribute. - * - * @return {@code this} for chaining. - */ - AlterColumnBuilder asNullable(); - - /** - * Mark column as non-nullable. - * - * <p>Note: Replacement param is mandatory, all previously stored 'nulls' will be treated as replacement value on read. - * - * @param replacement Non-null value, that 'null' will be converted to. - * @return {@code this} for chaining. - */ - AlterColumnBuilder asNonNullable(Object replacement); - - /** - * Builds alter column descriptor and pass it to parent table modification builder. - * - * @return Parent builder. - */ - TableModificationBuilder done(); -} diff --git a/modules/api/src/main/java/org/apache/ignite/schema/modification/TableModificationBuilder.java b/modules/api/src/main/java/org/apache/ignite/schema/modification/TableModificationBuilder.java deleted file mode 100644 index af4508544f..0000000000 --- a/modules/api/src/main/java/org/apache/ignite/schema/modification/TableModificationBuilder.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.schema.modification; - -import org.apache.ignite.schema.definition.ColumnDefinition; -import org.apache.ignite.schema.definition.index.IndexDefinition; - -/** - * Collect schema modification commands and pass them to manager to create a schema upgrade script. - */ -public interface TableModificationBuilder { - /** - * Adds new value column. - * - * @param column Column. - * @return {@code this} for chaining. - */ - TableModificationBuilder addColumn(ColumnDefinition column); - - /** - * Adds new non-affinity key column. - * - * @param column Column. - * @return {@code this} for chaining. - */ - TableModificationBuilder addKeyColumn(ColumnDefinition column); - - /** - * Creates alter column builder.. - * - * @param columnName Column name. - * @return Alter column builder. - */ - AlterColumnBuilder alterColumn(String columnName); - - /** - * Drops value column. - * - * <p>Note: Key column drop is not allowed. - * - * @param columnName Column. - * @return {@code this} for chaining. - */ - TableModificationBuilder dropColumn(String columnName); - - /** - * Adds new table index. - * - * @param indexDefinition Table index. - * @return {@code this} for chaining. - */ - TableModificationBuilder addIndex(IndexDefinition indexDefinition); - - /** - * Drops table index. - * - * <p>Note: PK can't be dropped. - * - * @param indexName Index name. - * @return {@code this} for chaining. - */ - TableModificationBuilder dropIndex(String indexName); - - /** - * Apply changes. - */ - void apply(); -} diff --git a/modules/api/src/main/java/org/apache/ignite/schema/modification/package-info.java b/modules/api/src/main/java/org/apache/ignite/schema/modification/package-info.java deleted file mode 100644 index 1b154cad5e..0000000000 --- a/modules/api/src/main/java/org/apache/ignite/schema/modification/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - */ - -/** - * Table schema manipulation API. - */ - -package org.apache.ignite.schema.modification; diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/AlterColumnBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/AlterColumnBuilderImpl.java deleted file mode 100644 index 0b1a12d25d..0000000000 --- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/AlterColumnBuilderImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.schema.modification; - -import org.apache.ignite.schema.definition.ColumnType; -import org.apache.ignite.schema.modification.AlterColumnBuilder; -import org.apache.ignite.schema.modification.TableModificationBuilder; - -/** - * Alter column builder. - */ -class AlterColumnBuilderImpl implements AlterColumnBuilder { - /** Table modification builder. */ - private final TableModificationBuilderImpl tableBuilder; - - /** - * Constructor. - * - * @param tableBuilder Table modification builder. - */ - AlterColumnBuilderImpl(TableModificationBuilderImpl tableBuilder) { - this.tableBuilder = tableBuilder; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder withNewName(String newName) { - return this; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder convertTo(ColumnType newType) { - return this; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder withNewDefault(Object defaultValue) { - return this; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder asNullable() { - return this; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder asNonNullable(Object replacement) { - return this; - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder done() { - return tableBuilder; - } -} diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/TableModificationBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/TableModificationBuilderImpl.java deleted file mode 100644 index 563399fc02..0000000000 --- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/modification/TableModificationBuilderImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.schema.modification; - -import org.apache.ignite.internal.schema.definition.TableDefinitionImpl; -import org.apache.ignite.schema.definition.ColumnDefinition; -import org.apache.ignite.schema.definition.PrimaryKeyDefinition; -import org.apache.ignite.schema.definition.index.IndexDefinition; -import org.apache.ignite.schema.modification.AlterColumnBuilder; -import org.apache.ignite.schema.modification.TableModificationBuilder; - -/** - * Table modification builder. - */ -public class TableModificationBuilderImpl implements TableModificationBuilder { - /** Table. */ - private final TableDefinitionImpl table; - - /** - * Constructor. - * - * @param table Table. - */ - public TableModificationBuilderImpl(TableDefinitionImpl table) { - this.table = table; - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder addColumn(ColumnDefinition column) { - if (table.hasColumn(column.name())) { - throw new IllegalArgumentException("Duplicate column: name='" + column.name() + '\''); - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder addKeyColumn(ColumnDefinition column) { - if (table.hasColumn(column.name())) { - throw new IllegalArgumentException("Duplicate column: name=" + column.name() + '\''); - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public AlterColumnBuilder alterColumn(String columnName) { - return new AlterColumnBuilderImpl(this); - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder dropColumn(String columnName) { - if (table.hasKeyColumn(columnName)) { - throw new IllegalArgumentException("Can't drop key column: name=" + columnName); - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder addIndex(IndexDefinition indexDefinition) { - assert !PrimaryKeyDefinition.PRIMARY_KEY_NAME.equals(indexDefinition.name()); - - if (table.indices().stream().anyMatch(i -> i.name().equals(indexDefinition.name()))) { - throw new IllegalArgumentException("Index already exists: name=" + indexDefinition.name() + '\''); - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableModificationBuilder dropIndex(String indexName) { - if (PrimaryKeyDefinition.PRIMARY_KEY_NAME.equals(indexName)) { - throw new IllegalArgumentException("Can't drop primary key index: name=" + indexName); - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public void apply() { - - } -}
