ibessonov commented on a change in pull request #739: URL: https://github.com/apache/ignite-3/pull/739#discussion_r840402387
########## File path: modules/storage-api/src/test/java/org/apache/ignite/internal/storage/AbstractSortedIndexMvStorageTest.java ########## @@ -0,0 +1,238 @@ +/* + * 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.storage; + +import static org.apache.ignite.internal.storage.index.SortedIndexMvStorage.BACKWARDS; +import static org.apache.ignite.internal.storage.index.SortedIndexMvStorage.FORWARD; +import static org.apache.ignite.internal.storage.index.SortedIndexMvStorage.GREATER_OR_EQUAL; +import static org.apache.ignite.internal.storage.index.SortedIndexMvStorage.LESS_OR_EQUAL; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; +import org.apache.ignite.configuration.schemas.table.ColumnChange; +import org.apache.ignite.configuration.schemas.table.SortedIndexChange; +import org.apache.ignite.configuration.schemas.table.SortedIndexConfigurationSchema; +import org.apache.ignite.configuration.schemas.table.TableConfiguration; +import org.apache.ignite.configuration.schemas.table.TableView; +import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension; +import org.apache.ignite.internal.configuration.testframework.InjectConfiguration; +import org.apache.ignite.internal.schema.BinaryRow; +import org.apache.ignite.internal.schema.marshaller.MarshallerException; +import org.apache.ignite.internal.schema.row.Row; +import org.apache.ignite.internal.storage.index.IndexRowPrefix; +import org.apache.ignite.internal.storage.index.SortedIndexMvStorage; +import org.apache.ignite.internal.storage.index.SortedIndexMvStorage.IndexRowEx; +import org.apache.ignite.internal.tx.Timestamp; +import org.apache.ignite.internal.util.Cursor; +import org.apache.ignite.lang.IgniteException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Base test for MV index storages. + */ +@ExtendWith(ConfigurationExtension.class) +public abstract class AbstractSortedIndexMvStorageTest extends BaseMvStoragesTest { + protected static final String INDEX1 = "asc_asc"; + protected static final String INDEX2 = "asc_desc"; + + protected TableConfiguration tableCfg; + + @BeforeEach + void setUp(@InjectConfiguration(polymorphicExtensions = SortedIndexConfigurationSchema.class) TableConfiguration tableCfg) { + tableCfg.change(tableChange -> tableChange + .changePartitions(1) + .changePrimaryKey(pk -> pk.changeColumns("intKey", "strKey")) + .changeColumns(columns -> columns + .create("intKey", column("intKey", "INT32")) + .create("strKey", column("strKey", "STRING")) + .create("intVal", column("intVal", "INT32")) + .create("strVal", column("strVal", "STRING")) + ) + .changeIndices(indexes -> indexes + .create(INDEX1, idx -> idx.convert(SortedIndexChange.class).changeColumns(idxColumns -> idxColumns + .create("strVal", c -> c.changeName("strVal").changeAsc(true)) + .create("intVal", c -> c.changeName("intVal").changeAsc(true)) + )) + .create(INDEX2, idx -> idx.convert(SortedIndexChange.class).changeColumns(idxColumns -> idxColumns + .create("strVal", c -> c.changeName("strVal").changeAsc(true)) + .create("intVal", c -> c.changeName("intVal").changeAsc(false)) + )) + ) + ).join(); + + this.tableCfg = tableCfg; + } + + private static Consumer<ColumnChange> column(String name, String typeName) { + return c -> c.changeName(name).changeNullable(false).changeType(type -> type.changeType(typeName)); + } + + /** + * Creates a storage instance for testing. + */ + protected abstract MvPartitionStorage partitionStorage(); + + /** + * Creates a storage instanc efor testing. + */ + protected abstract SortedIndexMvStorage createIndexStorage(String name, TableView tableCfg); + + @Test + public void testEmpty() throws Exception { + SortedIndexMvStorage index1 = createIndexStorage(INDEX1, tableCfg.value()); + SortedIndexMvStorage index2 = createIndexStorage(INDEX2, tableCfg.value()); Review comment: They have different orderings, just to be more confident -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
