Source:
<code>private void reindexIncrementally( ChangeJournal journal ) { long earliestTimestamp = Long.MAX_VALUE; List<IndexProvider> incrementalIndexingProviders = new ArrayList<>(); for (IndexProvider provider : indexManager.getProviders()) { Long latestIndexUpdateTime = provider.getLatestIndexUpdateTime(); if (latestIndexUpdateTime == null) { logger.warn(JcrI18n.warnIncrementalIndexingNotSupported, provider.getName()); continue; } incrementalIndexingProviders.add(provider); earliestTimestamp = Math.min(earliestTimestamp, latestIndexUpdateTime); } if (incrementalIndexingProviders.isEmpty()) { return; } assert earliestTimestamp != Long.MAX_VALUE; <START> Set<NodeKey> changedNodes = journal.changedNodesSince(earliestTimestamp); <END> IndexWriter writer = CompositeIndexWriter.create(incrementalIndexingProviders); RepositoryCache repositoryCache = runningState.repositoryCache(); for (String workspaceName : repositoryCache.getWorkspaceNames()) { if (logger.isDebugEnabled()) { logger.debug("Performing incremental reindexing since '{0}' for repository '{1}' on workspace '{2}'", new Date(earliestTimestamp), repositoryCache.getName(), workspaceName); } WorkspaceCache workspaceCache = repositoryCache.getWorkspaceCache(workspaceName); reindexSince(workspaceCache, writer, changedNodes); } }</code><technical_language>pretty set of changed node keys large, especially adding a new process cluster? memory issues? I this is save amount of work done computing set of changed node keys, for journal efficiently return Iterable<NodeKey> for reindexSince(...) method iterator? journal this a Set, in case current behavior is achieved, iterator literally walks journal possibly returns a node more once. is easier start out with, is more scalable for situations a lot of nodes (perhaps of them) changed. Changing signature give flexibility, while reindex method line 326 care (and is iterating keys anyway)</technical_language>

Target:
private void reindexIncrementally( ChangeJournal journal ) { long earliestTimestamp = Long.MAX_VALUE; List<IndexProvider> incrementalIndexingProviders = new ArrayList<>(); for (IndexProvider provider : indexManager.getProviders()) { Long latestIndexUpdateTime = provider.getLatestIndexUpdateTime(); if (latestIndexUpdateTime == null) { logger.warn(JcrI18n.warnIncrementalIndexingNotSupported, provider.getName()); continue; } incrementalIndexingProviders.add(provider); earliestTimestamp = Math.min(earliestTimestamp, latestIndexUpdateTime); } if (incrementalIndexingProviders.isEmpty()) { return; } assert earliestTimestamp != Long.MAX_VALUE; Iterator<NodeKey> changedNodes = journal.changedNodesSince(earliestTimestamp); IndexWriter writer = CompositeIndexWriter.create(incrementalIndexingProviders); RepositoryCache repositoryCache = runningState.repositoryCache(); for (String workspaceName : repositoryCache.getWorkspaceNames()) { if (logger.isDebugEnabled()) { logger.debug("Performing incremental reindexing since '{0}' for repository '{1}' on workspace '{2}'", new Date(earliestTimestamp), repositoryCache.getName(), workspaceName); } WorkspaceCache workspaceCache = repositoryCache.getWorkspaceCache(workspaceName); reindexSince(workspaceCache, writer, changedNodes); } }