You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2021/10/28 14:17:34 UTC
[lucene-solr] 02/03: SOLR-15676:
UpdateLog.RecentUpdates.getVersions to not return duplicate versions (#331)
This is an automated email from the ASF dual-hosted git repository.
cpoerschke pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 0c86be834e7beb3d5e54af7d808ca9c02fddb4ed
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Thu Oct 28 14:55:55 2021 +0100
SOLR-15676: UpdateLog.RecentUpdates.getVersions to not return duplicate versions (#331)
(cherry picked from commit be2db72164642c4f0b75f21168ba661c0651464a)
---
solr/core/src/java/org/apache/solr/update/UpdateLog.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index e1a2a0b..789f145 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1454,10 +1454,18 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
public List<Long> getVersions(int n, long maxVersion) {
List<Long> ret = new ArrayList<>(n);
+ LongSet set = new LongSet(n);
+ final int nInput = n;
for (List<Update> singleList : updateList) {
for (Update ptr : singleList) {
if(Math.abs(ptr.version) > Math.abs(maxVersion)) continue;
+ if (!set.add(ptr.version)) {
+ if (debug) {
+ log.debug("getVersions(n={}, maxVersion={}) not returning duplicate version = {}", nInput, maxVersion, ptr.version);
+ }
+ continue;
+ }
ret.add(ptr.version);
if (--n <= 0) return ret;
}