Index: lucene/CHANGES.txt =================================================================== --- lucene/CHANGES.txt (revision 1138058) +++ lucene/CHANGES.txt (working copy) @@ -536,6 +536,10 @@ 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 Index: lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java =================================================================== --- lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java (revision 1138058) +++ lucene/src/java/org/apache/lucene/index/FrozenBufferedDeletes.java (working copy) @@ -32,12 +32,12 @@ 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 @@ queryLimits[upto] = ent.getValue(); upto++; } - bytesUsed = terms.length * BYTES_PER_DEL_TERM + queries.length * BYTES_PER_DEL_QUERY; + int termDataBytes = 0; + for(Map.Entry 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(); }