sanpwc commented on code in PR #1191:
URL: https://github.com/apache/ignite-3/pull/1191#discussion_r1005531567


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -1557,6 +1577,103 @@ public CompletableFuture<TableImpl> 
tableAsyncInternal(UUID id, boolean checkCon
         return getTblFut.whenComplete((unused, throwable) -> 
tablesByIdVv.removeWhenComplete(tablesListener));
     }
 
+    /**
+     * Register the index with given id in a table.
+     *
+     * @param tableId A table id to register index in.
+     * @param indexId An index id os the index to register.
+     * @param searchRowResolver Function which converts given table row to an 
index key.
+     */
+    public void registerHashIndex(UUID tableId, UUID indexId, 
Function<BinaryRow, CompletableFuture<BinaryTuple>> searchRowResolver) {

Review Comment:
   Mmm, at first sight it is still possible.
   All
   ```
       private final Map<UUID, Map<UUID, IndexStorageAdapterFactory>> 
indexStorageAdapterFactories = new ConcurrentHashMap<>();
       private final Map<UUID, Map<UUID, IndexLockerFactory>> 
indexLockerFactories = new ConcurrentHashMap<>();
   ```
   and 
   ```
   registerHashIndex
   unregisterIndex
   ```
   goes inside table
   
   Thus 
   `IndexManager#createIndexLocally` will call 
`tableManager.table(tableId).registerHashIndex` instead of 
`tableManager.registerHashIndex`
   
   registerHashIndex inside table will look similar to
   ```
       public void registerHashIndex(UUID indexId, boolean unique, 
Function<BinaryRow, BinaryTuple> searchRowResolver) {
           indexLockerFactories.computeIfAbsent(
                   tableId(),
                   key -> new ConcurrentHashMap<>()
           ).put(
                   indexId,
                   partitionId -> new HashIndexLocker(
                           indexId,
                           unique,
                           lockMgr,
                           searchRowResolver
                   )
           );
           indexStorageAdapterFactories.put(
                   indexId,
                   partitionId -> new TableSchemaAwareIndexStorage(
                           indexId,
                           storage().getOrCreateHashIndex(partitionId, indexId),
                           searchRowResolver
                   )
           );
       }
   ```
   Besides populating talbe with
   ```
       private final Map<UUID, IndexLockerFactory> indexLockerFactories = new 
ConcurrentHashMap<>();
   
       private final Map<UUID, IndexStorageAdapterFactory> 
indexStorageAdapterFactories = new ConcurrentHashMap<>();
   ```
   we will also propagate lockManager to a table, not a big deal.
   
   `indexStorageAdapters` also goes to table and in order to populate partion 
with list of storage adapters we call
   ` new Lazy<>(() -> 
internalTbl.indexStorageAdapters(partId).get().get(table.pkId()))` in 
PartitoinReplicaListener construcor.
   
   I dind't check all that in code, however, seems that it should work.



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