You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/09/21 10:13:19 UTC

[GitHub] [jackrabbit-oak] amit-jain commented on a diff in pull request #715: OAK-9790 - Implement parallel indexing for speeding up oak run indexing command

amit-jain commented on code in PR #715:
URL: https://github.com/apache/jackrabbit-oak/pull/715#discussion_r976324312


##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/DocumentStoreIndexerBase.java:
##########
@@ -265,6 +271,55 @@ public void reindex() throws CommitFailedException, IOException {
         indexerSupport.postIndexWork(copyOnWriteStore);
     }
 
+    private void indexParallel(List<FlatFileStore> storeList, CompositeIndexer indexer, IndexingProgressReporter progressReporter) {
+        ExecutorService service = Executors.newFixedThreadPool(IndexerConfiguration.indexThreadPoolSize());
+        List<Future> futureList = new ArrayList<>();
+
+        for (FlatFileStore item : storeList) {
+            Future future = service.submit(new Callable<Boolean>() {
+                @Override
+                public Boolean call() throws IOException, CommitFailedException {
+                    for (NodeStateEntry entry : item) {
+                        reportDocumentRead(entry.getPath(), progressReporter);
+                        log.trace("Indexing : {}", entry.getPath());
+                        indexer.index(entry);
+                    }
+                    return true;
+                }
+            });
+            futureList.add(future);
+        }
+
+        try {
+            for (Future future : futureList) {
+                future.get();
+            }
+            log.info("All {} indexing jobs are done", storeList.size());
+        } catch (InterruptedException | ExecutionException e) {
+            log.error("Failure getting indexing job result", e);

Review Comment:
   @fabriziofortino You had a comment in the original PR which I forgot to address. It might be   better to throw in case of exceptions as it affects correctness. @thomasmueller wdyt?



-- 
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: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org