Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Dec 3, 2024
1 parent 2124324 commit 23fe840
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public LuceneSyntheticSourceChangesSnapshot(
this.maxMemorySizeInBytes = maxMemorySizeInBytes;
this.sourceLoader = mappingLookup.newSourceLoader(SourceFieldMetrics.NOOP);
Set<String> storedFields = sourceLoader.requiredStoredFields();
this.storedFieldLoader = StoredFieldLoader.create(mappingLookup.isSourceSynthetic() == false, storedFields);
assert mappingLookup.isSourceSynthetic() : "synthetic source must be enabled for proper functionality.";
this.storedFieldLoader = StoredFieldLoader.create(false, storedFields);
this.lastSeenSeqNo = fromSeqNo - 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ protected SearchBasedChangesSnapshot(
throw new IllegalArgumentException("Search_batch_size must be positive [" + searchBatchSize + "]");
}

final AtomicBoolean closed = new AtomicBoolean();
this.onClose = () -> {
if (closed.compareAndSet(false, true)) {
IOUtils.close(engineSearcher);
}
};

this.indexVersionCreated = indexVersionCreated;
this.fromSeqNo = fromSeqNo;
this.toSeqNo = toSeqNo;
Expand All @@ -91,13 +98,6 @@ protected SearchBasedChangesSnapshot(
this.indexSearcher = newIndexSearcher(engineSearcher);
this.indexSearcher.setQueryCache(null);

final AtomicBoolean closed = new AtomicBoolean();
this.onClose = () -> {
if (closed.compareAndSet(false, true)) {
IOUtils.close(engineSearcher);
}
};

long requestingSize = (toSeqNo - fromSeqNo == Long.MAX_VALUE) ? Long.MAX_VALUE : (toSeqNo - fromSeqNo + 1L);
this.searchBatchSize = (int) Math.min(requestingSize, searchBatchSize);

Expand Down

0 comments on commit 23fe840

Please sign in to comment.