Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 38369 invoked from network); 29 Feb 2008 12:43:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Feb 2008 12:43:13 -0000 Received: (qmail 28612 invoked by uid 500); 29 Feb 2008 12:43:09 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 28590 invoked by uid 500); 29 Feb 2008 12:43:08 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 28579 invoked by uid 99); 29 Feb 2008 12:43:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Feb 2008 04:43:08 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Feb 2008 12:42:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6ED281A9832; Fri, 29 Feb 2008 04:42:52 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r632306 - /lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Date: Fri, 29 Feb 2008 12:42:51 -0000 To: java-commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080229124252.6ED281A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikemccand Date: Fri Feb 29 04:42:47 2008 New Revision: 632306 URL: http://svn.apache.org/viewvc?rev=632306&view=rev Log: LUCENE-1197: fix DocumentsWriter to not overcount RAM usage when term vectors are on Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Modified: lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=632306&r1=632305&r2=632306&view=diff ============================================================================== --- lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java (original) +++ lucene/java/trunk/src/java/org/apache/lucene/index/DocumentsWriter.java Fri Feb 29 04:42:47 2008 @@ -1172,8 +1172,8 @@ infoStream.println("WARNING: document contains at least one immense term (longer than the max length " + MAX_TERM_LENGTH + "), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '" + maxTermPrefix + "...'"); } - final ByteBlockPool postingsPool = new ByteBlockPool(); - final ByteBlockPool vectorsPool = new ByteBlockPool(); + final ByteBlockPool postingsPool = new ByteBlockPool(true); + final ByteBlockPool vectorsPool = new ByteBlockPool(false); final CharBlockPool charPool = new CharBlockPool(); // Current posting we are working on @@ -2957,6 +2957,12 @@ public byte[] buffer; // Current head buffer public int byteOffset = -BYTE_BLOCK_SIZE; // Current head offset + private boolean trackAllocations; + + public ByteBlockPool(boolean trackAllocations) { + this.trackAllocations = trackAllocations; + } + public void reset() { if (bufferUpto != -1) { // We allocated at least one buffer @@ -2986,7 +2992,7 @@ System.arraycopy(buffers, 0, newBuffers, 0, buffers.length); buffers = newBuffers; } - buffer = buffers[1+bufferUpto] = getByteBlock(); + buffer = buffers[1+bufferUpto] = getByteBlock(trackAllocations); bufferUpto++; byteUpto = 0; @@ -3148,7 +3154,7 @@ private ArrayList freeByteBlocks = new ArrayList(); /* Allocate another byte[] from the shared pool */ - synchronized byte[] getByteBlock() { + synchronized byte[] getByteBlock(boolean trackAllocations) { final int size = freeByteBlocks.size(); final byte[] b; if (0 == size) { @@ -3157,7 +3163,8 @@ b = new byte[BYTE_BLOCK_SIZE]; } else b = (byte[]) freeByteBlocks.remove(size-1); - numBytesUsed += BYTE_BLOCK_SIZE; + if (trackAllocations) + numBytesUsed += BYTE_BLOCK_SIZE; return b; }