Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-3222: don't under count RAM required for deleted terms

Michael McCandlessa2f08bfb9b4e
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 433da6d0543..6105f6ad85e 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -544,6 +544,10 @@ Bug fixes
background optimize when documents are still being deleted
concurrently with the optimize (Mike McCandless)
+* LUCENE-3222: The RAM accounting for buffered delete terms was
+ failing to measure the space required to hold the term's field and
+ text character data. (Mike McCandless)
+
API Changes
* LUCENE-3208: Renamed protected IndexSearcher.createWeight() to expert
diff --git a/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java b/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java
index c54053c9f04..3849fb41e98 100644
--- a/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java
+++ b/lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java
@@ -32,12 +32,12 @@ import org.apache.lucene.index.BufferedDeletesStream.QueryAndLimit;
class FrozenBufferedDeletes {
/* Rough logic: Term is object w/
- String field and String text (OBJ_HEADER + 2*POINTER).
- Term's text is String (OBJ_HEADER + 4*INT + POINTER +
- OBJ_HEADER + text.length*CHAR).
- Term's field is String (OBJ_HEADER + 4*INT + POINTER +
- OBJ_HEADER + field.length*CHAR). */
- final static int BYTES_PER_DEL_TERM = 4*RamUsageEstimator.NUM_BYTES_OBJECT_REF + 4*RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 8*RamUsageEstimator.NUM_BYTES_INT;
+ String field and BytesRef text (OBJ_HEADER + 2*POINTER).
+ String field is (OBJ_HEADER + 4*INT +
+ POINTER + OBJ_HEADER + CHAR*field.length).
+ Term's text is BytesRef (OBJ_HEADER + 2*INT + POINTER +
+ OBJ_HEADER + bytes.length). */
+ final static int BYTES_PER_DEL_TERM = 4*RamUsageEstimator.NUM_BYTES_OBJECT_REF + 5*RamUsageEstimator.NUM_BYTES_OBJECT_HEADER + 6*RamUsageEstimator.NUM_BYTES_INT;
/* Query we often undercount (say 24 bytes), plus int. */
final static int BYTES_PER_DEL_QUERY = RamUsageEstimator.NUM_BYTES_OBJECT_REF + RamUsageEstimator.NUM_BYTES_INT + 24;
@@ -71,7 +71,13 @@ class FrozenBufferedDeletes {
queryLimits[upto] = ent.getValue();
upto++;
}
- bytesUsed = terms.length * BYTES_PER_DEL_TERM + queries.length * BYTES_PER_DEL_QUERY;
+ int termDataBytes = 0;
+ for(Map.Entry<Term,Integer> ent : deletes.terms.entrySet()) {
+ final Term term = ent.getKey();
+ termDataBytes += term.bytes().length;
+ termDataBytes += term.field().length() * RamUsageEstimator.NUM_BYTES_CHAR;
+ }
+ bytesUsed = terms.length * BYTES_PER_DEL_TERM + queries.length * BYTES_PER_DEL_QUERY + termDataBytes;
numTermDeletes = deletes.numTermDeletes.get();
}