This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new 2cdf19aaf2 IGNITE-15556 Drop unused SchemaBuilder API from test framework (#2655) 2cdf19aaf2 is described below commit 2cdf19aaf2015b8d247abb0a6db6b87beeebeac1 Author: Andrew V. Mashenkov <amashen...@users.noreply.github.com> AuthorDate: Wed Oct 4 14:00:09 2023 +0300 IGNITE-15556 Drop unused SchemaBuilder API from test framework (#2655) --- .../schema/AbstractSchemaConverterTest.java | 4 +- .../builder/ColumnDefinitionBuilderTest.java | 53 -- .../builder/HashIndexDefinitionBuilderTest.java | 56 -- .../PrimaryKeyDefinitionDefinitionBuilderTest.java | 79 --- .../builder/SortedIndexDefinitionBuilderTest.java | 50 -- .../schema/builder/TableDefinitionBuilderTest.java | 48 -- .../CatalogToSchemaDescriptorConverterTest.java | 4 +- .../schema/serializer/AbstractSerializerTest.java | 4 +- .../testutils/builder/AbstractIndexBuilder.java | 84 --- .../testutils/builder/ColumnDefinitionBuilder.java | 57 -- .../builder/ColumnDefinitionBuilderImpl.java | 87 --- .../builder/HashIndexDefinitionBuilder.java | 55 -- .../builder/HashIndexDefinitionBuilderImpl.java | 76 --- .../builder/PrimaryKeyDefinitionBuilder.java | 66 --- .../builder/PrimaryKeyDefinitionBuilderImpl.java | 109 ---- .../schema/testutils/builder/SchemaBuilders.java | 98 ---- .../testutils/builder/SchemaObjectBuilder.java | 40 -- .../builder/SortedIndexDefinitionBuilder.java | 89 --- .../builder/SortedIndexDefinitionBuilderImpl.java | 153 ------ .../testutils/builder/TableDefinitionBuilder.java | 72 --- .../builder/TableDefinitionBuilderImpl.java | 113 ---- .../testutils/definition/AbstractSchemaObject.java | 51 -- .../testutils/definition/ColumnDefinition.java | 52 -- .../testutils/definition/ColumnDefinitionImpl.java | 82 --- .../schema/testutils/definition/ColumnType.java | 611 --------------------- .../definition/DefaultValueDefinition.java | 112 ---- .../definition/DefaultValueGenerators.java | 27 - .../testutils/definition/PrimaryKeyDefinition.java | 43 -- .../schema/testutils/definition/SchemaObject.java | 42 -- .../testutils/definition/TableDefinition.java | 55 -- .../testutils/definition/TableDefinitionImpl.java | 115 ---- .../definition/index/ColumnarIndexDefinition.java | 41 -- .../definition/index/HashIndexDefinition.java | 29 - .../definition/index/HashIndexDefinitionImpl.java | 62 --- .../definition/index/IndexColumnDefinition.java | 30 - .../index/IndexColumnDefinitionImpl.java | 41 -- .../definition/index/IndexDefinition.java | 52 -- .../definition/index/PrimaryKeyDefinitionImpl.java | 85 --- .../testutils/definition/index/SortOrder.java | 33 -- .../index/SortedIndexColumnDefinition.java | 30 - .../index/SortedIndexColumnDefinitionImpl.java | 60 -- .../definition/index/SortedIndexDefinition.java | 39 -- .../index/SortedIndexDefinitionImpl.java | 76 --- .../testutils/definition/index/package-info.java | 22 - 44 files changed, 6 insertions(+), 3181 deletions(-) diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/AbstractSchemaConverterTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/AbstractSchemaConverterTest.java index ba18efd3f3..ff6cfad29f 100644 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/AbstractSchemaConverterTest.java +++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/AbstractSchemaConverterTest.java @@ -35,7 +35,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.ignite.internal.schema.testutils.definition.ColumnType.DecimalColumnType; +import org.apache.ignite.internal.catalog.commands.CatalogUtils; import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; import org.apache.ignite.internal.util.ArrayUtils; @@ -111,7 +111,7 @@ public class AbstractSchemaConverterTest extends BaseIgniteAbstractTest { @SuppressWarnings("unchecked") protected static <T> T adjust(T val) { if (val instanceof BigDecimal) { - return (T) ((BigDecimal) val).setScale(DecimalColumnType.DEFAULT_SCALE, HALF_UP); + return (T) ((BigDecimal) val).setScale(CatalogUtils.DEFAULT_SCALE, HALF_UP); } return val; diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/ColumnDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/ColumnDefinitionBuilderTest.java deleted file mode 100644 index c679876796..0000000000 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/ColumnDefinitionBuilderTest.java +++ /dev/null @@ -1,53 +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.builder; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -import java.time.LocalDate; -import org.apache.ignite.internal.schema.testutils.builder.ColumnDefinitionBuilder; -import org.apache.ignite.internal.schema.testutils.builder.SchemaBuilders; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinition; -import org.apache.ignite.internal.schema.testutils.definition.ColumnType; -import org.apache.ignite.internal.schema.testutils.definition.DefaultValueDefinition.ConstantValue; -import org.apache.ignite.internal.schema.testutils.definition.DefaultValueDefinition.DefaultValueType; -import org.junit.jupiter.api.Test; - -/** - * Tests for table column builder. - */ -public class ColumnDefinitionBuilderTest { - /** - * Check column parameters. - */ - @Test - public void testCreateColumn() { - ColumnDefinitionBuilder builder = SchemaBuilders.column("TEST", ColumnType.DATE); - - var dflt = LocalDate.now(); - - ColumnDefinition col = builder.withDefaultValue(dflt).build(); - - assertEquals("TEST", col.name()); - assertEquals(ColumnType.DATE, col.type()); - assertEquals(DefaultValueType.CONSTANT, col.defaultValueDefinition().type()); - assertEquals(dflt, ((ConstantValue) col.defaultValueDefinition()).value()); - assertFalse(col.nullable()); - } -} diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java deleted file mode 100644 index 78c95e1815..0000000000 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java +++ /dev/null @@ -1,56 +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.builder; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.util.Collections; -import org.apache.ignite.internal.schema.testutils.builder.HashIndexDefinitionBuilder; -import org.apache.ignite.internal.schema.testutils.builder.SchemaBuilders; -import org.apache.ignite.internal.schema.testutils.definition.index.HashIndexDefinition; -import org.junit.jupiter.api.Test; - -/** - * Tests for hash index builder. - */ -public class HashIndexDefinitionBuilderTest { - /** - * Build index and check its parameters. - */ - @Test - public void testBuild() { - HashIndexDefinitionBuilder builder = SchemaBuilders.hashIndex("testHI") - .withColumns("A", "B", "C") - .withHints(Collections.singletonMap("param", "value")); - HashIndexDefinition idx = builder.build(); - - assertEquals("TESTHI", idx.name()); - assertEquals(3, idx.columns().size()); - } - - /** - * Try to create index without columns and check error. - */ - @Test - public void testBuildNoColumns() { - HashIndexDefinitionBuilder builder = SchemaBuilders.hashIndex("testHI"); - - assertThrows(AssertionError.class, builder::build); - } -} diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/PrimaryKeyDefinitionDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/PrimaryKeyDefinitionDefinitionBuilderTest.java deleted file mode 100644 index e716d6ffef..0000000000 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/PrimaryKeyDefinitionDefinitionBuilderTest.java +++ /dev/null @@ -1,79 +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.builder; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import org.apache.ignite.internal.schema.testutils.builder.PrimaryKeyDefinitionBuilder; -import org.apache.ignite.internal.schema.testutils.builder.SchemaBuilders; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; -import org.junit.jupiter.api.Test; - -/** - * Primary key builder test. - */ -public class PrimaryKeyDefinitionDefinitionBuilderTest { - /** Test primary key parameters. */ - @Test - public void testPrimaryKeyWithColocationColumns() { - PrimaryKeyDefinitionBuilder builder = SchemaBuilders.primaryKey(); - - builder.withColumns("A", "B", "C").withColocationColumns("B").build(); - - PrimaryKeyDefinition idx = builder.build(); - - assertEquals(3, idx.columns().size()); - assertEquals(1, idx.colocationColumns().size()); - - assertTrue(idx.columns().containsAll(List.of("A", "B", "C"))); - assertTrue(idx.colocationColumns().contains("B")); - - assertFalse(idx.colocationColumns().contains("A")); - assertFalse(idx.colocationColumns().contains("C")); - } - - /** Test primary key parameters. */ - @Test - public void testPrimaryKey() { - PrimaryKeyDefinitionBuilder builder = SchemaBuilders.primaryKey(); - - builder.withColumns("A", "B", "C").build(); - - PrimaryKeyDefinition idx = builder.build(); - - assertEquals(3, idx.columns().size()); - assertEquals(3, idx.colocationColumns().size()); - - assertTrue(idx.columns().containsAll(List.of("A", "B", "C"))); - assertTrue(idx.colocationColumns().containsAll(List.of("A", "B", "C"))); - } - - /** Test primary key parameters. */ - @Test - public void testPrimaryKeyWrongColocationColumn() { - PrimaryKeyDefinitionBuilder builder = SchemaBuilders.primaryKey() - .withColumns("A", "B") - .withColocationColumns("C"); - - assertThrows(IllegalStateException.class, builder::build); - } -} diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/SortedIndexDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/SortedIndexDefinitionBuilderTest.java deleted file mode 100644 index 46712c3cd2..0000000000 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/SortedIndexDefinitionBuilderTest.java +++ /dev/null @@ -1,50 +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.builder; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -import org.apache.ignite.internal.schema.testutils.builder.SchemaBuilders; -import org.apache.ignite.internal.schema.testutils.builder.SortedIndexDefinitionBuilder; -import org.apache.ignite.internal.schema.testutils.definition.index.SortOrder; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexDefinition; -import org.junit.jupiter.api.Test; - -/** - * Tests for sorted index builder. - */ -public class SortedIndexDefinitionBuilderTest { - /** - * Build sorted index and check it's parameters. - */ - @Test - public void testBuild() { - SortedIndexDefinitionBuilder builder = SchemaBuilders.sortedIndex("SIDX"); - - builder.addIndexColumn("A").asc().done(); - builder.addIndexColumn("B").desc().done(); - - SortedIndexDefinition idx = builder.build(); - - assertFalse(idx.unique()); - assertEquals(2, idx.indexedColumns().size()); - assertEquals(SortOrder.ASC, idx.columns().get(0).sortOrder()); - assertEquals(SortOrder.DESC, idx.columns().get(1).sortOrder()); - } -} diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/TableDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/TableDefinitionBuilderTest.java deleted file mode 100644 index c6eedc7c86..0000000000 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/TableDefinitionBuilderTest.java +++ /dev/null @@ -1,48 +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.builder; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.ignite.internal.schema.testutils.builder.SchemaBuilders; -import org.apache.ignite.internal.schema.testutils.builder.TableDefinitionBuilder; -import org.apache.ignite.internal.schema.testutils.definition.ColumnType; -import org.apache.ignite.internal.schema.testutils.definition.TableDefinition; -import org.junit.jupiter.api.Test; - -/** - * Tests for table schema builder. - */ -public class TableDefinitionBuilderTest { - /** - * Create table schema and check its parameters. - */ - @Test - public void testBuild() { - TableDefinitionBuilder builder = SchemaBuilders.tableBuilder("SNAME", "TNAME") - .columns( - SchemaBuilders.column("COL1", ColumnType.DOUBLE).build(), - SchemaBuilders.column("COL2", ColumnType.DOUBLE).build()) - .withPrimaryKey("COL1"); - - TableDefinition tbl = builder.build(); - - assertEquals("TNAME", tbl.name()); - assertEquals(1, tbl.keyColumns().size()); - } -} diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/catalog/CatalogToSchemaDescriptorConverterTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/catalog/CatalogToSchemaDescriptorConverterTest.java index 581fa466f6..55ca4ffbec 100644 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/catalog/CatalogToSchemaDescriptorConverterTest.java +++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/catalog/CatalogToSchemaDescriptorConverterTest.java @@ -31,6 +31,7 @@ import org.apache.ignite.internal.schema.AbstractSchemaConverterTest; import org.apache.ignite.internal.schema.BitmaskNativeType; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.DecimalNativeType; +import org.apache.ignite.internal.schema.DefaultValueGenerator; import org.apache.ignite.internal.schema.DefaultValueProvider.FunctionalValueProvider; import org.apache.ignite.internal.schema.DefaultValueProvider.Type; import org.apache.ignite.internal.schema.NativeType; @@ -40,7 +41,6 @@ import org.apache.ignite.internal.schema.NumberNativeType; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.TemporalNativeType; import org.apache.ignite.internal.schema.VarlenNativeType; -import org.apache.ignite.internal.schema.testutils.definition.DefaultValueGenerators; import org.apache.ignite.sql.ColumnType; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -104,7 +104,7 @@ public class CatalogToSchemaDescriptorConverterTest extends AbstractSchemaConver @Test public void convertColumnDescriptorFunctionalDefault() { String columnName = "UUID"; - String functionName = DefaultValueGenerators.GEN_RANDOM_UUID; + String functionName = DefaultValueGenerator.GEN_RANDOM_UUID.name(); DefaultValue defaultValue = DefaultValue.functionCall(functionName); CatalogTableColumnDescriptor columnDescriptor = new CatalogTableColumnDescriptor( diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/serializer/AbstractSerializerTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/serializer/AbstractSerializerTest.java index 8e7590ca7c..ca8f924ab2 100644 --- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/serializer/AbstractSerializerTest.java +++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/serializer/AbstractSerializerTest.java @@ -46,6 +46,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.UUID; +import org.apache.ignite.internal.catalog.commands.CatalogUtils; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.DefaultValueProvider.Type; import org.apache.ignite.internal.schema.NativeType; @@ -56,7 +57,6 @@ import org.apache.ignite.internal.schema.mapping.ColumnMapper; import org.apache.ignite.internal.schema.mapping.ColumnMapping; import org.apache.ignite.internal.schema.marshaller.schema.AbstractSchemaSerializer; import org.apache.ignite.internal.schema.marshaller.schema.SchemaSerializerImpl; -import org.apache.ignite.internal.schema.testutils.definition.ColumnType.DecimalColumnType; import org.apache.ignite.internal.util.ArrayUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -314,7 +314,7 @@ public class AbstractSerializerTest { @SuppressWarnings("unchecked") protected static <T> T adjust(T val) { if (val instanceof BigDecimal) { - return (T) ((BigDecimal) val).setScale(DecimalColumnType.DEFAULT_SCALE, HALF_UP); + return (T) ((BigDecimal) val).setScale(CatalogUtils.DEFAULT_SCALE, HALF_UP); } return val; diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/AbstractIndexBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/AbstractIndexBuilder.java deleted file mode 100644 index 1ec42fb37f..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/AbstractIndexBuilder.java +++ /dev/null @@ -1,84 +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.testutils.builder; - -import java.util.Collections; -import java.util.Map; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Index base class. - */ -public abstract class AbstractIndexBuilder implements SchemaObjectBuilder { - /** Index name. */ - protected final String name; - - /** Unique flag. */ - private boolean unique; - - /** Builder hints. */ - protected Map<String, String> hints; - - /** - * Constructor. - * - * @param name Index name. - */ - AbstractIndexBuilder(String name) { - this(name, false); - } - - /** - * Constructor. - * - * @param name Index name. - * @param unique Unique flag. - */ - AbstractIndexBuilder(String name, boolean unique) { - this.name = IgniteNameUtils.parseSimpleName(name); - this.unique = unique; - } - - /** - * Unique index flag. - * - * @return Unique flag. - */ - public boolean unique() { - return unique; - } - - /** - * Sets unique index flag. - * - * @return {@code This} for chaining. - */ - public AbstractIndexBuilder unique(boolean unique) { - this.unique = unique; - - return this; - } - - /** {@inheritDoc} */ - @Override - public AbstractIndexBuilder withHints(Map<String, String> hints) { - this.hints = Collections.unmodifiableMap(hints); - - return this; - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilder.java deleted file mode 100644 index c2d6145ab0..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilder.java +++ /dev/null @@ -1,57 +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.testutils.builder; - -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinition; -import org.jetbrains.annotations.Nullable; - -/** - * Table column builder. - */ -public interface ColumnDefinitionBuilder extends SchemaObjectBuilder { - /** - * Set nullable attribute. - * - * @param nullable If {@code false}, null values will not be allowed for this column. - * - * @return {@code this} for chaining. - */ - ColumnDefinitionBuilder asNullable(boolean nullable); - - /** - * Sets column default value expression. - * - * @param defValExpr Default value expression. - * @return {@code this} for chaining. - */ - ColumnDefinitionBuilder withDefaultValue(@Nullable Object defValExpr); - - /** {@inheritDoc} */ - @Override - ColumnDefinitionBuilder withHints(Map<String, String> hints); - - /** - * Builds column. - * - * @return Built column. - */ - @Override - ColumnDefinition build(); -} - diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilderImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilderImpl.java deleted file mode 100644 index 0809c84895..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/ColumnDefinitionBuilderImpl.java +++ /dev/null @@ -1,87 +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.testutils.builder; - -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinition; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinitionImpl; -import org.apache.ignite.internal.schema.testutils.definition.ColumnType; -import org.apache.ignite.internal.schema.testutils.definition.DefaultValueDefinition; -import org.apache.ignite.lang.util.IgniteNameUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Column builder. - */ -class ColumnDefinitionBuilderImpl implements ColumnDefinitionBuilder { - /** Column name. */ - private final String colName; - - /** Column type. */ - private final ColumnType colType; - - /** Nullable flag. */ - private boolean nullable; - - /** Default value expression. */ - private @Nullable Object defValExpr; - - /** - * Constructor. - * - * @param colName Column name. - * @param colType Column type. - */ - public ColumnDefinitionBuilderImpl(String colName, ColumnType colType) { - this.colName = IgniteNameUtils.parseSimpleName(colName); - this.colType = colType; - } - - /** {@inheritDoc} */ - @Override - public ColumnDefinitionBuilderImpl asNullable(boolean nullable) { - this.nullable = nullable; - - return this; - } - - /** {@inheritDoc} */ - @Override - public ColumnDefinitionBuilderImpl withDefaultValue(@Nullable Object defValExpr) { - this.defValExpr = defValExpr; - - return this; - } - - /** {@inheritDoc} */ - @Override - public ColumnDefinitionBuilderImpl withHints(Map<String, String> hints) { - // No op. - - return this; - } - - /** {@inheritDoc} */ - @Override - public ColumnDefinition build() { - var defaultSupp = defValExpr == null - ? DefaultValueDefinition.nullValue() - : DefaultValueDefinition.constant(defValExpr); - return new ColumnDefinitionImpl(colName, colType, nullable, defaultSupp); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilder.java deleted file mode 100644 index 4e108bdfe1..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilder.java +++ /dev/null @@ -1,55 +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.testutils.builder; - -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.index.HashIndexDefinition; - -/** - * Hash index descriptor builder. - */ -public interface HashIndexDefinitionBuilder extends SchemaObjectBuilder { - /** - * Sets indexed columns. - * - * @param columns Indexed columns. - * @return {@code this} for chaining. - */ - HashIndexDefinitionBuilder withColumns(String... columns); - - /** - * Sets indexed columns. - * - * @param columns Indexed columns. - * @return {@code this} for chaining. - */ - HashIndexDefinitionBuilder withColumns(List<String> columns); - - /** {@inheritDoc} */ - @Override - HashIndexDefinitionBuilder withHints(Map<String, String> hints); - - /** - * Builds hash index. - * - * @return Hash index. - */ - @Override - HashIndexDefinition build(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilderImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilderImpl.java deleted file mode 100644 index 0c3d5d251a..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/HashIndexDefinitionBuilderImpl.java +++ /dev/null @@ -1,76 +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.testutils.builder; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.ignite.internal.schema.testutils.definition.index.HashIndexDefinition; -import org.apache.ignite.internal.schema.testutils.definition.index.HashIndexDefinitionImpl; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Hash index builder. - */ -class HashIndexDefinitionBuilderImpl extends AbstractIndexBuilder implements HashIndexDefinitionBuilder { - /** Index columns. */ - private List<String> columns; - - /** - * Constructor. - * - * @param name Index name. - */ - public HashIndexDefinitionBuilderImpl(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public HashIndexDefinitionBuilder withColumns(List<String> columns) { - this.columns = columns.stream().map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public HashIndexDefinitionBuilder withColumns(String... columns) { - this.columns = Arrays.stream(columns).map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public HashIndexDefinitionBuilderImpl withHints(Map<String, String> hints) { - super.withHints(hints); - - return this; - } - - /** {@inheritDoc} */ - @Override - public HashIndexDefinition build() { - assert columns != null; - assert !columns.isEmpty(); - - return new HashIndexDefinitionImpl(name, columns); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilder.java deleted file mode 100644 index e3a3a6e092..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilder.java +++ /dev/null @@ -1,66 +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.testutils.builder; - -import java.util.List; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; - -/** - * Hash index descriptor builder. - */ -public interface PrimaryKeyDefinitionBuilder extends SchemaObjectBuilder { - /** - * Sets colocation columns. - * - * @param cols Colocation columns. Must be a valid subset of key columns. - * @return Primary index builder. - */ - PrimaryKeyDefinitionBuilder withColocationColumns(String... cols); - - /** - * Sets colocation columns. - * - * @param cols Colocation columns. Must be a valid subset of key columns. - * @return Primary index builder. - */ - PrimaryKeyDefinitionBuilder withColocationColumns(List<String> cols); - - /** - * Sets primary key columns. - * - * @param columns Indexed columns. - * @return {@code this} for chaining. - */ - PrimaryKeyDefinitionBuilder withColumns(String... columns); - - /** - * Sets primary key columns. - * - * @param columns Indexed columns. - * @return {@code this} for chaining. - */ - PrimaryKeyDefinitionBuilder withColumns(List<String> columns); - - /** - * Builds primary key. - * - * @return Primary key. - */ - @Override - PrimaryKeyDefinition build(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilderImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilderImpl.java deleted file mode 100644 index 4b107e7bc3..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/PrimaryKeyDefinitionBuilderImpl.java +++ /dev/null @@ -1,109 +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.testutils.builder; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; -import org.apache.ignite.internal.schema.testutils.definition.index.PrimaryKeyDefinitionImpl; -import org.apache.ignite.internal.tostring.IgniteToStringInclude; -import org.apache.ignite.internal.util.CollectionUtils; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Primary key builder. - */ -class PrimaryKeyDefinitionBuilderImpl implements SchemaObjectBuilder, PrimaryKeyDefinitionBuilder { - /** Index columns. */ - @IgniteToStringInclude - private List<String> columns; - - /** Colocation columns. */ - @IgniteToStringInclude - private List<String> colocationColumns; - - /** Builder hints. */ - protected Map<String, String> hints; - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinitionBuilderImpl withColumns(String... columns) { - this.columns = Arrays.stream(columns).map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinitionBuilderImpl withColumns(List<String> columns) { - this.columns = columns.stream().map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinitionBuilderImpl withColocationColumns(String... colocationCols) { - this.colocationColumns = colocationCols == null - ? null - : Arrays.stream(colocationCols).map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinitionBuilderImpl withColocationColumns(List<String> colocationCols) { - this.colocationColumns = colocationCols == null - ? null - : colocationCols.stream().map(IgniteNameUtils::parseSimpleName).collect(Collectors.toList()); - - return this; - } - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinitionBuilderImpl withHints(Map<String, String> hints) { - this.hints = hints; - - return this; - } - - /** {@inheritDoc} */ - @Override - public PrimaryKeyDefinition build() { - if (columns == null) { - throw new IllegalStateException("Primary key column(s) must be configured."); - } - - Set<String> cols = Set.copyOf(columns); - - List<String> colocationCols; - - if (CollectionUtils.nullOrEmpty(colocationColumns)) { - colocationCols = List.copyOf(columns); - } else { - colocationCols = List.copyOf(colocationColumns); - } - - return new PrimaryKeyDefinitionImpl(cols, colocationCols); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaBuilders.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaBuilders.java deleted file mode 100644 index 5ab1d21251..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaBuilders.java +++ /dev/null @@ -1,98 +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.testutils.builder; - - -import org.apache.ignite.internal.schema.testutils.definition.ColumnType; -import org.apache.ignite.internal.schema.testutils.definition.TableDefinition; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Schema builder helper. - */ -public final class SchemaBuilders { - /** - * Create table descriptor from classes. - * - * @param schemaName Schema name. - * @param tableName Table name. - * @param keyClass Key class. - * @param valueClass Value class. - * @return Table descriptor for given key-value pair. - */ - public static TableDefinition buildSchema(String schemaName, String tableName, Class<?> keyClass, Class<?> valueClass) { - // TODO IGNITE-13749: implement schema generation from classes. - - return null; - } - - /** - * Creates table descriptor builder. - * - * @param schemaName Schema name. - * @param tableName Table name. - * @return Table descriptor builder. - */ - public static TableDefinitionBuilder tableBuilder(String schemaName, String tableName) { - return new TableDefinitionBuilderImpl(schemaName, tableName); - } - - /** - * Creates table column builder. - * - * @param name Column name. - * @param type Column type. - * @return Column builder. - */ - public static ColumnDefinitionBuilder column(String name, ColumnType type) { - return new ColumnDefinitionBuilderImpl(name, type); - } - - /** - * Creates primary key builder. - * - * @return Primary key builder. - */ - public static PrimaryKeyDefinitionBuilder primaryKey() { - return new PrimaryKeyDefinitionBuilderImpl(); - } - - /** - * Creates sorted index builder. - * - * @param name Index name. - * @return Sorted index builder. - */ - public static SortedIndexDefinitionBuilder sortedIndex(String name) { - return new SortedIndexDefinitionBuilderImpl(IgniteNameUtils.quote(name)); - } - - /** - * Creates hash index builder. - * - * @param name Index name. - * @return Hash index builder. - */ - public static HashIndexDefinitionBuilder hashIndex(String name) { - return new HashIndexDefinitionBuilderImpl(name); - } - - // Stub. - private SchemaBuilders() { - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaObjectBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaObjectBuilder.java deleted file mode 100644 index 69f403bf2c..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SchemaObjectBuilder.java +++ /dev/null @@ -1,40 +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.testutils.builder; - -import java.util.Map; - -/** - * Builder base interface. - */ -public interface SchemaObjectBuilder { - /** - * Provide hints to a builder. - * - * @param hints Hints. - * @return {@code This} for chaining. - */ - SchemaObjectBuilder withHints(Map<String, String> hints); - - /** - * Builds schema object. - * - * @return Built object. - */ - Object build(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilder.java deleted file mode 100644 index c6e20391c5..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilder.java +++ /dev/null @@ -1,89 +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.testutils.builder; - -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexDefinition; - -/** - * Sorted index descriptor builder. - */ -public interface SortedIndexDefinitionBuilder extends SchemaObjectBuilder { - /** - * Adds a column to index. - * - * @param name Table column name. - * @return Index builder. - */ - SortedIndexColumnBuilder addIndexColumn(String name); - - /** {@inheritDoc} */ - @Override - SortedIndexDefinitionBuilder withHints(Map<String, String> hints); - - /** - * Unique index flag. - * - * @param b {@code True} if a unique index. - * @return {@code This} for chaining. - */ - SortedIndexDefinitionBuilder unique(boolean b); - - /** - * Builds sorted index. - * - * @return Sorted index. - */ - @Override - SortedIndexDefinition build(); - - /** - * Index column builder. - */ - @SuppressWarnings("PublicInnerClass") - interface SortedIndexColumnBuilder { - /** - * Sets descending sort order. - * - * @return {@code this} for chaining. - */ - SortedIndexColumnBuilder desc(); - - /** - * Sets ascending sort order. - * - * @return {@code this} for chaining. - */ - SortedIndexColumnBuilder asc(); - - /** - * Sets column name. - * - * @param name Column name. - * @return {@code this} for chaining. - */ - SortedIndexColumnBuilder withName(String name); - - /** - * Builds and adds the column to the index. - * - * @return Parent builder for chaining. - */ - SortedIndexDefinitionBuilder done(); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilderImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilderImpl.java deleted file mode 100644 index caa1908828..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/SortedIndexDefinitionBuilderImpl.java +++ /dev/null @@ -1,153 +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.testutils.builder; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.apache.ignite.internal.schema.testutils.definition.index.SortOrder; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexColumnDefinition; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexColumnDefinitionImpl; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexDefinition; -import org.apache.ignite.internal.schema.testutils.definition.index.SortedIndexDefinitionImpl; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Sorted index builder. - */ -class SortedIndexDefinitionBuilderImpl extends AbstractIndexBuilder implements SortedIndexDefinitionBuilder { - /** Index columns ordered map. */ - protected final Map<String, SortedIndexColumnBuilderImpl> cols = new LinkedHashMap<>(); - - /** - * Constructor. - * - * @param name Index name. - */ - public SortedIndexDefinitionBuilderImpl(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public SortedIndexDefinitionBuilderImpl withHints(Map<String, String> hints) { - super.withHints(hints); - - return this; - } - - /** {@inheritDoc} */ - @Override - public SortedIndexColumnBuilderImpl addIndexColumn(String name) { - return new SortedIndexColumnBuilderImpl(this).withName(name); - } - - /** - * Add index column. - * - * @param idxBuilder Index builder. - */ - protected void addIndexColumn(SortedIndexColumnBuilderImpl idxBuilder) { - if (cols.put(idxBuilder.name(), idxBuilder) != null) { - throw new IllegalArgumentException("Index with same name already exists: " + idxBuilder.name()); - } - } - - /** {@inheritDoc} */ - @Override - public SortedIndexDefinitionBuilderImpl unique(boolean unique) { - super.unique(unique); - - return this; - } - - /** - * Get index columns. - */ - public List<SortedIndexColumnDefinition> columns() { - return cols.values().stream().map(c -> new SortedIndexColumnDefinitionImpl(c.name, c.order)).collect(Collectors.toList()); - } - - /** {@inheritDoc} */ - @Override - public SortedIndexDefinition build() { - assert !cols.isEmpty(); - - return new SortedIndexDefinitionImpl(name, columns(), unique()); - } - - /** - * Index column builder. - */ - protected static class SortedIndexColumnBuilderImpl implements SortedIndexColumnBuilder { - /** Index builder. */ - private final SortedIndexDefinitionBuilderImpl parent; - - /** Columns name. */ - protected String name; - - /** Index order flag. */ - private SortOrder order = SortOrder.ASC; - - /** - * Constructor. - * - * @param parent Parent builder. - */ - SortedIndexColumnBuilderImpl(SortedIndexDefinitionBuilderImpl parent) { - this.parent = parent; - } - - /** {@inheritDoc} */ - @Override - public SortedIndexColumnBuilderImpl desc() { - order = SortOrder.DESC; - - return this; - } - - /** {@inheritDoc} */ - @Override - public SortedIndexColumnBuilderImpl asc() { - order = SortOrder.ASC; - - return this; - } - - /** {@inheritDoc} */ - @Override - public SortedIndexColumnBuilderImpl withName(String name) { - this.name = IgniteNameUtils.parseSimpleName(name); - - return this; - } - - public String name() { - return name; - } - - /** {@inheritDoc} */ - @Override - public SortedIndexDefinitionBuilderImpl done() { - parent.addIndexColumn(this); - - return parent; - } - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilder.java deleted file mode 100644 index 5a616055b4..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilder.java +++ /dev/null @@ -1,72 +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.testutils.builder; - -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinition; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; -import org.apache.ignite.internal.schema.testutils.definition.TableDefinition; - -/** - * Table definition builder. - */ -public interface TableDefinitionBuilder extends SchemaObjectBuilder { - /** - * Adds columns to the table. - * - * @param columns Table columns definitions. - * @return {@code This} for chaining. - */ - TableDefinitionBuilder columns(List<ColumnDefinition> columns); - - /** - * Adds columns to the table. - * - * @param columns Table columns definitions. - * @return {@code This} for chaining. - */ - TableDefinitionBuilder columns(ColumnDefinition... columns); - - /** - * Shortcut method for adding {@link PrimaryKeyDefinition} of single column. - * - * @param colName Key column name. - * @return {@code This} for chaining. - */ - TableDefinitionBuilder withPrimaryKey(String colName); - - /** - * Adds primary key constraint to the table. - * - * @param primaryKeyDefinition Primary key definition. - * @return {@code This} for chaining. - */ - TableDefinitionBuilder withPrimaryKey(PrimaryKeyDefinition primaryKeyDefinition); - - /** {@inheritDoc} */ - @Override TableDefinitionBuilder withHints(Map<String, String> hints); - - /** - * Builds table definition. - * - * @return Table definition. - */ - @Override - TableDefinition build(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilderImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilderImpl.java deleted file mode 100644 index c50ffb9bd5..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/builder/TableDefinitionBuilderImpl.java +++ /dev/null @@ -1,113 +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.testutils.builder; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.internal.schema.testutils.definition.ColumnDefinition; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; -import org.apache.ignite.internal.schema.testutils.definition.TableDefinition; -import org.apache.ignite.internal.schema.testutils.definition.TableDefinitionImpl; -import org.apache.ignite.lang.util.IgniteNameUtils; - -/** - * Table builder. - */ -class TableDefinitionBuilderImpl implements TableDefinitionBuilder { - /** Schema name. */ - private final String schemaName; - - /** Table name. */ - private final String tableName; - - /** Columns definitions. */ - private final LinkedHashMap<String, ColumnDefinition> columns = new LinkedHashMap<>(); - - /** Table primary key. */ - private PrimaryKeyDefinition primaryKeyDefinition; - - /** - * Constructor. - * - * @param schemaName Schema name. - * @param tableName Table name. - */ - public TableDefinitionBuilderImpl(String schemaName, String tableName) { - this.schemaName = IgniteNameUtils.parseSimpleName(schemaName); - this.tableName = IgniteNameUtils.parseSimpleName(tableName); - } - - /** {@inheritDoc} */ - @Override - public TableDefinitionBuilderImpl columns(List<ColumnDefinition> columns) { - for (ColumnDefinition column : columns) { - if (this.columns.put(column.name(), column) != null) { - throw new IllegalArgumentException("Column with same name already exists: columnName=" + column.name()); - } - } - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableDefinitionBuilderImpl columns(ColumnDefinition... columns) { - return columns(Arrays.asList(columns)); - } - - /** {@inheritDoc} */ - @Override - public TableDefinitionBuilder withPrimaryKey(String colName) { - primaryKeyDefinition = SchemaBuilders.primaryKey().withColumns(IgniteNameUtils.parseSimpleName(colName)).build(); - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableDefinitionBuilder withPrimaryKey(PrimaryKeyDefinition primaryKeyDefinition) { - this.primaryKeyDefinition = primaryKeyDefinition; - - return this; - } - - /** {@inheritDoc} */ - @Override - public TableDefinitionBuilder withHints(Map<String, String> hints) { - // No op. - return this; - } - - /** {@inheritDoc} */ - @Override - public TableDefinition build() { - assert schemaName != null : "Database schema name must be specified."; - - assert primaryKeyDefinition != null : "Primary key index must be configured."; - assert columns.size() > primaryKeyDefinition.columns().size() : "Key or/and value columns must be defined."; - - return new TableDefinitionImpl( - schemaName, - tableName, - columns, - primaryKeyDefinition - ); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/AbstractSchemaObject.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/AbstractSchemaObject.java deleted file mode 100644 index 4a2700c7f8..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/AbstractSchemaObject.java +++ /dev/null @@ -1,51 +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.testutils.definition; - -import org.apache.ignite.internal.tostring.S; - -/** - * Schema object base class. - */ -public abstract class AbstractSchemaObject implements SchemaObject { - /** Schema object name. */ - private final String name; - - /** - * Constructor. - * - * @param name Schema object name. - */ - protected AbstractSchemaObject(String name) { - this.name = name; - } - - /** {@inheritDoc} */ - @Override - public String name() { - return name; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString("SchemaObject", - "name", name, - "class", getClass().getName()); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinition.java deleted file mode 100644 index b0e85326cc..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinition.java +++ /dev/null @@ -1,52 +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.testutils.definition; - -/** - * Table column descriptor. - */ -public interface ColumnDefinition { - /** - * Returns column name. - * - * @return Column name. - */ - String name(); - - /** - * Returns column type. - * - * @return Column type. - */ - ColumnType type(); - - /** - * Returns {@code Nullable} flag value. - * - * @return {@code True} if null-values is allowed, {@code false} otherwise. - */ - boolean nullable(); - - /** - * Returns default value definition. - * - * @param <T> Desired subtype of the definition. - * @return Default value definition. - */ - <T extends DefaultValueDefinition> T defaultValueDefinition(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinitionImpl.java deleted file mode 100644 index 61df32a099..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnDefinitionImpl.java +++ /dev/null @@ -1,82 +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.testutils.definition; - -import org.apache.ignite.internal.tostring.S; - -/** - * Table column. - */ -public class ColumnDefinitionImpl implements ColumnDefinition { - /** Column name. */ - private final String name; - - /** Column type. */ - private final ColumnType type; - - /** Nullable flag. */ - private final boolean nullable; - - private final DefaultValueDefinition defaultValueDefinition; - - /** - * Constructor. - * - * @param name Column name. - * @param type Column type. - * @param nullable Nullability flag. - * @param defaultValueDefinition Default value. - */ - public ColumnDefinitionImpl(String name, ColumnType type, boolean nullable, DefaultValueDefinition defaultValueDefinition) { - this.name = name; - this.type = type; - this.nullable = nullable; - this.defaultValueDefinition = defaultValueDefinition; - } - - /** {@inheritDoc} */ - @Override - public String name() { - return name; - } - - /** {@inheritDoc} */ - @Override - public ColumnType type() { - return type; - } - - /** {@inheritDoc} */ - @Override - public boolean nullable() { - return nullable; - } - - /** {@inheritDoc} */ - @Override - @SuppressWarnings("unchecked") - public <T extends DefaultValueDefinition> T defaultValueDefinition() { - return (T) defaultValueDefinition; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(ColumnDefinitionImpl.class, this); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnType.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnType.java deleted file mode 100644 index ae31af2610..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/ColumnType.java +++ /dev/null @@ -1,611 +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.testutils.definition; - -import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_TIMESTAMP_PRECISION; -import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_TIME_PRECISION; -import static org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_VARLEN_LENGTH; - -import java.util.Objects; -import org.apache.ignite.internal.catalog.commands.CatalogUtils; - -/** - * Predefined column types. - */ -@SuppressWarnings("PublicInnerClass") -public class ColumnType { - /** Boolean. */ - public static final ColumnType BOOLEAN = new ColumnType(ColumnTypeSpec.BOOLEAN); - - /** 8-bit signed int. */ - public static final ColumnType INT8 = new ColumnType(ColumnTypeSpec.INT8); - - /** 16-bit signed int. */ - public static final ColumnType INT16 = new ColumnType(ColumnTypeSpec.INT16); - - /** 32-bit signed int. */ - public static final ColumnType INT32 = new ColumnType(ColumnTypeSpec.INT32); - - /** 64-bit signed int. */ - public static final ColumnType INT64 = new ColumnType(ColumnTypeSpec.INT64); - - /** 32-bit float. */ - public static final ColumnType FLOAT = new ColumnType(ColumnTypeSpec.FLOAT); - - /** 64-bit double. */ - public static final ColumnType DOUBLE = new ColumnType(ColumnTypeSpec.DOUBLE); - - /** 128-bit UUID. */ - public static final ColumnType UUID = new ColumnType(ColumnTypeSpec.UUID); - - /** Timezone-free three-part value representing a year, month, and day. */ - public static final ColumnType DATE = new ColumnType(ColumnTypeSpec.DATE); - - /** - * Returns bit mask type. - * - * @param bits Bit mask size in bits. - * @return Bitmap type. - */ - public static VarLenColumnType bitmaskOf(int bits) { - return new VarLenColumnType(ColumnTypeSpec.BITMASK, bits); - } - - /** - * Returns string type of unlimited length. - * - * @return String type. - */ - public static VarLenColumnType string() { - return VarLenColumnType.UNLIMITED_STRING; - } - - /** - * Return string type of limited size. - * - * @param length String length in chars. - * @return String type. - */ - public static VarLenColumnType stringOf(int length) { - return new VarLenColumnType(ColumnTypeSpec.STRING, length); - } - - /** - * Returns blob type of unlimited length. - * - * @return Blob type. - * @see #blobOf(int) - */ - public static VarLenColumnType blob() { - return VarLenColumnType.UNLIMITED_BLOB; - } - - /** - * Return blob type of limited length. - * - * @param length Blob length in bytes. - * @return Blob type. - */ - public static VarLenColumnType blobOf(int length) { - return new VarLenColumnType(ColumnTypeSpec.BYTES, length); - } - - /** - * Returns number type with given precision. - * - * @param precision Precision of value. - * @return Number type. - * @throws IllegalArgumentException If precision value was invalid. - */ - public static NumberColumnType numberOf(int precision) { - if (precision <= 0) { - throw new IllegalArgumentException("Precision [" + precision + "] must be positive integer value."); - } - - return new NumberColumnType(ColumnTypeSpec.NUMBER, precision); - } - - /** - * Returns number type with the default precision. - * - * @return Number type. - * @see #numberOf(int) - */ - public static NumberColumnType number() { - return NumberColumnType.UNLIMITED_NUMBER; - } - - /** - * Returns decimal type with given precision and scale. - * - * @param precision Precision. - * @param scale Scale. - * @return Decimal type. - * @throws IllegalArgumentException If precision and/or scale values were invalid. - */ - public static DecimalColumnType decimalOf(int precision, int scale) { - if (precision <= 0) { - throw new IllegalArgumentException("Precision [" + precision + "] must be positive integer value."); - } - - if (scale < 0) { - throw new IllegalArgumentException("Scale [" + scale + "] must be non-negative integer value."); - } - - if (precision < scale) { - throw new IllegalArgumentException("Precision [" + precision + "] must be" - + " not lower than scale [ " + scale + " ]."); - } - - return new DecimalColumnType(ColumnTypeSpec.DECIMAL, precision, scale); - } - - /** - * Returns decimal type with default precision and scale values. - * - * @return Decimal type. - * @see #decimalOf(int, int) - */ - public static DecimalColumnType decimal() { - return new DecimalColumnType( - ColumnTypeSpec.DECIMAL, - DecimalColumnType.DEFAULT_PRECISION, - DecimalColumnType.DEFAULT_SCALE - ); - } - - /** - * Returns timezone-free type representing a time of day in hours, minutes, seconds, and fractional seconds with the default precision - * of 0 (seconds). - * - * @return Native type. - * @see CatalogUtils#DEFAULT_TIME_PRECISION - * @see #time(int) - */ - public static TemporalColumnType time() { - return new TemporalColumnType(ColumnTypeSpec.TIME, DEFAULT_TIME_PRECISION); - } - - /** - * Returns timezone-free type representing a time of day in hours, minutes, seconds, and fractional seconds. - * - * <p>Precision is a number of digits in fractional seconds part, from 0 - whole seconds precision up to 9 - nanoseconds precision. - * - * @param precision The number of digits in fractional seconds part. Accepted values are in range [0-9]. - * @return Native type. - * @throws IllegalArgumentException If precision value was invalid. - */ - public static TemporalColumnType time(int precision) { - if (precision < 0 || precision > 9) { - throw new IllegalArgumentException("Unsupported fractional seconds precision: " + precision); - } - - return new TemporalColumnType(ColumnTypeSpec.TIME, precision); - } - - /** - * Returns timezone-free datetime encoded as (date, time) with the default time precision of 6 (microseconds). - * - * @return Native type. - * @see CatalogUtils#DEFAULT_TIMESTAMP_PRECISION - * @see #datetime(int) - */ - public static TemporalColumnType datetime() { - return new TemporalColumnType(ColumnTypeSpec.DATETIME, DEFAULT_TIMESTAMP_PRECISION); - } - - /** - * Returns timezone-free datetime encoded as (date, time). - * - * <p>Precision is a number of digits in fractional seconds part of time, from 0 - whole seconds precision up to 9 - nanoseconds - * precision. - * - * @param precision The number of digits in fractional seconds part. Accepted values are in range [0-9]. - * @return Native type. - * @throws IllegalArgumentException If precision value was invalid. - */ - public static TemporalColumnType datetime(int precision) { - if (precision < 0 || precision > 9) { - throw new IllegalArgumentException("Unsupported fractional seconds precision: " + precision); - } - - return new TemporalColumnType(ColumnTypeSpec.DATETIME, precision); - } - - /** - * Returns point in time as number of ticks since {@code 1970-01-01T00:00:00Z} with the default precision of 6 - * (microseconds). - * - * @return Native type. - * @see CatalogUtils#DEFAULT_TIMESTAMP_PRECISION - * @see #timestamp(int) - */ - public static TemporalColumnType timestamp() { - return new TemporalColumnType(ColumnTypeSpec.TIMESTAMP, DEFAULT_TIMESTAMP_PRECISION); - } - - /** - * Returns point in time as number of ticks since {@code 1970-01-01T00:00:00Z}. Ticks that are stored can be precised to - * second, millisecond, microsecond or nanosecond. - * - * <p>Precision is a number of digits in fractional seconds part of time, from 0 - whole seconds precision up to 9 - nanoseconds - * precision. - * - * @param precision The number of digits in fractional seconds part. Accepted values are in range [0-9]. - * @return Native type. - * @throws IllegalArgumentException If precision value was invalid. - */ - public static TemporalColumnType timestamp(int precision) { - if (precision < 0 || precision > 9) { - throw new IllegalArgumentException("Unsupported fractional seconds precision: " + precision); - } - - return new TemporalColumnType(ColumnTypeSpec.TIMESTAMP, precision); - } - - /** - * Column type of variable length. - */ - public static class VarLenColumnType extends ColumnType { - /** String varlen type of unlimited length. */ - private static final VarLenColumnType UNLIMITED_STRING = new VarLenColumnType(ColumnTypeSpec.STRING, DEFAULT_VARLEN_LENGTH); - - /** Blob varlen type of unlimited length. */ - private static final VarLenColumnType UNLIMITED_BLOB = new VarLenColumnType(ColumnTypeSpec.BYTES, DEFAULT_VARLEN_LENGTH); - - /** Max length. */ - private final int length; - - /** - * Creates variable-length column type. - * - * @param typeSpec Type spec. - * @param length Type max length. - */ - private VarLenColumnType(ColumnTypeSpec typeSpec, int length) { - super(typeSpec); - - this.length = length; - } - - /** - * Max column value length. - * - * @return Max column value length or {@code 0} if unlimited. - */ - public int length() { - return length; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - if (!super.equals(o)) { - return false; - } - - VarLenColumnType type = (VarLenColumnType) o; - - return length == type.length; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), length); - } - } - - /** - * Decimal column type. - */ - public static class DecimalColumnType extends ColumnType { - /** Default precision. */ - public static final int DEFAULT_PRECISION = 19; - - /** Default scale. */ - public static final int DEFAULT_SCALE = 3; - - /** Precision. */ - private final int precision; - - /** Scale. */ - private final int scale; - - /** - * Creates numeric column type. - * - * @param typeSpec Type spec. - * @param precision Precision. - * @param scale Scale. - */ - private DecimalColumnType(ColumnTypeSpec typeSpec, int precision, int scale) { - super(typeSpec); - - this.precision = precision; - this.scale = scale; - } - - /** - * Returns column precision. - * - * @return Precision. - */ - public int precision() { - return precision; - } - - /** - * Returns column scale. - * - * @return Scale. - */ - public int scale() { - return scale; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - if (!super.equals(o)) { - return false; - } - - DecimalColumnType type = (DecimalColumnType) o; - - return precision == type.precision && scale == type.scale; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), precision, scale); - } - } - - /** - * Number column type. - */ - public static class NumberColumnType extends ColumnType { - /** Number type with unlimited precision. */ - public static final NumberColumnType UNLIMITED_NUMBER = new NumberColumnType(ColumnTypeSpec.NUMBER, Integer.MAX_VALUE); - - /** Max precision of value. If -1, column has no precision restrictions. */ - private final int precision; - - /** - * Constructor. - * - * @param typeSpec Type specification. - * @param precision Precision. - */ - private NumberColumnType(ColumnTypeSpec typeSpec, int precision) { - super(typeSpec); - - this.precision = precision; - } - - /** - * Returns column precision. - * - * @return Max number of digits. - */ - public int precision() { - return precision; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - if (!super.equals(o)) { - return false; - } - - NumberColumnType type = (NumberColumnType) o; - - return precision == type.precision; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), precision); - } - } - - /** - * Column type of variable length. - */ - public static class TemporalColumnType extends ColumnType { - /** Fractional seconds precision. */ - private final int precision; - - /** - * Creates temporal type. - * - * @param typeSpec Type spec. - * @param precision Fractional seconds meaningful digits. Allowed values are 0-9, where {@code 0} means second precision, {@code 9} - * means 1-ns precision. - */ - private TemporalColumnType(ColumnTypeSpec typeSpec, int precision) { - super(typeSpec); - - assert precision >= 0 && precision < 10; - - this.precision = precision; - } - - /** - * Return column precision. - * - * @return Number of fractional seconds meaningful digits. - */ - public int precision() { - return precision; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - if (!super.equals(o)) { - return false; - } - - TemporalColumnType type = (TemporalColumnType) o; - - return precision == type.precision; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), precision); - } - } - - /** - * Column type spec. - */ - public enum ColumnTypeSpec { - /** Boolean. */ - BOOLEAN, - - /** 8-bit signed integer. */ - INT8, - - /** 16-bit signed integer. */ - INT16, - - /** 32-bit signed integer. */ - INT32, - - /** 64-bit signed integer. */ - INT64, - - /** 32-bit single-precision floating-point number. */ - FLOAT, - - /** 64-bit double-precision floating-point number. */ - DOUBLE, - - /** A decimal floating-point number. */ - DECIMAL, - - /** Timezone-free date. */ - DATE, - - /** Timezone-free time with precision. */ - TIME, - - /** Timezone-free datetime. */ - DATETIME, - - /** Point on the time-line. Number of ticks since {@code 1970-01-01T00:00:00Z}. Tick unit depends on precision. */ - TIMESTAMP, - - /** 128-bit UUID. */ - UUID, - - /** Bit mask. */ - BITMASK, - - /** String. */ - STRING, - - /** Binary data. */ - BYTES, - - /** Number. */ - NUMBER, - } - - /** Type spec. */ - private final ColumnTypeSpec typeSpec; - - /** - * Creates column type. - * - * @param typeSpec Type spec. - */ - private ColumnType(ColumnTypeSpec typeSpec) { - this.typeSpec = typeSpec; - } - - /** - * Returns column type spec. - * - * @return Type spec. - */ - public ColumnTypeSpec typeSpec() { - return typeSpec; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - ColumnType type = (ColumnType) o; - - return typeSpec == type.typeSpec; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(typeSpec); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueDefinition.java deleted file mode 100644 index 7229e83f1b..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueDefinition.java +++ /dev/null @@ -1,112 +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.testutils.definition; - -import java.util.Objects; - -/** - * Definition of value provider to use as default. - */ -@SuppressWarnings("PublicInnerClass") -public class DefaultValueDefinition { - private static final DefaultValueDefinition NULL = new DefaultValueDefinition(DefaultValueType.NULL); - - /** - * Defines value provider as functional provider. - * - * @param name Name of the function to invoke to generate the value - * @return Default value definition. - * @see DefaultValueGenerators - */ - public static DefaultValueDefinition functionCall(String name) { - return new FunctionCall(Objects.requireNonNull(name, "name")); - } - - /** - * Defines value provider as non-null constant value provider. - * - * @param value A value to use as default. - * @return Default value definition. - * @throws NullPointerException If value argument is null. - */ - public static DefaultValueDefinition constant(Object value) { - return new ConstantValue(Objects.requireNonNull(value, "value")); - } - - /** - * Defines value provider as constant null provider. - * - * @return Default value definition. - */ - public static DefaultValueDefinition nullValue() { - return NULL; - } - - /** Types of the defaults. */ - public enum DefaultValueType { - /** Default is not specified or explicitly specified as null. */ - NULL, - - /** Default is specified as non-null constant. */ - CONSTANT, - - /** Default is specified as a call to a function. */ - FUNCTION_CALL - } - - protected final DefaultValueType type; - - private DefaultValueDefinition(DefaultValueType type) { - this.type = type; - } - - /** Returns type of the default value. */ - public DefaultValueType type() { - return type; - } - - /** Defines default value provider as a function call. */ - public static class FunctionCall extends DefaultValueDefinition { - private final String functionName; - - private FunctionCall(String functionName) { - super(DefaultValueType.FUNCTION_CALL); - this.functionName = functionName; - } - - /** Returns name of the function to use as value generator. */ - public String functionName() { - return functionName; - } - } - - /** Defines default value provider as a constant. */ - public static class ConstantValue extends DefaultValueDefinition { - private final Object value; - - private ConstantValue(Object value) { - super(DefaultValueType.CONSTANT); - this.value = value; - } - - /** Returns value to use as default. */ - public Object value() { - return value; - } - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueGenerators.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueGenerators.java deleted file mode 100644 index 5f04536a55..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/DefaultValueGenerators.java +++ /dev/null @@ -1,27 +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.testutils.definition; - -/** - * Enumeration of all supported value generators that could be used as a default value provider - * (i.e. could be specified as a default in column definition). - */ -public class DefaultValueGenerators { - /** Generator that generates random UUID string. */ - public static final String GEN_RANDOM_UUID = "GEN_RANDOM_UUID"; -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/PrimaryKeyDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/PrimaryKeyDefinition.java deleted file mode 100644 index abf7300b0b..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/PrimaryKeyDefinition.java +++ /dev/null @@ -1,43 +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.testutils.definition; - -import java.util.List; -import java.util.Set; - -/** - * Primary key constraint. - */ -public interface PrimaryKeyDefinition extends SchemaObject { - /** Default primary key name. */ - String PRIMARY_KEY_NAME = "PK"; - - /** - * Returns key columns. - * - * @return Key columns. - */ - Set<String> columns(); - - /** - * Returns colocation columns. - * - * @return Colocation columns. - */ - List<String> colocationColumns(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/SchemaObject.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/SchemaObject.java deleted file mode 100644 index 44b14ef6c1..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/SchemaObject.java +++ /dev/null @@ -1,42 +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.testutils.definition; - -/** - * Schema object. - */ -public interface SchemaObject { - /** Default schema name. */ - String DEFAULT_DATABASE_SCHEMA_NAME = "PUBLIC"; - - /** - * Returns name of schema object. - * - * @return Object name. - */ - String name(); - - /** - * Returns database schema name this object belongs to. - * - * @return Database schema name. - */ - default String schemaName() { - return DEFAULT_DATABASE_SCHEMA_NAME; - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinition.java deleted file mode 100644 index 683b278f56..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinition.java +++ /dev/null @@ -1,55 +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.testutils.definition; - -import java.util.List; -import java.util.Set; - -/** - * Table schema configuration. - */ -public interface TableDefinition extends SchemaObject { - /** - * Returns table name. - * - * @return Table name. - */ - @Override - String name(); - - /** - * Returns key columns. - * - * @return List of columns. - */ - Set<String> keyColumns(); - - /** - * Returns affinity columns. - * - * @return List of columns. - */ - List<String> colocationColumns(); - - /** - * Returns table columns in user-defined order. - * - * @return List of columns. - */ - List<ColumnDefinition> columns(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinitionImpl.java deleted file mode 100644 index b1d2c1d193..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/TableDefinitionImpl.java +++ /dev/null @@ -1,115 +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.testutils.definition; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Set; -import org.apache.ignite.internal.tostring.S; - -/** - * Table. - */ -@SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") -public class TableDefinitionImpl extends AbstractSchemaObject implements TableDefinition { - /** Schema name. */ - private final String schemaName; - - /** Key columns. */ - private final LinkedHashMap<String, ColumnDefinition> colMap; - - /** Cached key columns. */ - private final Set<String> keyCols; - - /** Colocation columns. */ - private final List<String> colocationCols; - - /** - * Constructor. - * - * @param schemaName Schema name. - * @param tableName Table name. - * @param colMap Columns. - * @param primaryKeyDefinition Primary key. - */ - public TableDefinitionImpl( - String schemaName, - String tableName, - LinkedHashMap<String, ColumnDefinition> colMap, - PrimaryKeyDefinition primaryKeyDefinition - ) { - super(tableName); - - this.schemaName = schemaName; - this.colMap = colMap; - - keyCols = primaryKeyDefinition.columns(); - colocationCols = primaryKeyDefinition.colocationColumns(); - } - - /** {@inheritDoc} */ - @Override - public String schemaName() { - return schemaName; - } - - /** {@inheritDoc} */ - @Override - public Set<String> keyColumns() { - return keyCols; - } - - /** {@inheritDoc} */ - @Override - public List<String> colocationColumns() { - return colocationCols; - } - - /** {@inheritDoc} */ - @Override - public List<ColumnDefinition> columns() { - return new ArrayList<>(colMap.values()); - } - - /** - * Check if specified column already exists. - * - * @param name Column name. - * @return {@code True} if column with given name already exists, {@code false} otherwise. - */ - public boolean hasColumn(String name) { - return colMap.containsKey(name); - } - - /** - * Check if specified key column already exists. - * - * @param name Column name. - * @return {@code True} if key column with given name already exists, {@code false} otherwise. - */ - public boolean hasKeyColumn(String name) { - return keyCols.contains(name); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(TableDefinitionImpl.class, this); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/ColumnarIndexDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/ColumnarIndexDefinition.java deleted file mode 100644 index b7ee58fe22..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/ColumnarIndexDefinition.java +++ /dev/null @@ -1,41 +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.testutils.definition.index; - -import java.util.List; - -/** - * Columnar index interface. - */ -public interface ColumnarIndexDefinition extends IndexDefinition { - /** - * Configured index columns. - * - * @return Index columns. - */ - List<? extends IndexColumnDefinition> columns(); - - /** - * Returns all index columns: user defined + implicitly attached. - * - * @return Indexed columns. - */ - default List<? extends IndexColumnDefinition> indexedColumns() { - return columns(); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinition.java deleted file mode 100644 index 55ee4fe411..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinition.java +++ /dev/null @@ -1,29 +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.testutils.definition.index; - -/** - * Hash index descriptor. - */ -public interface HashIndexDefinition extends ColumnarIndexDefinition { - /** {@inheritDoc} */ - @Override - default String type() { - return "HASH"; - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinitionImpl.java deleted file mode 100644 index 1e9223a178..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/HashIndexDefinitionImpl.java +++ /dev/null @@ -1,62 +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.testutils.definition.index; - -import java.util.List; -import java.util.stream.Collectors; -import org.apache.ignite.internal.schema.testutils.definition.AbstractSchemaObject; -import org.apache.ignite.internal.tostring.IgniteToStringInclude; -import org.apache.ignite.internal.tostring.S; - -/** - * Hash index. - */ -public class HashIndexDefinitionImpl extends AbstractSchemaObject implements HashIndexDefinition { - /** Index columns. */ - @IgniteToStringInclude - private final List<IndexColumnDefinition> columns; - - /** - * Constructor. - * - * @param name Index name. - * @param columns Index columns. - */ - public HashIndexDefinitionImpl(String name, List<String> columns) { - super(name); - - this.columns = columns.stream().map(IndexColumnDefinitionImpl::new).collect(Collectors.toUnmodifiableList()); - } - - - /** {@inheritDoc} */ - @SuppressWarnings("AssignmentOrReturnOfFieldWithMutableType") - @Override - public List<IndexColumnDefinition> columns() { - return columns; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(HashIndexDefinitionImpl.class, this, - "type", type(), - "name", name()); - } - -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinition.java deleted file mode 100644 index e94026a6d9..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinition.java +++ /dev/null @@ -1,30 +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.testutils.definition.index; - -/** - * Index column descriptor. - */ -public interface IndexColumnDefinition { - /** - * Returns column name. - * - * @return Column name. - */ - String name(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinitionImpl.java deleted file mode 100644 index a10ddcd78e..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexColumnDefinitionImpl.java +++ /dev/null @@ -1,41 +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.testutils.definition.index; - -import org.apache.ignite.internal.schema.testutils.definition.AbstractSchemaObject; -import org.apache.ignite.internal.tostring.S; - -/** - * Non-ordered index column. - */ -public class IndexColumnDefinitionImpl extends AbstractSchemaObject implements IndexColumnDefinition { - /** - * Constructor. - * - * @param name Column name. - */ - IndexColumnDefinitionImpl(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(IndexColumnDefinitionImpl.class.getSimpleName(), "name", name()); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexDefinition.java deleted file mode 100644 index 7f2880ab17..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/IndexDefinition.java +++ /dev/null @@ -1,52 +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.testutils.definition.index; - -import org.apache.ignite.internal.schema.testutils.definition.SchemaObject; - -/** - * Index base interface. - */ -public interface IndexDefinition extends SchemaObject { - /** - * Returns index name. - * - * @return Index name. - */ - @Override - String name(); - - /** - * Unique index flag. - * - * <p>Limitation: Index MUST have all affinity columns declared explicitly. This requirement allows omitting cluster wide constraint - * checks. - * - * @return Unique flag. - */ - default boolean unique() { - return false; - } - - /** - * Returns index type. - * - * @return Index type. - */ - String type(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/PrimaryKeyDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/PrimaryKeyDefinitionImpl.java deleted file mode 100644 index 2111d251e2..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/PrimaryKeyDefinitionImpl.java +++ /dev/null @@ -1,85 +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.testutils.definition.index; - -import java.util.List; -import java.util.Set; -import org.apache.ignite.internal.schema.testutils.definition.AbstractSchemaObject; -import org.apache.ignite.internal.schema.testutils.definition.PrimaryKeyDefinition; -import org.apache.ignite.internal.tostring.IgniteToStringInclude; -import org.apache.ignite.internal.tostring.S; -import org.apache.ignite.internal.util.CollectionUtils; - -/** - * Primary key index. - */ -public class PrimaryKeyDefinitionImpl extends AbstractSchemaObject implements PrimaryKeyDefinition { - /** Index columns. */ - @IgniteToStringInclude - private final Set<String> columns; - - /** Colocation columns. */ - @IgniteToStringInclude - private final List<String> colocationColumns; - - /** - * Constructor. - * - * @param columns Index columns. - * @param colocationColumns Colocation columns. - */ - public PrimaryKeyDefinitionImpl(Set<String> columns, List<String> colocationColumns) { - super(PrimaryKeyDefinition.PRIMARY_KEY_NAME); - - if (CollectionUtils.nullOrEmpty(columns)) { - throw new IllegalStateException("Primary key column(s) must be configured."); - } - - Set<String> colocationColumnsSet = Set.copyOf(colocationColumns); - - if (!columns.containsAll(colocationColumnsSet)) { - throw new IllegalStateException("Schema definition error: All colocation columns must be part of primary key."); - } else if (colocationColumns.size() != colocationColumnsSet.size()) { - throw new IllegalStateException("Schema definition error: Colocation columns must not be duplicated."); - } - - this.columns = columns; - this.colocationColumns = colocationColumns; - } - - /** {@inheritDoc} */ - @Override - public Set<String> columns() { - return columns; - } - - /** {@inheritDoc} */ - @Override - public List<String> colocationColumns() { - return colocationColumns; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(PrimaryKeyDefinitionImpl.class, this, - "name", name(), - "cols", columns(), - "colocationCols", colocationColumns()); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortOrder.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortOrder.java deleted file mode 100644 index 4c56b08ace..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortOrder.java +++ /dev/null @@ -1,33 +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.testutils.definition.index; - -/** - * Index column sort order. - */ -public enum SortOrder { - /** - * Ascending sort order. - */ - ASC, - - /** - * Descending sort order. - */ - DESC -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinition.java deleted file mode 100644 index 785a65362e..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinition.java +++ /dev/null @@ -1,30 +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.testutils.definition.index; - -/** - * Sorted index column. - */ -public interface SortedIndexColumnDefinition extends IndexColumnDefinition { - /** - * Returns column sort order. - * - * @return Column sort order. - */ - SortOrder sortOrder(); -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinitionImpl.java deleted file mode 100644 index 67acd4b7c0..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexColumnDefinitionImpl.java +++ /dev/null @@ -1,60 +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.testutils.definition.index; - -import org.apache.ignite.internal.tostring.S; - -/** - * Ordered index column. - */ -public class SortedIndexColumnDefinitionImpl implements SortedIndexColumnDefinition { - /** Schema object name. */ - private final String name; - - /** Sort order. */ - private final SortOrder sortOrder; - - /** - * Constructor. - * - * @param name Column name. - * @param sortOrder Sort order flag. - */ - public SortedIndexColumnDefinitionImpl(String name, SortOrder sortOrder) { - this.name = name; - this.sortOrder = sortOrder; - } - - /** {@inheritDoc} */ - @Override - public String name() { - return name; - } - - /** {@inheritDoc} */ - @Override - public SortOrder sortOrder() { - return sortOrder; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(SortedIndexColumnDefinitionImpl.class, this); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinition.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinition.java deleted file mode 100644 index fc2ef4dad3..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinition.java +++ /dev/null @@ -1,39 +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.testutils.definition.index; - -import java.util.List; - -/** - * Sorted index descriptor. - */ -public interface SortedIndexDefinition extends ColumnarIndexDefinition { - /** {@inheritDoc} */ - @Override - List<SortedIndexColumnDefinition> columns(); - - /** {@inheritDoc} */ - @Override - List<SortedIndexColumnDefinition> indexedColumns(); - - /** {@inheritDoc} */ - @Override - default String type() { - return "SORTED"; - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinitionImpl.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinitionImpl.java deleted file mode 100644 index 9562a8cfd1..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/SortedIndexDefinitionImpl.java +++ /dev/null @@ -1,76 +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.testutils.definition.index; - -import java.util.Collections; -import java.util.List; -import org.apache.ignite.internal.schema.testutils.definition.AbstractSchemaObject; -import org.apache.ignite.internal.tostring.IgniteToStringInclude; -import org.apache.ignite.internal.tostring.S; - -/** - * Sorted index. - */ -public class SortedIndexDefinitionImpl extends AbstractSchemaObject implements SortedIndexDefinition { - /** Columns. */ - @IgniteToStringInclude - private final List<SortedIndexColumnDefinition> cols; - - /** Unique flag. */ - private final boolean unique; - - /** - * Constructor. - * - * @param name Index name. - * @param cols Index columns. - * @param unique Unique flag. - */ - public SortedIndexDefinitionImpl(String name, List<SortedIndexColumnDefinition> cols, boolean unique) { - super(name); - - this.cols = Collections.unmodifiableList(cols); - this.unique = unique; - } - - /** {@inheritDoc} */ - @Override - public boolean unique() { - return unique; - } - - /** {@inheritDoc} */ - @Override - public List<SortedIndexColumnDefinition> columns() { - return cols; - } - - /** {@inheritDoc} */ - @Override - public List<SortedIndexColumnDefinition> indexedColumns() { - return cols; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return S.toString(SortedIndexDefinition.class, this, - "type", type(), - "name", name()); - } -} diff --git a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/package-info.java b/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/package-info.java deleted file mode 100644 index 5c5f34a90f..0000000000 --- a/modules/schema/src/testFixtures/java/org/apache/ignite/internal/schema/testutils/definition/index/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. - */ - -/** - * Contains index definition interfaces. - */ - -package org.apache.ignite.internal.schema.testutils.definition.index; \ No newline at end of file