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


##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java:
##########
@@ -465,11 +466,16 @@ private CompletableFuture<?> createIndexLocally(
         CompletableFuture<?> fireEventFuture =
                 fireEvent(IndexEvent.CREATE, new 
IndexEventParameters(causalityToken, tableId, indexId, eventIndexDescriptor));
 
-        CompletableFuture<TableImpl> tableFuture = 
tableManager.tableAsync(causalityToken, tableId);
+        TableImpl table = tableManager.getTable(tableId);
 
-        CompletableFuture<SchemaRegistry> schemaRegistryFuture = 
schemaManager.schemaRegistry(causalityToken, tableId);
+        assert table != null : tableId;
 
-        CompletableFuture<?> createIndexFuture = 
tableFuture.thenAcceptBoth(schemaRegistryFuture, (table, schemaRegistry) -> {
+        CompletableFuture<SchemaRegistry> schemaRegistryFut = 
schemaManager.schemaRegistry(causalityToken, tableId);

Review Comment:
   Let's rename it to **schemaRegistryFuture**.



##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java:
##########
@@ -465,11 +466,16 @@ private CompletableFuture<?> createIndexLocally(
         CompletableFuture<?> fireEventFuture =
                 fireEvent(IndexEvent.CREATE, new 
IndexEventParameters(causalityToken, tableId, indexId, eventIndexDescriptor));
 
-        CompletableFuture<TableImpl> tableFuture = 
tableManager.tableAsync(causalityToken, tableId);
+        TableImpl table = tableManager.getTable(tableId);
 
-        CompletableFuture<SchemaRegistry> schemaRegistryFuture = 
schemaManager.schemaRegistry(causalityToken, tableId);
+        assert table != null : tableId;
 
-        CompletableFuture<?> createIndexFuture = 
tableFuture.thenAcceptBoth(schemaRegistryFuture, (table, schemaRegistry) -> {
+        CompletableFuture<SchemaRegistry> schemaRegistryFut = 
schemaManager.schemaRegistry(causalityToken, tableId);
+
+        // TODO: https://issues.apache.org/jira/browse/IGNITE-19712 Listen to 
assignment changes and start new index storages.
+        CompletableFuture<PartitionSet> tableStoragesFut = 
tableManager.localPartitionSetAsync(causalityToken, tableId);

Review Comment:
   Let's rename it to **tablePartitionFuture**.



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/engine/MvTableStorage.java:
##########
@@ -268,7 +268,6 @@ CompletableFuture<Void> finishRebalancePartition(
      * @return Index Storage.
      * @throws StorageException If the given partition does not exist.
      */
-    // TODO: IGNITE-19112 Change or get rid of

Review Comment:
   I will ask you to either return the **TODO**, or add it to the mention of 
this method in the ticket.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -2356,32 +2405,50 @@ private static PeersAndLearners 
configurationFromAssignments(Collection<Assignme
     }
 
     /**
-     * Creates partition stores. If one of the storages has not completed the 
rebalance, then the storages are cleared.
+     * Gets partition stores.
      *
      * @param table Table.
      * @param partitionId Partition ID.
-     * @return Future of creating or getting partition stores.
+     * @return PartitionStorages.
      */
-    // TODO: IGNITE-18939 Create storages only once, then only get them
-    private CompletableFuture<PartitionStorages> 
getOrCreatePartitionStorages(TableImpl table, int partitionId) {
+    private PartitionStorages getPartitionStorages(TableImpl table, int 
partitionId) {
         InternalTable internalTable = table.internalTable();
 
         MvPartitionStorage mvPartition = 
internalTable.storage().getMvPartition(partitionId);
 
-        return (mvPartition != null ? completedFuture(mvPartition) : 
internalTable.storage().createMvPartition(partitionId))
-                .thenComposeAsync(mvPartitionStorage -> {
-                    TxStateStorage txStateStorage = 
internalTable.txStateStorage().getOrCreateTxStateStorage(partitionId);
+        assert mvPartition != null;
 
-                    if (mvPartitionStorage.persistedIndex() == 
MvPartitionStorage.REBALANCE_IN_PROGRESS
-                            || txStateStorage.persistedIndex() == 
TxStateStorage.REBALANCE_IN_PROGRESS) {
-                        return allOf(
-                                
internalTable.storage().clearPartition(partitionId),
-                                txStateStorage.clear()
-                        ).thenApply(unused -> new 
PartitionStorages(mvPartitionStorage, txStateStorage));
-                    } else {
-                        return completedFuture(new 
PartitionStorages(mvPartitionStorage, txStateStorage));
-                    }
-                }, ioExecutor);
+        TxStateStorage txStateStorage = 
internalTable.txStateStorage().getTxStateStorage(partitionId);
+
+        assert txStateStorage != null;
+
+        return new PartitionStorages(mvPartition, txStateStorage);
+    }
+
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-19739 Create 
storages only once.

Review Comment:
   This ticket talks about indexes, but it should be about partitions, right?



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