lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r329068 - in /lucene/java/trunk/src/java/org/apache/lucene/index: SegmentMergeInfo.java SegmentMerger.java
Date Fri, 28 Oct 2005 03:44:05 GMT
Author: yonik
Date: Thu Oct 27 20:44:00 2005
New Revision: 329068

URL: http://svn.apache.org/viewcvs?rev=329068&view=rev
Log:
speedup by deferring docMap and postings until needed - LUCENE-454

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMergeInfo.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMerger.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMergeInfo.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMergeInfo.java?rev=329068&r1=329067&r2=329068&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMergeInfo.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMergeInfo.java Thu Oct 27 20:44:00
2005
@@ -23,8 +23,8 @@
   int base;
   TermEnum termEnum;
   IndexReader reader;
-  TermPositions postings;
-  int[] docMap = null;				  // maps around deleted docs
+  private TermPositions postings;  // use getPositions()
+  private int[] docMap;  // use getDocMap()
 
   SegmentMergeInfo(int b, TermEnum te, IndexReader r)
     throws IOException {
@@ -32,8 +32,11 @@
     reader = r;
     termEnum = te;
     term = te.term();
-    postings = reader.termPositions();
+  }
 
+  // maps around deleted docs
+  int[] getDocMap() {
+    if (docMap == null) {
     // build array which maps document numbers around deletions 
     if (reader.hasDeletions()) {
       int maxDoc = reader.maxDoc();
@@ -47,6 +50,15 @@
       }
     }
   }
+    return docMap;
+  }
+
+  TermPositions getPositions() throws IOException {
+    if (postings == null) {
+      postings = reader.termPositions();
+    }
+    return postings;
+  }
 
   final boolean next() throws IOException {
     if (termEnum.next()) {
@@ -60,7 +72,9 @@
 
   final void close() throws IOException {
     termEnum.close();
+    if (postings != null) {
     postings.close();
   }
+}
 }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMerger.java?rev=329068&r1=329067&r2=329068&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentMerger.java Thu Oct 27 20:44:00
2005
@@ -311,9 +311,9 @@
     resetSkip();
     for (int i = 0; i < n; i++) {
       SegmentMergeInfo smi = smis[i];
-      TermPositions postings = smi.postings;
+      TermPositions postings = smi.getPositions();
       int base = smi.base;
-      int[] docMap = smi.docMap;
+      int[] docMap = smi.getDocMap();
       postings.seek(smi.termEnum);
       while (postings.next()) {
         int doc = postings.doc();



Mime
View raw message