lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r635863 - in /lucene/java/branches/lucene_2_3: CHANGES.txt src/java/org/apache/lucene/index/DocumentsWriter.java
Date Tue, 11 Mar 2008 10:03:04 GMT
Author: mikemccand
Date: Tue Mar 11 03:02:42 2008
New Revision: 635863

URL: http://svn.apache.org/viewvc?rev=635863&view=rev
Log:
LUCENE-1197 (porting to 2.3): fix IndexWriter to not flush by RAM too early when TermVectors
are in use

Modified:
    lucene/java/branches/lucene_2_3/CHANGES.txt
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java

Modified: lucene/java/branches/lucene_2_3/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/CHANGES.txt?rev=635863&r1=635862&r2=635863&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_3/CHANGES.txt Tue Mar 11 03:02:42 2008
@@ -7,6 +7,9 @@
     methods in IndexWriter, do not commit any further changes to the
     index to prevent risk of possible corruption.  (Mike McCandless)
 
+ 2. LUCENE-1197: Fixed issue whereby IndexWriter would flush by RAM
+    too early when TermVectors were in use.  (Mike McCandless)
+
 ======================= Release 2.3.1 2008-02-22 =======================
 
 Bug fixes

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=635863&r1=635862&r2=635863&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
(original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
Tue Mar 11 03:02:42 2008
@@ -1123,8 +1123,8 @@
         balanceRAM();
     }
 
-    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
@@ -2884,6 +2884,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
@@ -2913,7 +2919,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;
@@ -3075,7 +3081,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) {
@@ -3084,7 +3090,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;
   }
 



Mime
View raw message