SammyVimes commented on code in PR #2177:
URL: https://github.com/apache/ignite-3/pull/2177#discussion_r1230497527


##########
modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java:
##########
@@ -322,40 +312,96 @@ public void registerHashIndex(
      */
     public void registerSortedIndex(
             StorageSortedIndexDescriptor indexDescriptor,
-            Function<BinaryRow, BinaryTuple> searchRowResolver
+            Function<BinaryRow, BinaryTuple> searchRowResolver,
+            PartitionSet partitions
     ) {
         int indexId = indexDescriptor.id();
 
-        indexLockerFactories.put(
-                indexId,
-                partitionId -> new SortedIndexLocker(
-                        indexId,
-                        partitionId,
-                        lockManager,
-                        tbl.storage().getOrCreateSortedIndex(partitionId, 
indexDescriptor),
-                        searchRowResolver
-                )
-        );
-        indexStorageAdapterFactories.put(
-                indexId,
-                partitionId -> new TableSchemaAwareIndexStorage(
-                        indexId,
-                        tbl.storage().getOrCreateSortedIndex(partitionId, 
indexDescriptor),
-                        searchRowResolver
-                )
-        );
+        partitions.stream().forEach(partitionId -> {
+            tbl.storage().getOrCreateSortedIndex(partitionId, indexDescriptor);
+        });
+
+        indexStorageAdapters.put(indexId, new SortedIndexWrapper(indexId, 
searchRowResolver));
 
         completeWaitIndex(indexId);
     }
 
+    /** Class that creates index storage and locker decorators for given 
partition. */
+    private abstract static class IndexWrapper {
+        final int indexId;
+        final Function<BinaryRow, BinaryTuple> indexRowResolver;
+
+        private IndexWrapper(int indexId, Function<BinaryRow, BinaryTuple> 
indexRowResolver) {
+            this.indexId = indexId;
+            this.indexRowResolver = indexRowResolver;
+        }
+
+        abstract TableSchemaAwareIndexStorage getStorage(int partitionId);

Review Comment:
   It doesn't really create a storage, but it creates a wrapper. Do you think 
it should be called `createStorage`?



##########
modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java:
##########
@@ -322,40 +312,96 @@ public void registerHashIndex(
      */
     public void registerSortedIndex(
             StorageSortedIndexDescriptor indexDescriptor,
-            Function<BinaryRow, BinaryTuple> searchRowResolver
+            Function<BinaryRow, BinaryTuple> searchRowResolver,
+            PartitionSet partitions
     ) {
         int indexId = indexDescriptor.id();
 
-        indexLockerFactories.put(
-                indexId,
-                partitionId -> new SortedIndexLocker(
-                        indexId,
-                        partitionId,
-                        lockManager,
-                        tbl.storage().getOrCreateSortedIndex(partitionId, 
indexDescriptor),
-                        searchRowResolver
-                )
-        );
-        indexStorageAdapterFactories.put(
-                indexId,
-                partitionId -> new TableSchemaAwareIndexStorage(
-                        indexId,
-                        tbl.storage().getOrCreateSortedIndex(partitionId, 
indexDescriptor),
-                        searchRowResolver
-                )
-        );
+        partitions.stream().forEach(partitionId -> {
+            tbl.storage().getOrCreateSortedIndex(partitionId, indexDescriptor);
+        });
+
+        indexStorageAdapters.put(indexId, new SortedIndexWrapper(indexId, 
searchRowResolver));
 
         completeWaitIndex(indexId);
     }
 
+    /** Class that creates index storage and locker decorators for given 
partition. */
+    private abstract static class IndexWrapper {
+        final int indexId;
+        final Function<BinaryRow, BinaryTuple> indexRowResolver;
+
+        private IndexWrapper(int indexId, Function<BinaryRow, BinaryTuple> 
indexRowResolver) {
+            this.indexId = indexId;
+            this.indexRowResolver = indexRowResolver;
+        }
+
+        abstract TableSchemaAwareIndexStorage getStorage(int partitionId);
+
+        abstract IndexLocker getLocker(int partitionId);

Review Comment:
   Same here



-- 
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]

Reply via email to