From 047d76bf6aac1fec9a30396a566b1e36f49451ce Mon Sep 17 00:00:00 2001 From: Shai Erera Date: Mon, 24 Jan 2011 15:35:55 +0000 Subject: [PATCH] LUCENE-2693: Add delete term and query need to more precisely record the bytes used (trunk) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1062832 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ .../src/java/org/apache/lucene/index/SegmentDeletes.java | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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) {