maedhroz commented on code in PR #2492:
URL: https://github.com/apache/cassandra/pull/2492#discussion_r1264244329


##########
src/java/org/apache/cassandra/index/SecondaryIndexManager.java:
##########
@@ -490,10 +490,58 @@ public static String getIndexName(String cfName)
         assert isIndexColumnFamily(cfName);
         return StringUtils.substringAfter(cfName, 
Directories.SECONDARY_INDEX_NAME_SEPARATOR);
     }
+    
+    public void buildIndexesBlockingIncremental(Collection<SSTableReader> 
sstables)
+    {
+        Set<Index> toBuild = 
indexes.values().stream().filter(Index::isSSTableAttached).collect(Collectors.toSet());
+
+        if (toBuild.isEmpty())
+            return;
+
+        logger.info("Submitting incremental index build of {} for data in {}",
+                    commaSeparated(toBuild),
+                    
sstables.stream().map(SSTableReader::toString).collect(Collectors.joining(",")));
+
+        // Group all building tasks
+        Map<Index.IndexBuildingSupport, Set<Index>> byType = new HashMap<>();
+        for (Index index : toBuild)
+        {
+            Set<Index> stored = 
byType.computeIfAbsent(index.getBuildTaskSupport(), i -> new HashSet<>());
+            stored.add(index);
+        }
+
+        // Schedule all index building tasks with callbacks to handle success 
and failure
+        List<Future<?>> futures = new ArrayList<>(byType.size());
+        byType.forEach((buildingSupport, groupedIndexes) ->
+        {
+            SecondaryIndexBuilder builder = 
buildingSupport.getIndexBuildTask(baseCfs, groupedIndexes, sstables, false);
+            AsyncPromise<Object> build = new AsyncPromise<>();
+            
CompactionManager.instance.submitIndexBuild(builder).addCallback(new 
FutureCallback<Object>()
+            {
+                @Override
+                public void onFailure(Throwable t)
+                {
+                    logger.warn("Failed to build indexes {}", 
getIndexNames(groupedIndexes));
+                    build.tryFailure(t);
+                }
+
+                @Override
+                public void onSuccess(Object o)
+                {
+                    logger.info("Index build of {} completed", 
getIndexNames(groupedIndexes));

Review Comment:
   ```suggestion
                       logger.info("Incremental index build of {} completed", 
getIndexNames(groupedIndexes));
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to