From f5cf8137298cd534b29ec993c7b4b09cbefd6c95 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Mon, 18 Nov 2024 09:34:09 +0000 Subject: [PATCH] apply review comment --- .../index/engine/LuceneSyntheticSourceChangesSnapshot.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshot.java b/server/src/main/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshot.java index 1608489e39eec..2bc517745f7e2 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshot.java +++ b/server/src/main/java/org/elasticsearch/index/engine/LuceneSyntheticSourceChangesSnapshot.java @@ -114,8 +114,7 @@ protected Translog.Operation nextOperation() throws IOException { private void loadNextBatch() throws IOException { List documentsToLoad = new ArrayList<>(); long accumulatedSize = 0; - boolean reachedMemoryLimit = false; - while (reachedMemoryLimit == false) { + while (accumulatedSize < maxMemorySizeInBytes) { if (pendingDocs.isEmpty()) { ScoreDoc[] topDocs = nextTopDocs().scoreDocs; if (topDocs.length == 0) { @@ -127,9 +126,6 @@ private void loadNextBatch() throws IOException { document.doc().shardIndex = documentsToLoad.size(); documentsToLoad.add(document); accumulatedSize += document.size(); - if (accumulatedSize > maxMemorySizeInBytes) { - reachedMemoryLimit = true; - } } for (var op : loadDocuments(documentsToLoad)) {