You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tk...@apache.org on 2024/04/12 08:37:40 UTC
(ignite-3) branch main updated: IGNITE-22021 Set null into IndexStorage#getNextRowIdToBuild for the primary index (#3589)
This is an automated email from the ASF dual-hosted git repository.
tkalkirill 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 058e5c9c4d IGNITE-22021 Set null into IndexStorage#getNextRowIdToBuild for the primary index (#3589)
058e5c9c4d is described below
commit 058e5c9c4d49849275858cf5507169a53f777e5b
Author: Kirill Tkalenko <tk...@yandex.ru>
AuthorDate: Fri Apr 12 11:37:34 2024 +0300
IGNITE-22021 Set null into IndexStorage#getNextRowIdToBuild for the primary index (#3589)
---
.../storage/index/StorageHashIndexDescriptor.java | 17 +-
.../storage/index/StorageIndexDescriptor.java | 3 +
.../index/StorageSortedIndexDescriptor.java | 17 +-
.../storage/index/StorageIndexDescriptorTest.java | 94 +++++++++++
.../storage/AbstractMvTableStorageTest.java | 171 +++++++++++++--------
.../storage/engine/AbstractStorageEngineTest.java | 10 +-
.../index/AbstractHashIndexStorageTest.java | 39 +++--
.../storage/index/AbstractIndexStorageTest.java | 65 +++++++-
.../index/AbstractSortedIndexStorageTest.java | 63 +++++---
.../index/impl/AbstractTestIndexStorage.java | 9 +-
.../storage/index/impl/TestHashIndexStorage.java | 2 +-
.../storage/index/impl/TestSortedIndexStorage.java | 2 +-
.../storage/pagememory/mv/IndexStorageFactory.java | 5 +-
.../storage/rocksdb/RocksDbMetaStorage.java | 5 +-
.../rocksdb/index/AbstractRocksDbIndexStorage.java | 9 +-
.../rocksdb/index/RocksDbHashIndexStorage.java | 2 +-
.../rocksdb/index/RocksDbSortedIndexStorage.java | 2 +-
.../internal/table/distributed/IndexBaseTest.java | 45 ++++--
.../table/distributed/SortedIndexLockerTest.java | 7 +-
.../table/distributed/StorageCleanupTest.java | 45 ++++--
.../distributed/StorageUpdateHandlerTest.java | 45 ++++--
.../raft/PartitionCommandListenerTest.java | 6 +-
.../PartitionReplicaListenerIndexLockingTest.java | 8 +-
.../replication/PartitionReplicaListenerTest.java | 27 +++-
24 files changed, 516 insertions(+), 182 deletions(-)
diff --git a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageHashIndexDescriptor.java b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageHashIndexDescriptor.java
index 75254329d9..c3c1596918 100644
--- a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageHashIndexDescriptor.java
+++ b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageHashIndexDescriptor.java
@@ -81,6 +81,8 @@ public class StorageHashIndexDescriptor implements StorageIndexDescriptor {
private final List<StorageHashIndexColumnDescriptor> columns;
+ private final boolean pk;
+
/**
* Constructor.
*
@@ -88,7 +90,7 @@ public class StorageHashIndexDescriptor implements StorageIndexDescriptor {
* @param index Catalog index descriptor.
*/
public StorageHashIndexDescriptor(CatalogTableDescriptor table, CatalogHashIndexDescriptor index) {
- this(index.id(), extractIndexColumnsConfiguration(table, index));
+ this(index.id(), extractIndexColumnsConfiguration(table, index), table.primaryKeyIndexId() == index.id());
}
/**
@@ -96,10 +98,12 @@ public class StorageHashIndexDescriptor implements StorageIndexDescriptor {
*
* @param indexId Index id.
* @param columns Columns descriptors.
+ * @param pk Primary index flag.
*/
- public StorageHashIndexDescriptor(int indexId, List<StorageHashIndexColumnDescriptor> columns) {
+ public StorageHashIndexDescriptor(int indexId, List<StorageHashIndexColumnDescriptor> columns, boolean pk) {
this.id = indexId;
this.columns = columns;
+ this.pk = pk;
}
@Override
@@ -112,17 +116,22 @@ public class StorageHashIndexDescriptor implements StorageIndexDescriptor {
return columns;
}
+ @Override
+ public boolean isPk() {
+ return pk;
+ }
+
private static List<StorageHashIndexColumnDescriptor> extractIndexColumnsConfiguration(
CatalogTableDescriptor table,
CatalogHashIndexDescriptor index
) {
- assert table.id() == index.tableId() : "tableId=" + table.id() + ", indexTableId=" + index.tableId();
+ assert table.id() == index.tableId() : "indexId=" + index.id() + ", tableId=" + table.id() + ", indexTableId=" + index.tableId();
return index.columns().stream()
.map(columnName -> {
CatalogTableColumnDescriptor column = table.column(columnName);
- assert column != null : columnName;
+ assert column != null : "indexId=" + index.id() + ", columnName=" + columnName;
return new StorageHashIndexColumnDescriptor(column.name(), getNativeType(column), column.nullable());
})
diff --git a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptor.java b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptor.java
index 18ecabfc3e..24197b3f1a 100644
--- a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptor.java
+++ b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptor.java
@@ -60,6 +60,9 @@ public interface StorageIndexDescriptor {
*/
List<? extends StorageColumnDescriptor> columns();
+ /** Returns {@code true} for the primary index. */
+ boolean isPk();
+
/**
* Creates an index description based on the catalog descriptors.
*
diff --git a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageSortedIndexDescriptor.java b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageSortedIndexDescriptor.java
index 6c30c96779..4ed6ebf97e 100644
--- a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageSortedIndexDescriptor.java
+++ b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/index/StorageSortedIndexDescriptor.java
@@ -99,6 +99,8 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
private final BinaryTupleSchema binaryTupleSchema;
+ private final boolean pk;
+
/**
* Constructor.
*
@@ -106,7 +108,7 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
* @param index Catalog index descriptor.
*/
public StorageSortedIndexDescriptor(CatalogTableDescriptor table, CatalogSortedIndexDescriptor index) {
- this(index.id(), extractIndexColumnsConfiguration(table, index));
+ this(index.id(), extractIndexColumnsConfiguration(table, index), table.primaryKeyIndexId() == index.id());
}
/**
@@ -114,11 +116,13 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
*
* @param indexId Index ID.
* @param columnDescriptors Column descriptors.
+ * @param pk Primary index flag.
*/
- public StorageSortedIndexDescriptor(int indexId, List<StorageSortedIndexColumnDescriptor> columnDescriptors) {
+ public StorageSortedIndexDescriptor(int indexId, List<StorageSortedIndexColumnDescriptor> columnDescriptors, boolean pk) {
this.id = indexId;
this.columns = List.copyOf(columnDescriptors);
this.binaryTupleSchema = createSchema(columns);
+ this.pk = pk;
}
private static BinaryTupleSchema createSchema(List<StorageSortedIndexColumnDescriptor> columns) {
@@ -139,6 +143,11 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
return columns;
}
+ @Override
+ public boolean isPk() {
+ return pk;
+ }
+
/**
* Returns a {@code BinaryTupleSchema} that corresponds to the index configuration.
*/
@@ -150,7 +159,7 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
CatalogTableDescriptor table,
CatalogSortedIndexDescriptor index
) {
- assert table.id() == index.tableId() : "tableId=" + table.id() + ", indexTableId=" + index.tableId();
+ assert table.id() == index.tableId() : "indexId=" + index.id() + ", tableId=" + table.id() + ", indexTableId=" + index.tableId();
return index.columns().stream()
.map(columnDescriptor -> {
@@ -158,7 +167,7 @@ public class StorageSortedIndexDescriptor implements StorageIndexDescriptor {
CatalogTableColumnDescriptor column = table.column(columnName);
- assert column != null : columnName;
+ assert column != null : "indexId=" + index.id() + ", columnName=" + columnName;
CatalogColumnCollation collation = columnDescriptor.collation();
diff --git a/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptorTest.java b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptorTest.java
new file mode 100644
index 0000000000..ca2913f8fa
--- /dev/null
+++ b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/index/StorageIndexDescriptorTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.index;
+
+import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static org.apache.ignite.internal.catalog.descriptors.CatalogColumnCollation.ASC_NULLS_FIRST;
+import static org.apache.ignite.internal.catalog.descriptors.CatalogIndexStatus.AVAILABLE;
+import static org.apache.ignite.sql.ColumnType.INT32;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.internal.catalog.descriptors.CatalogHashIndexDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogIndexColumnDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogSortedIndexDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableColumnDescriptor;
+import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+/** For {@link StorageHashIndexDescriptor} testing. */
+public class StorageIndexDescriptorTest {
+ private static final String COLUMN_NAME = "INT_VAL";
+
+ private final AtomicInteger nextId = new AtomicInteger();
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testIsPk(boolean pk) {
+ CatalogTableDescriptor tableDescriptor = createTableDescriptor();
+
+ int tableId = tableDescriptor.id();
+ int indexId = pk ? tableDescriptor.primaryKeyIndexId() : nextId.getAndIncrement();
+
+ CatalogHashIndexDescriptor pkHashIndexDescriptor = createHashIndexDescriptor(indexId, tableId);
+ CatalogSortedIndexDescriptor pkSortedIndexDescriptor = createSortedIndexDescriptor(indexId, tableId);
+
+ assertEquals(pk, StorageIndexDescriptor.create(tableDescriptor, pkHashIndexDescriptor).isPk());
+ assertEquals(pk, StorageIndexDescriptor.create(tableDescriptor, pkSortedIndexDescriptor).isPk());
+ }
+
+ private CatalogTableDescriptor createTableDescriptor() {
+ return new CatalogTableDescriptor(
+ nextId.getAndIncrement(),
+ nextId.getAndIncrement(),
+ nextId.getAndIncrement(),
+ "TABLE_NAME",
+ nextId.getAndIncrement(),
+ List.of(new CatalogTableColumnDescriptor(COLUMN_NAME, INT32, false, 0, 0, 0, null)),
+ List.of(COLUMN_NAME),
+ List.of(COLUMN_NAME),
+ DEFAULT_STORAGE_PROFILE
+ );
+ }
+
+ private static CatalogHashIndexDescriptor createHashIndexDescriptor(int indexId, int tableId) {
+ return new CatalogHashIndexDescriptor(
+ indexId,
+ "INDEX_NAME_" + indexId,
+ tableId,
+ false,
+ AVAILABLE,
+ 1,
+ List.of(COLUMN_NAME)
+ );
+ }
+
+ private static CatalogSortedIndexDescriptor createSortedIndexDescriptor(int indexId, int tableId) {
+ return new CatalogSortedIndexDescriptor(
+ indexId,
+ "INDEX_NAME_" + indexId,
+ tableId,
+ false,
+ AVAILABLE,
+ 1,
+ List.of(new CatalogIndexColumnDescriptor(COLUMN_NAME, ASC_NULLS_FIRST))
+ );
+ }
+}
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
index 0cf07b6834..a443ba8740 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.storage;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexName;
import static org.apache.ignite.internal.catalog.descriptors.CatalogColumnCollation.ASC_NULLS_LAST;
import static org.apache.ignite.internal.catalog.descriptors.CatalogIndexStatus.AVAILABLE;
import static org.apache.ignite.internal.schema.BinaryRowMatcher.equalToRow;
@@ -99,7 +100,9 @@ import org.junit.jupiter.params.provider.ValueSource;
*/
@SuppressWarnings("JUnitTestMethodInProductSource")
public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
- private static final String TABLE_NAME = "foo";
+ private static final String TABLE_NAME = "FOO";
+
+ private static final String PK_INDEX_NAME = pkIndexName(TABLE_NAME);
private static final String SORTED_INDEX_NAME = "SORTED_IDX";
@@ -123,6 +126,8 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
protected StorageHashIndexDescriptor hashIdx;
+ protected StorageIndexDescriptor pkIdx;
+
private final CatalogService catalogService = mock(CatalogService.class);
protected final StorageIndexDescriptorSupplier indexDescriptorSupplier = new StorageIndexDescriptorSupplier() {
@@ -800,43 +805,22 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
assertThat(tableStorage.destroyPartition(PARTITION_ID), willCompleteSuccessfully());
}
- @Test
- void testNextRowIdToBuild() {
- MvPartitionStorage mvPartitionStorage = getOrCreateMvPartition(PARTITION_ID);
-
- IndexStorage hashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
- IndexStorage sortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
-
- assertThat(hashIndexStorage.getNextRowIdToBuild(), equalTo(INITIAL_ROW_ID_TO_BUILD));
- assertThat(sortedIndexStorage.getNextRowIdToBuild(), equalTo(INITIAL_ROW_ID_TO_BUILD));
-
- RowId rowId0 = new RowId(PARTITION_ID);
- RowId rowId1 = new RowId(PARTITION_ID);
-
- mvPartitionStorage.runConsistently(locker -> {
- hashIndexStorage.setNextRowIdToBuild(rowId0);
- sortedIndexStorage.setNextRowIdToBuild(rowId1);
-
- return null;
- });
-
- assertThat(hashIndexStorage.getNextRowIdToBuild(), equalTo(rowId0));
- assertThat(sortedIndexStorage.getNextRowIdToBuild(), equalTo(rowId1));
- }
-
@Test
void testNextRowIdToBuildAfterRestart() throws Exception {
MvPartitionStorage mvPartitionStorage = getOrCreateMvPartition(PARTITION_ID);
IndexStorage hashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
IndexStorage sortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
+ IndexStorage pkIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, pkIdx);
RowId rowId0 = new RowId(PARTITION_ID);
RowId rowId1 = new RowId(PARTITION_ID);
+ RowId rowId2 = new RowId(PARTITION_ID);
mvPartitionStorage.runConsistently(locker -> {
hashIndexStorage.setNextRowIdToBuild(rowId0);
sortedIndexStorage.setNextRowIdToBuild(rowId1);
+ pkIndexStorage.setNextRowIdToBuild(rowId2);
return null;
});
@@ -852,61 +836,52 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
IndexStorage hashIndexStorageRestarted = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
IndexStorage sortedIndexStorageRestarted = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
+ IndexStorage pkIndexStorageRestarted = tableStorage.getOrCreateIndex(PARTITION_ID, pkIdx);
if (tableStorage.isVolatile()) {
assertThat(hashIndexStorageRestarted.getNextRowIdToBuild(), equalTo(INITIAL_ROW_ID_TO_BUILD));
assertThat(sortedIndexStorageRestarted.getNextRowIdToBuild(), equalTo(INITIAL_ROW_ID_TO_BUILD));
+ assertThat(pkIndexStorageRestarted.getNextRowIdToBuild(), nullValue());
} else {
assertThat(hashIndexStorageRestarted.getNextRowIdToBuild(), equalTo(rowId0));
assertThat(sortedIndexStorageRestarted.getNextRowIdToBuild(), equalTo(rowId1));
+ assertThat(pkIndexStorageRestarted.getNextRowIdToBuild(), equalTo(rowId2));
}
}
@Test
- void testNextRowIdToBuildAfterRebalance() {
- MvPartitionStorage mvPartitionStorage = getOrCreateMvPartition(PARTITION_ID);
-
- IndexStorage hashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
- IndexStorage sortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
-
- RowId rowId0 = new RowId(PARTITION_ID);
- RowId rowId1 = new RowId(PARTITION_ID);
-
- mvPartitionStorage.runConsistently(locker -> {
- hashIndexStorage.setNextRowIdToBuild(rowId0);
- sortedIndexStorage.setNextRowIdToBuild(rowId1);
-
- return null;
+ void testNextRowIdToBuildAfterRebalance() throws Exception {
+ testNextRowIdToBuildAfterOperation(() -> {
+ assertThat(tableStorage.startRebalancePartition(PARTITION_ID), willCompleteSuccessfully());
+ assertThat(tableStorage.finishRebalancePartition(PARTITION_ID, 100, 100, BYTE_EMPTY_ARRAY), willCompleteSuccessfully());
});
+ }
- assertThat(hashIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId0)));
- assertThat(sortedIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId1)));
-
- assertThat(mvPartitionStorage.flush(), willCompleteSuccessfully());
+ @Test
+ void testNextRowIdToBuildAfterClearPartition() throws Exception {
+ testNextRowIdToBuildAfterOperation(() -> assertThat(tableStorage.clearPartition(PARTITION_ID), willCompleteSuccessfully()));
+ }
- // We expect that nextRowIdToBuild will be reverted to its default value after the rebalance.
- assertThat(tableStorage.startRebalancePartition(PARTITION_ID), willCompleteSuccessfully());
- assertThat(tableStorage.finishRebalancePartition(PARTITION_ID, 100, 100, BYTE_EMPTY_ARRAY), willCompleteSuccessfully());
+ @Test
+ void testNextRowIdToBuildAfterDestroyPartition() throws Exception {
+ testNextRowIdToBuildAfterOperation(() -> {
+ assertThat(tableStorage.destroyPartition(PARTITION_ID), willCompleteSuccessfully());
- assertThat(hashIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
- assertThat(sortedIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
+ getOrCreateMvPartition(PARTITION_ID);
+ });
+ }
- IndexStorage recreatedHashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
- IndexStorage recreatedSortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
+ @Test
+ void testNextRowIdToBuildAfterDestroyTable() throws Exception {
+ testNextRowIdToBuildAfterOperation(() -> {
+ assertThat(tableStorage.destroy(), willCompleteSuccessfully());
- assertThat(recreatedHashIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
- assertThat(recreatedSortedIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
+ tableStorage.close();
- // Check that rowId can be set successfully.
- mvPartitionStorage.runConsistently(locker -> {
- recreatedHashIndexStorage.setNextRowIdToBuild(rowId0);
- recreatedSortedIndexStorage.setNextRowIdToBuild(rowId1);
+ tableStorage = createMvTableStorage();
- return null;
+ getOrCreateMvPartition(PARTITION_ID);
});
-
- assertThat(recreatedHashIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId0)));
- assertThat(recreatedSortedIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId1)));
}
@Test
@@ -953,20 +928,23 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
int zoneId = id++;
int sortedIndexId = id++;
int hashIndexId = id++;
+ int pkIndexId = id++;
+
+ String pkColumnName = "INTKEY";
CatalogTableDescriptor tableDescriptor = new CatalogTableDescriptor(
tableId,
schemaId,
- hashIndexId,
+ pkIndexId,
TABLE_NAME,
zoneId,
List.of(
- CatalogUtils.fromParams(ColumnParams.builder().name("INTKEY").type(INT32).build()),
+ CatalogUtils.fromParams(ColumnParams.builder().name(pkColumnName).type(INT32).build()),
CatalogUtils.fromParams(ColumnParams.builder().name("STRKEY").length(100).type(STRING).build()),
CatalogUtils.fromParams(ColumnParams.builder().name("INTVAL").type(INT32).build()),
CatalogUtils.fromParams(ColumnParams.builder().name("STRVAL").length(100).type(STRING).build())
),
- List.of("INTKEY"),
+ List.of(pkColumnName),
null,
DEFAULT_STORAGE_PROFILE
);
@@ -991,13 +969,25 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
List.of("STRKEY")
);
+ CatalogIndexDescriptor pkIndex = new CatalogHashIndexDescriptor(
+ pkIndexId,
+ PK_INDEX_NAME,
+ tableId,
+ true,
+ AVAILABLE,
+ catalogService.latestCatalogVersion(),
+ List.of(pkColumnName)
+ );
+
when(catalogService.table(eq(TABLE_NAME), anyLong())).thenReturn(tableDescriptor);
when(catalogService.aliveIndex(eq(SORTED_INDEX_NAME), anyLong())).thenReturn(sortedIndex);
when(catalogService.aliveIndex(eq(HASH_INDEX_NAME), anyLong())).thenReturn(hashIndex);
+ when(catalogService.aliveIndex(eq(PK_INDEX_NAME), anyLong())).thenReturn(pkIndex);
when(catalogService.table(eq(tableId), anyInt())).thenReturn(tableDescriptor);
when(catalogService.index(eq(sortedIndexId), anyInt())).thenReturn(sortedIndex);
when(catalogService.index(eq(hashIndexId), anyInt())).thenReturn(hashIndex);
+ when(catalogService.index(eq(pkIndexId), anyInt())).thenReturn(pkIndex);
}
private static <T> List<T> getAll(Cursor<T> cursor) {
@@ -1147,12 +1137,15 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
CatalogIndexDescriptor catalogSortedIndexDescriptor = catalogService.aliveIndex(SORTED_INDEX_NAME, clock.nowLong());
CatalogIndexDescriptor catalogHashIndexDescriptor = catalogService.aliveIndex(HASH_INDEX_NAME, clock.nowLong());
+ CatalogIndexDescriptor catalogPkIndexDescriptor = catalogService.aliveIndex(PK_INDEX_NAME, clock.nowLong());
assertNotNull(catalogSortedIndexDescriptor);
assertNotNull(catalogHashIndexDescriptor);
+ assertNotNull(catalogPkIndexDescriptor);
sortedIdx = new StorageSortedIndexDescriptor(catalogTableDescriptor, (CatalogSortedIndexDescriptor) catalogSortedIndexDescriptor);
hashIdx = new StorageHashIndexDescriptor(catalogTableDescriptor, (CatalogHashIndexDescriptor) catalogHashIndexDescriptor);
+ pkIdx = StorageIndexDescriptor.create(catalogTableDescriptor, catalogPkIndexDescriptor);
}
private static void checkHashIndexStorageMethodsAfterStartRebalance(HashIndexStorage storage) {
@@ -1411,4 +1404,56 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
protected MvPartitionStorage getOrCreateMvPartition(int partitionId) {
return getOrCreateMvPartition(tableStorage, partitionId);
}
+
+ void testNextRowIdToBuildAfterOperation(Operation operation) throws Exception {
+ MvPartitionStorage mvPartitionStorage = getOrCreateMvPartition(PARTITION_ID);
+
+ IndexStorage hashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
+ IndexStorage sortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
+ IndexStorage pkIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, pkIdx);
+
+ RowId rowId0 = new RowId(PARTITION_ID);
+ RowId rowId1 = new RowId(PARTITION_ID);
+ RowId rowId2 = new RowId(PARTITION_ID);
+
+ mvPartitionStorage.runConsistently(locker -> {
+ hashIndexStorage.setNextRowIdToBuild(rowId0);
+ sortedIndexStorage.setNextRowIdToBuild(rowId1);
+ pkIndexStorage.setNextRowIdToBuild(rowId2);
+
+ return null;
+ });
+
+ assertThat(mvPartitionStorage.flush(), willCompleteSuccessfully());
+
+ // We expect that nextRowIdToBuild will be reverted to its default value after the operation.
+ operation.doOperation();
+
+ mvPartitionStorage = getOrCreateMvPartition(PARTITION_ID);
+
+ IndexStorage recreatedHashIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, hashIdx);
+ IndexStorage recreatedSortedIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, sortedIdx);
+ IndexStorage recreatedPkIndexStorage = tableStorage.getOrCreateIndex(PARTITION_ID, pkIdx);
+
+ assertThat(recreatedHashIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
+ assertThat(recreatedSortedIndexStorage.getNextRowIdToBuild(), is(equalTo(INITIAL_ROW_ID_TO_BUILD)));
+ assertThat(recreatedPkIndexStorage.getNextRowIdToBuild(), nullValue());
+
+ // Check that rowId can be set successfully.
+ mvPartitionStorage.runConsistently(locker -> {
+ recreatedHashIndexStorage.setNextRowIdToBuild(rowId0);
+ recreatedSortedIndexStorage.setNextRowIdToBuild(rowId1);
+ recreatedPkIndexStorage.setNextRowIdToBuild(rowId2);
+
+ return null;
+ });
+
+ assertThat(recreatedHashIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId0)));
+ assertThat(recreatedSortedIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId1)));
+ assertThat(recreatedPkIndexStorage.getNextRowIdToBuild(), is(equalTo(rowId2)));
+ }
+
+ private interface Operation {
+ void doOperation() throws Exception;
+ }
}
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java
index 1792b3948d..2488c3dcf2 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/engine/AbstractStorageEngineTest.java
@@ -171,8 +171,14 @@ public abstract class AbstractStorageEngineTest extends BaseMvStoragesTest {
int sortedIndexId = numTables + i * 2;
int hashIndexId = sortedIndexId + 1;
- indexDescriptorMap.put(sortedIndexId, new StorageSortedIndexDescriptor(sortedIndexId, List.of(sortedIndexColumnDescriptor)));
- indexDescriptorMap.put(hashIndexId, new StorageHashIndexDescriptor(hashIndexId, List.of(hashIndexColumnDescriptor)));
+ indexDescriptorMap.put(
+ sortedIndexId,
+ new StorageSortedIndexDescriptor(sortedIndexId, List.of(sortedIndexColumnDescriptor), false)
+ );
+ indexDescriptorMap.put(
+ hashIndexId,
+ new StorageHashIndexDescriptor(hashIndexId, List.of(hashIndexColumnDescriptor), false)
+ );
}
when(indexDescriptorSupplier.get(anyInt()))
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java
index 6320b14261..cc2d8d5597 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractHashIndexStorageTest.java
@@ -25,10 +25,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.sameInstance;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
@@ -45,24 +41,16 @@ import org.junit.jupiter.api.Test;
public abstract class AbstractHashIndexStorageTest extends AbstractIndexStorageTest<HashIndexStorage, StorageHashIndexDescriptor> {
@Override
protected HashIndexStorage createIndexStorage(String name, ColumnType... columnTypes) {
- CatalogTableDescriptor catalogTableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong());
+ CatalogTableDescriptor tableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong());
- CatalogHashIndexDescriptor catalogHashIndexDescriptor = new CatalogHashIndexDescriptor(
- catalogId.getAndIncrement(),
- name,
- catalogTableDescriptor.id(),
- false,
- AVAILABLE,
- catalogService.latestCatalogVersion(),
- Stream.of(columnTypes).map(AbstractIndexStorageTest::columnName).collect(toList())
- );
+ int tableId = tableDescriptor.id();
+ int indexId = catalogId.getAndIncrement();
- when(catalogService.aliveIndex(eq(name), anyLong())).thenReturn(catalogHashIndexDescriptor);
- when(catalogService.index(eq(catalogHashIndexDescriptor.id()), anyInt())).thenReturn(catalogHashIndexDescriptor);
+ CatalogHashIndexDescriptor indexDescriptor = createCatalogIndexDescriptor(tableId, indexId, name, columnTypes);
return tableStorage.getOrCreateHashIndex(
TEST_PARTITION,
- new StorageHashIndexDescriptor(catalogTableDescriptor, catalogHashIndexDescriptor)
+ new StorageHashIndexDescriptor(tableDescriptor, indexDescriptor)
);
}
@@ -71,6 +59,23 @@ public abstract class AbstractHashIndexStorageTest extends AbstractIndexStorageT
return index.indexDescriptor();
}
+ @Override
+ CatalogHashIndexDescriptor createCatalogIndexDescriptor(int tableId, int indexId, String indexName, ColumnType... columnTypes) {
+ var indexDescriptor = new CatalogHashIndexDescriptor(
+ indexId,
+ indexName,
+ tableId,
+ false,
+ AVAILABLE,
+ catalogService.latestCatalogVersion(),
+ Stream.of(columnTypes).map(AbstractIndexStorageTest::columnName).collect(toList())
+ );
+
+ addToCatalog(indexDescriptor);
+
+ return indexDescriptor;
+ }
+
@Test
public void testDestroy() {
HashIndexStorage index = createIndexStorage(INDEX_NAME, ColumnType.INT32, ColumnType.STRING);
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java
index 98721436fe..a808c99036 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractIndexStorageTest.java
@@ -20,7 +20,9 @@ package org.apache.ignite.internal.storage.index;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.apache.ignite.internal.catalog.CatalogService.DEFAULT_STORAGE_PROFILE;
+import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexName;
import static org.apache.ignite.internal.storage.BaseMvStoragesTest.getOrCreateMvPartition;
+import static org.apache.ignite.internal.storage.util.StorageUtils.initialRowIdToBuild;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -33,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -50,6 +53,7 @@ import java.util.stream.Stream;
import org.apache.ignite.internal.catalog.CatalogService;
import org.apache.ignite.internal.catalog.commands.CatalogUtils;
import org.apache.ignite.internal.catalog.commands.ColumnParams;
+import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor;
import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor;
import org.apache.ignite.internal.hlc.HybridClock;
import org.apache.ignite.internal.hlc.HybridClockImpl;
@@ -64,6 +68,8 @@ import org.apache.ignite.sql.ColumnType;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
/**
* Base class for index storage tests. Covers common methods, such as {@link IndexStorage#get(BinaryTuple)} or
@@ -79,9 +85,11 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
protected static final int TEST_PARTITION = 12;
- protected static final String INDEX_NAME = "TEST_IDX";
+ protected static final String TABLE_NAME = "FOO";
+
+ protected static final String PK_INDEX_NAME = pkIndexName(TABLE_NAME);
- protected static final String TABLE_NAME = "foo";
+ protected static final String INDEX_NAME = "TEST_IDX";
private static List<ColumnParams> allTypesColumnParams() {
return List.of(
@@ -139,23 +147,24 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
this.tableStorage = tableStorage;
this.partitionStorage = getOrCreateMvPartition(tableStorage, TEST_PARTITION);
- createTestTable(catalogService, catalogId);
+ createTestTable();
}
/**
* Configures a test table with columns of all supported types.
*/
- private static void createTestTable(CatalogService catalogService, AtomicInteger catalogId) {
+ private void createTestTable() {
ColumnParams pkColumn = ColumnParams.builder().name("pk").type(ColumnType.INT32).nullable(false).build();
int schemaId = catalogId.getAndIncrement();
int tableId = catalogId.getAndIncrement();
int zoneId = catalogId.getAndIncrement();
+ int pkIndexId = catalogId.getAndIncrement();
CatalogTableDescriptor tableDescriptor = new CatalogTableDescriptor(
tableId,
schemaId,
- 1,
+ pkIndexId,
TABLE_NAME,
zoneId,
Stream.concat(Stream.of(pkColumn), ALL_TYPES_COLUMN_PARAMS.stream()).map(CatalogUtils::fromParams).collect(toList()),
@@ -166,6 +175,8 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
when(catalogService.table(eq(TABLE_NAME), anyLong())).thenReturn(tableDescriptor);
when(catalogService.table(eq(tableId), anyInt())).thenReturn(tableDescriptor);
+
+ createCatalogIndexDescriptor(tableId, pkIndexId, PK_INDEX_NAME, pkColumn.type());
}
/**
@@ -180,6 +191,8 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
*/
protected abstract D indexDescriptor(S index);
+ abstract CatalogIndexDescriptor createCatalogIndexDescriptor(int tableId, int indexId, String indexName, ColumnType... columnTypes);
+
/**
* Tests the {@link IndexStorage#get} method.
*/
@@ -341,6 +354,32 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
assertDoesNotThrow(() -> remove(index, row));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testNextRowIdToBuild(boolean pk) {
+ IndexStorage indexStorage;
+
+ if (pk) {
+ indexStorage = createPkIndexStorage();
+
+ assertNull(indexStorage.getNextRowIdToBuild());
+ } else {
+ indexStorage = createIndexStorage(INDEX_NAME, ColumnType.INT32);
+
+ assertEquals(initialRowIdToBuild(TEST_PARTITION), indexStorage.getNextRowIdToBuild());
+ }
+
+ var newNextRowIdToBuild = new RowId(TEST_PARTITION);
+
+ partitionStorage.runConsistently(locker -> {
+ indexStorage.setNextRowIdToBuild(newNextRowIdToBuild);
+
+ return null;
+ });
+
+ assertEquals(newNextRowIdToBuild, newNextRowIdToBuild);
+ }
+
protected static Collection<RowId> getAll(IndexStorage index, IndexRow row) {
try (Cursor<RowId> cursor = index.get(row.indexColumns())) {
return cursor.stream().collect(toList());
@@ -387,4 +426,20 @@ public abstract class AbstractIndexStorageTest<S extends IndexStorage, D extends
private static ColumnParams.Builder columnParamsBuilder(ColumnType columnType) {
return ColumnParams.builder().name(columnName(columnType)).type(columnType);
}
+
+ void addToCatalog(CatalogIndexDescriptor indexDescriptor) {
+ when(catalogService.aliveIndex(eq(indexDescriptor.name()), anyLong())).thenReturn(indexDescriptor);
+ when(catalogService.index(eq(indexDescriptor.id()), anyInt())).thenReturn(indexDescriptor);
+ }
+
+ IndexStorage createPkIndexStorage() {
+ CatalogTableDescriptor tableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong());
+
+ CatalogIndexDescriptor pkIndexDescriptor = catalogService.aliveIndex(PK_INDEX_NAME, clock.nowLong());
+
+ return tableStorage.getOrCreateIndex(
+ TEST_PARTITION,
+ StorageIndexDescriptor.create(tableDescriptor, pkIndexDescriptor)
+ );
+ }
}
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractSortedIndexStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractSortedIndexStorageTest.java
index 12f1751934..be854f4f58 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractSortedIndexStorageTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/AbstractSortedIndexStorageTest.java
@@ -43,10 +43,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
@@ -93,13 +89,7 @@ public abstract class AbstractSortedIndexStorageTest extends AbstractIndexStorag
@Override
protected SortedIndexStorage createIndexStorage(String name, ColumnType... columnTypes) {
- return createIndexStorage(
- name,
- Stream.of(columnTypes)
- .map(AbstractIndexStorageTest::columnName)
- .map(columnName -> new CatalogIndexColumnDescriptor(columnName, ASC_NULLS_FIRST))
- .toArray(CatalogIndexColumnDescriptor[]::new)
- );
+ return createIndexStorage(name, toCatalogIndexColumnDescriptors(columnTypes));
}
/**
@@ -122,24 +112,16 @@ public abstract class AbstractSortedIndexStorageTest extends AbstractIndexStorag
* Creates a Sorted Index using the given index definition.
*/
protected SortedIndexStorage createIndexStorage(String name, CatalogIndexColumnDescriptor... columns) {
- CatalogTableDescriptor catalogTableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong());
+ CatalogTableDescriptor tableDescriptor = catalogService.table(TABLE_NAME, clock.nowLong());
- CatalogSortedIndexDescriptor catalogSortedIndexDescriptor = new CatalogSortedIndexDescriptor(
- catalogId.getAndIncrement(),
- name,
- catalogTableDescriptor.id(),
- false,
- AVAILABLE,
- catalogService.latestCatalogVersion(),
- List.of(columns)
- );
+ int tableId = tableDescriptor.id();
+ int indexId = catalogId.getAndIncrement();
- when(catalogService.aliveIndex(eq(catalogSortedIndexDescriptor.name()), anyLong())).thenReturn(catalogSortedIndexDescriptor);
- when(catalogService.index(eq(catalogSortedIndexDescriptor.id()), anyInt())).thenReturn(catalogSortedIndexDescriptor);
+ CatalogSortedIndexDescriptor indexDescriptor = createCatalogIndexDescriptor(tableId, indexId, name, columns);
return tableStorage.getOrCreateSortedIndex(
TEST_PARTITION,
- new StorageSortedIndexDescriptor(catalogTableDescriptor, catalogSortedIndexDescriptor)
+ new StorageSortedIndexDescriptor(tableDescriptor, indexDescriptor)
);
}
@@ -148,6 +130,32 @@ public abstract class AbstractSortedIndexStorageTest extends AbstractIndexStorag
return index.indexDescriptor();
}
+ @Override
+ CatalogSortedIndexDescriptor createCatalogIndexDescriptor(int tableId, int indexId, String indexName, ColumnType... columnTypes) {
+ return createCatalogIndexDescriptor(tableId, indexId, indexName, toCatalogIndexColumnDescriptors(columnTypes));
+ }
+
+ private CatalogSortedIndexDescriptor createCatalogIndexDescriptor(
+ int tableId,
+ int indexId,
+ String indexName,
+ CatalogIndexColumnDescriptor... columns
+ ) {
+ var indexDescriptor = new CatalogSortedIndexDescriptor(
+ indexId,
+ indexName,
+ tableId,
+ false,
+ AVAILABLE,
+ catalogService.latestCatalogVersion(),
+ List.of(columns)
+ );
+
+ addToCatalog(indexDescriptor);
+
+ return indexDescriptor;
+ }
+
/**
* Tests that columns of all types are correctly serialized and deserialized.
*/
@@ -1601,4 +1609,11 @@ public abstract class AbstractSortedIndexStorageTest extends AbstractIndexStorag
return new SimpleRow<>(mapper.apply(indexRow), indexRow.rowId());
}
}
+
+ private static CatalogIndexColumnDescriptor[] toCatalogIndexColumnDescriptors(ColumnType... columnTypes) {
+ return Stream.of(columnTypes)
+ .map(AbstractIndexStorageTest::columnName)
+ .map(columnName -> new CatalogIndexColumnDescriptor(columnName, ASC_NULLS_FIRST))
+ .toArray(CatalogIndexColumnDescriptor[]::new);
+ }
}
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/AbstractTestIndexStorage.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/AbstractTestIndexStorage.java
index 67432a3e62..6a38d3daaf 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/AbstractTestIndexStorage.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/AbstractTestIndexStorage.java
@@ -41,12 +41,15 @@ abstract class AbstractTestIndexStorage implements IndexStorage {
private final int partitionId;
+ private final boolean pk;
+
/** Amount of cursors that opened and still do not close. */
protected final AtomicInteger pendingCursors = new AtomicInteger();
- AbstractTestIndexStorage(int partitionId) {
+ AbstractTestIndexStorage(int partitionId, boolean pk) {
this.partitionId = partitionId;
- nextRowIdToBuild = initialRowIdToBuild(partitionId);
+ this.pk = pk;
+ nextRowIdToBuild = pk ? null : initialRowIdToBuild(partitionId);
}
/**
@@ -114,7 +117,7 @@ abstract class AbstractTestIndexStorage implements IndexStorage {
private void clearAndReset() {
clear0();
- nextRowIdToBuild = initialRowIdToBuild(partitionId);
+ nextRowIdToBuild = pk ? null : initialRowIdToBuild(partitionId);
}
public void destroy() {
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestHashIndexStorage.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestHashIndexStorage.java
index 781dfcbc6b..9dfa54605b 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestHashIndexStorage.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestHashIndexStorage.java
@@ -46,7 +46,7 @@ public class TestHashIndexStorage extends AbstractTestIndexStorage implements Ha
* Constructor.
*/
public TestHashIndexStorage(int partitionId, StorageHashIndexDescriptor descriptor) {
- super(partitionId);
+ super(partitionId, descriptor.isPk());
this.descriptor = descriptor;
}
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java
index 0da4df6c17..e316f79352 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java
@@ -56,7 +56,7 @@ public class TestSortedIndexStorage extends AbstractTestIndexStorage implements
* Constructor.
*/
public TestSortedIndexStorage(int partitionId, StorageSortedIndexDescriptor descriptor) {
- super(partitionId);
+ super(partitionId, descriptor.isPk());
BinaryTupleComparator binaryTupleComparator = new BinaryTupleComparator(descriptor.columns());
diff --git a/modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/IndexStorageFactory.java b/modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/IndexStorageFactory.java
index a8631b4c0c..0bc40c0f5a 100644
--- a/modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/IndexStorageFactory.java
+++ b/modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/IndexStorageFactory.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.storage.pagememory.mv;
import static org.apache.ignite.internal.storage.util.StorageUtils.initialRowIdToBuild;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.internal.lang.IgniteInternalCheckedException;
import org.apache.ignite.internal.pagememory.PageIdAllocator;
@@ -284,7 +285,9 @@ class IndexStorageFactory {
IndexType indexType = descriptor instanceof StorageHashIndexDescriptor ? IndexType.HASH : IndexType.SORTED;
- var indexMeta = new IndexMeta(descriptor.id(), indexType, metaPageId, initialRowIdToBuild(partitionId).uuid());
+ UUID nextRowIdUuidToBuild = descriptor.isPk() ? null : initialRowIdToBuild(partitionId).uuid();
+
+ var indexMeta = new IndexMeta(descriptor.id(), indexType, metaPageId, nextRowIdUuidToBuild);
boolean replaced = indexMetaTree.putx(indexMeta);
diff --git a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMetaStorage.java b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMetaStorage.java
index 2b2b3d035e..9635cab9fd 100644
--- a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMetaStorage.java
+++ b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMetaStorage.java
@@ -77,13 +77,14 @@ public class RocksDbMetaStorage {
*
* @param indexId Index ID.
* @param partitionId Partition ID.
+ * @param pk Primary index flag.
*/
- public @Nullable RowId getNextRowIdToBuild(int tableId, int indexId, int partitionId) {
+ public @Nullable RowId getNextRowIdToBuild(int tableId, int indexId, int partitionId, boolean pk) {
try {
byte[] lastBuiltRowIdBytes = metaColumnFamily.get(createKey(INDEX_ROW_ID_PREFIX, tableId, indexId, partitionId));
if (lastBuiltRowIdBytes == null) {
- return initialRowIdToBuild(partitionId);
+ return pk ? null : initialRowIdToBuild(partitionId);
}
if (lastBuiltRowIdBytes.length == 0) {
diff --git a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/AbstractRocksDbIndexStorage.java b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/AbstractRocksDbIndexStorage.java
index 27de6178e5..55046dc02e 100644
--- a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/AbstractRocksDbIndexStorage.java
+++ b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/AbstractRocksDbIndexStorage.java
@@ -68,6 +68,8 @@ public abstract class AbstractRocksDbIndexStorage implements IndexStorage {
protected final int partitionId;
+ private final boolean pk;
+
private final RocksDbMetaStorage indexMetaStorage;
/** Busy lock. */
@@ -79,13 +81,14 @@ public abstract class AbstractRocksDbIndexStorage implements IndexStorage {
/** Row ID for which the index needs to be built, {@code null} means that the index building has completed. */
private volatile @Nullable RowId nextRowIdToBuild;
- AbstractRocksDbIndexStorage(int tableId, int indexId, int partitionId, RocksDbMetaStorage indexMetaStorage) {
+ AbstractRocksDbIndexStorage(int tableId, int indexId, int partitionId, RocksDbMetaStorage indexMetaStorage, boolean pk) {
this.tableId = tableId;
this.indexId = indexId;
this.indexMetaStorage = indexMetaStorage;
this.partitionId = partitionId;
+ this.pk = pk;
- nextRowIdToBuild = indexMetaStorage.getNextRowIdToBuild(tableId, indexId, partitionId);
+ nextRowIdToBuild = indexMetaStorage.getNextRowIdToBuild(tableId, indexId, partitionId, pk);
}
@Override
@@ -255,7 +258,7 @@ public abstract class AbstractRocksDbIndexStorage implements IndexStorage {
indexMetaStorage.removeNextRowIdToBuild(writeBatch, tableId, indexId, partitionId);
- nextRowIdToBuild = initialRowIdToBuild(partitionId);
+ nextRowIdToBuild = pk ? null : initialRowIdToBuild(partitionId);
}
/** Method that needs to be overridden by the inheritors to remove all implementation specific data for this index. */
diff --git a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbHashIndexStorage.java b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbHashIndexStorage.java
index f99de6a188..179f88f250 100644
--- a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbHashIndexStorage.java
+++ b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbHashIndexStorage.java
@@ -82,7 +82,7 @@ public class RocksDbHashIndexStorage extends AbstractRocksDbIndexStorage impleme
ColumnFamily indexCf,
RocksDbMetaStorage indexMetaStorage
) {
- super(tableId, descriptor.id(), partitionId, indexMetaStorage);
+ super(tableId, descriptor.id(), partitionId, indexMetaStorage, descriptor.isPk());
this.descriptor = descriptor;
this.indexCf = indexCf;
diff --git a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorage.java b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorage.java
index 07ab97f036..9c6db558e0 100644
--- a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorage.java
+++ b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorage.java
@@ -87,7 +87,7 @@ public class RocksDbSortedIndexStorage extends AbstractRocksDbIndexStorage imple
ColumnFamily indexCf,
RocksDbMetaStorage indexMetaStorage
) {
- super(tableId, descriptor.id(), partitionId, indexMetaStorage);
+ super(tableId, descriptor.id(), partitionId, indexMetaStorage, descriptor.isPk());
this.descriptor = descriptor;
this.indexCf = indexCf;
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/IndexBaseTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/IndexBaseTest.java
index 170dc457d4..556f0762ba 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/IndexBaseTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/IndexBaseTest.java
@@ -102,10 +102,17 @@ public abstract class IndexBaseTest extends BaseMvStoragesTest {
int sortedIndexId = 3;
int hashIndexId = 4;
- pkInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(pkIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
- )));
+ pkInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ pkIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
+ ),
+ true
+ )
+ );
TableSchemaAwareIndexStorage pkStorage = new TableSchemaAwareIndexStorage(
pkIndexId,
@@ -113,10 +120,17 @@ public abstract class IndexBaseTest extends BaseMvStoragesTest {
PK_INDEX_BINARY_TUPLE_CONVERTER
);
- sortedInnerStorage = new TestSortedIndexStorage(PARTITION_ID, new StorageSortedIndexDescriptor(sortedIndexId, List.of(
- new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
- new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
- )));
+ sortedInnerStorage = new TestSortedIndexStorage(
+ PARTITION_ID,
+ new StorageSortedIndexDescriptor(
+ sortedIndexId,
+ List.of(
+ new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
+ new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage sortedIndexStorage = new TableSchemaAwareIndexStorage(
sortedIndexId,
@@ -124,10 +138,17 @@ public abstract class IndexBaseTest extends BaseMvStoragesTest {
USER_INDEX_BINARY_TUPLE_CONVERTER
);
- hashInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(hashIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
- )));
+ hashInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ hashIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage hashIndexStorage = new TableSchemaAwareIndexStorage(
hashIndexId,
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/SortedIndexLockerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/SortedIndexLockerTest.java
index cfbf278464..b0de51bbb0 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/SortedIndexLockerTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/SortedIndexLockerTest.java
@@ -51,10 +51,13 @@ class SortedIndexLockerTest extends BaseIgniteAbstractTest {
@Test
void takingInsertLocksOnDestroyedIndexStorageYieldsNullLock() {
- StorageSortedIndexColumnDescriptor column = new StorageSortedIndexColumnDescriptor("c1", NativeTypes.INT32, false, true);
TestSortedIndexStorage indexStorage = new TestSortedIndexStorage(
PARTITION_ID,
- new StorageSortedIndexDescriptor(1, List.of(column))
+ new StorageSortedIndexDescriptor(
+ 1,
+ List.of(new StorageSortedIndexColumnDescriptor("c1", NativeTypes.INT32, false, true)),
+ false
+ )
);
indexStorage.destroy();
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageCleanupTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageCleanupTest.java
index 02948112e4..087bb386e5 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageCleanupTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageCleanupTest.java
@@ -103,10 +103,17 @@ public class StorageCleanupTest extends BaseMvStoragesTest {
int sortedIndexId = 3;
int hashIndexId = 4;
- pkInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(pkIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
- )));
+ pkInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ pkIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
+ ),
+ true
+ )
+ );
TableSchemaAwareIndexStorage pkStorage = new TableSchemaAwareIndexStorage(
pkIndexId,
@@ -114,10 +121,17 @@ public class StorageCleanupTest extends BaseMvStoragesTest {
PK_INDEX_BINARY_TUPLE_CONVERTER
);
- sortedInnerStorage = new TestSortedIndexStorage(PARTITION_ID, new StorageSortedIndexDescriptor(sortedIndexId, List.of(
- new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
- new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
- )));
+ sortedInnerStorage = new TestSortedIndexStorage(
+ PARTITION_ID,
+ new StorageSortedIndexDescriptor(
+ sortedIndexId,
+ List.of(
+ new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
+ new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage sortedIndexStorage = new TableSchemaAwareIndexStorage(
sortedIndexId,
@@ -125,10 +139,17 @@ public class StorageCleanupTest extends BaseMvStoragesTest {
USER_INDEX_BINARY_TUPLE_CONVERTER
);
- hashInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(hashIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
- )));
+ hashInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ hashIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage hashIndexStorage = new TableSchemaAwareIndexStorage(
hashIndexId,
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandlerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandlerTest.java
index 2c0551e8d5..0f871df7a9 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandlerTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/StorageUpdateHandlerTest.java
@@ -96,10 +96,17 @@ public class StorageUpdateHandlerTest extends BaseMvStoragesTest {
int sortedIndexId = 3;
int hashIndexId = 4;
- pkInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(pkIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
- )));
+ pkInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ pkIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTKEY", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRKEY", NativeTypes.STRING, false)
+ ),
+ true
+ )
+ );
TableSchemaAwareIndexStorage pkStorage = new TableSchemaAwareIndexStorage(
pkIndexId,
@@ -107,10 +114,17 @@ public class StorageUpdateHandlerTest extends BaseMvStoragesTest {
PK_INDEX_BINARY_TUPLE_CONVERTER
);
- sortedInnerStorage = new TestSortedIndexStorage(PARTITION_ID, new StorageSortedIndexDescriptor(sortedIndexId, List.of(
- new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
- new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
- )));
+ sortedInnerStorage = new TestSortedIndexStorage(
+ PARTITION_ID,
+ new StorageSortedIndexDescriptor(
+ sortedIndexId,
+ List.of(
+ new StorageSortedIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false, true),
+ new StorageSortedIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false, true)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage sortedIndexStorage = new TableSchemaAwareIndexStorage(
sortedIndexId,
@@ -118,10 +132,17 @@ public class StorageUpdateHandlerTest extends BaseMvStoragesTest {
USER_INDEX_BINARY_TUPLE_CONVERTER
);
- hashInnerStorage = new TestHashIndexStorage(PARTITION_ID, new StorageHashIndexDescriptor(hashIndexId, List.of(
- new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
- new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
- )));
+ hashInnerStorage = new TestHashIndexStorage(
+ PARTITION_ID,
+ new StorageHashIndexDescriptor(
+ hashIndexId,
+ List.of(
+ new StorageHashIndexColumnDescriptor("INTVAL", NativeTypes.INT32, false),
+ new StorageHashIndexColumnDescriptor("STRVAL", NativeTypes.STRING, false)
+ ),
+ false
+ )
+ );
TableSchemaAwareIndexStorage hashIndexStorage = new TableSchemaAwareIndexStorage(
hashIndexId,
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/PartitionCommandListenerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/PartitionCommandListenerTest.java
index 3410eb5e4e..e32af05bda 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/PartitionCommandListenerTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/PartitionCommandListenerTest.java
@@ -166,7 +166,11 @@ public class PartitionCommandListenerTest extends BaseIgniteAbstractTest {
1,
new TestHashIndexStorage(
PARTITION_ID,
- new StorageHashIndexDescriptor(1, List.of(new StorageHashIndexColumnDescriptor("key", NativeTypes.INT32, false)))
+ new StorageHashIndexDescriptor(
+ TABLE_ID,
+ List.of(new StorageHashIndexColumnDescriptor("key", NativeTypes.INT32, false)),
+ true
+ )
),
BinaryRowConverter.keyExtractor(SCHEMA)
);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java
index bae54ec3af..f204c65da1 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerIndexLockingTest.java
@@ -164,7 +164,8 @@ public class PartitionReplicaListenerIndexLockingTest extends IgniteAbstractTest
StorageHashIndexDescriptor pkIndexDescriptor = new StorageHashIndexDescriptor(
PK_INDEX_ID,
- List.of(new StorageHashIndexColumnDescriptor("ID", NativeTypes.INT32, false))
+ List.of(new StorageHashIndexColumnDescriptor("ID", NativeTypes.INT32, false)),
+ true
);
TableSchemaAwareIndexStorage hashIndexStorage = new TableSchemaAwareIndexStorage(
@@ -187,9 +188,8 @@ public class PartitionReplicaListenerIndexLockingTest extends IgniteAbstractTest
new TestSortedIndexStorage(PART_ID,
new StorageSortedIndexDescriptor(
SORTED_INDEX_ID,
- List.of(new StorageSortedIndexColumnDescriptor(
- "val", NativeTypes.INT32, false, true
- ))
+ List.of(new StorageSortedIndexColumnDescriptor("val", NativeTypes.INT32, false, true)),
+ false
)),
row2SortKeyConverter
);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
index 5c3df6313d..2be41d90b1 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
@@ -480,13 +480,21 @@ public class PartitionReplicaListenerTest extends IgniteAbstractTest {
pkStorageSupplier = new Lazy<>(() -> new TableSchemaAwareIndexStorage(
pkIndexId,
- new TestHashIndexStorage(PART_ID, mock(StorageHashIndexDescriptor.class)),
+ new TestHashIndexStorage(
+ PART_ID,
+ new StorageHashIndexDescriptor(pkIndexId, List.of(), true)
+ ),
row2Tuple
));
- SortedIndexStorage indexStorage = new TestSortedIndexStorage(PART_ID, new StorageSortedIndexDescriptor(sortedIndexId, List.of(
- new StorageSortedIndexColumnDescriptor("intVal", NativeTypes.INT32, false, true)
- )));
+ SortedIndexStorage indexStorage = new TestSortedIndexStorage(
+ PART_ID,
+ new StorageSortedIndexDescriptor(
+ sortedIndexId,
+ List.of(new StorageSortedIndexColumnDescriptor("intVal", NativeTypes.INT32, false, true)),
+ false
+ )
+ );
// 2 is the index of "intVal" in the list of all columns.
ColumnsExtractor columnsExtractor = BinaryRowConverter.columnsExtractor(schemaDescriptor, 2);
@@ -495,9 +503,14 @@ public class PartitionReplicaListenerTest extends IgniteAbstractTest {
hashIndexStorage = new TableSchemaAwareIndexStorage(
hashIndexId,
- new TestHashIndexStorage(PART_ID, new StorageHashIndexDescriptor(hashIndexId, List.of(
- new StorageHashIndexColumnDescriptor("intVal", NativeTypes.INT32, false)
- ))),
+ new TestHashIndexStorage(
+ PART_ID,
+ new StorageHashIndexDescriptor(
+ hashIndexId,
+ List.of(new StorageHashIndexColumnDescriptor("intVal", NativeTypes.INT32, false)),
+ false
+ )
+ ),
columnsExtractor
);