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 2025/04/17 13:01:59 UTC

(ignite-3) 01/01: IGNITE-25180 wip

This is an automated email from the ASF dual-hosted git repository.

tkalkirill pushed a commit to branch ignite-25180
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit ab2df85901d633f9d7b8c6ca60d01abb717bf353
Author: Kirill Tkalenko <tk...@yandex.ru>
AuthorDate: Thu Apr 17 16:01:43 2025 +0300

    IGNITE-25180 wip
---
 .../apache/ignite/internal/table/IndexWrapper.java    | 19 ++++++++++++-------
 .../org/apache/ignite/internal/table/TableImpl.java   | 15 +++++++++------
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/IndexWrapper.java b/modules/table/src/main/java/org/apache/ignite/internal/table/IndexWrapper.java
index 95af6e838c3..36e84ae7a24 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/IndexWrapper.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/IndexWrapper.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.table.distributed.IndexLocker;
 import org.apache.ignite.internal.table.distributed.SortedIndexLocker;
 import org.apache.ignite.internal.table.distributed.TableSchemaAwareIndexStorage;
 import org.apache.ignite.internal.tx.LockManager;
+import org.jetbrains.annotations.Nullable;
 
 /** Class that creates index storage and locker decorators for given partition. */
 abstract class IndexWrapper {
@@ -41,11 +42,11 @@ abstract class IndexWrapper {
     }
 
     /**
-     * Creates schema aware index storage wrapper.
+     * Creates schema aware index storage wrapper, {@code null} if the index has been destroyed.
      *
-     * @param partitionId Partition id.
+     * @param partitionId Partition ID.
      */
-    abstract TableSchemaAwareIndexStorage getStorage(int partitionId);
+    abstract @Nullable TableSchemaAwareIndexStorage getStorage(int partitionId);
 
     /**
      * Creates schema aware index locker.
@@ -65,10 +66,12 @@ abstract class IndexWrapper {
         }
 
         @Override
-        TableSchemaAwareIndexStorage getStorage(int partitionId) {
+        @Nullable TableSchemaAwareIndexStorage getStorage(int partitionId) {
             IndexStorage index = tbl.storage().getIndex(partitionId, indexId);
 
-            assert index != null : tbl.name() + " part " + partitionId;
+            if (index == null) {
+                return null;
+            }
 
             return new TableSchemaAwareIndexStorage(
                     indexId,
@@ -105,10 +108,12 @@ abstract class IndexWrapper {
         }
 
         @Override
-        TableSchemaAwareIndexStorage getStorage(int partitionId) {
+        @Nullable TableSchemaAwareIndexStorage getStorage(int partitionId) {
             IndexStorage index = tbl.storage().getIndex(partitionId, indexId);
 
-            assert index != null : "tableId=" + tbl.tableId() + ", indexId=" + indexId + ", partitionId=" + partitionId;
+            if (index == null) {
+                return null;
+            }
 
             return new TableSchemaAwareIndexStorage(
                     indexId,
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
index 09a9f89ee87..bb3d8693784 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java
@@ -231,15 +231,18 @@ public class TableImpl implements TableViewInternal {
     }
 
     /** Returns a supplier of index storage wrapper factories for given partition. */
-    public TableIndexStoragesSupplier indexStorageAdapters(int partId) {
+    public TableIndexStoragesSupplier indexStorageAdapters(int partitionId) {
         return () -> {
-            List<IndexWrapper> factories = new ArrayList<>(indexWrapperById.values());
+            var factories = new ArrayList<>(indexWrapperById.values());
 
-            Map<Integer, TableSchemaAwareIndexStorage> adapters = new HashMap<>();
+            var adapters = new HashMap<Integer, TableSchemaAwareIndexStorage>();
 
-            for (IndexWrapper factory : factories) {
-                TableSchemaAwareIndexStorage storage = factory.getStorage(partId);
-                adapters.put(storage.id(), storage);
+            for (int i = 0; i < factories.size(); i++) {
+                TableSchemaAwareIndexStorage storage = factories.get(i).getStorage(partitionId);
+
+                if (storage != null) {
+                    adapters.put(storage.id(), storage);
+                }
             }
 
             return adapters;