Skip to content

Apache Lucene open-source search software

LUCENE-2693: Add delete term and query need to more precisely record the bytes used (trunk)

Shai Erera047d76bf6aac
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 3ddfac97ed3..99733821100 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -689,6 +689,9 @@ Bug fixes
internally, it now calls Similarity.idfExplain(Collection, IndexSearcher).
(Robert Muir)
+* LUCENE-2693: RAM used by IndexWriter was slightly incorrectly computed.
+ (Jason Rutherglen via Shai Erera)
+
New features
* LUCENE-2128: Parallelized fetching document frequencies during weight
diff --git a/lucene/src/java/org/apache/lucene/index/SegmentDeletes.java b/lucene/src/java/org/apache/lucene/index/SegmentDeletes.java
index 1bb7f028c44..b7341636f5d 100644
--- a/lucene/src/java/org/apache/lucene/index/SegmentDeletes.java
+++ b/lucene/src/java/org/apache/lucene/index/SegmentDeletes.java
@@ -140,8 +140,11 @@ class SegmentDeletes {
}
public void addQuery(Query query, int docIDUpto) {
- queries.put(query, docIDUpto);
- bytesUsed.addAndGet(BYTES_PER_DEL_QUERY);
+ Integer current = queries.put(query, docIDUpto);
+ // increment bytes used only if the query wasn't added so far.
+ if (current == null) {
+ bytesUsed.addAndGet(BYTES_PER_DEL_QUERY);
+ }
}
public void addDocID(int docID) {