1 package org.apache.lucene.index; 2 3 18 19 import java.io.IOException ; 20 21 final class SegmentMergeInfo { 22 Term term; 23 int base; 24 TermEnum termEnum; 25 IndexReader reader; 26 private TermPositions postings; private int[] docMap; 29 SegmentMergeInfo(int b, TermEnum te, IndexReader r) 30 throws IOException { 31 base = b; 32 reader = r; 33 termEnum = te; 34 term = te.term(); 35 } 36 37 int[] getDocMap() { 39 if (docMap == null) { 40 if (reader.hasDeletions()) { 42 int maxDoc = reader.maxDoc(); 43 docMap = new int[maxDoc]; 44 int j = 0; 45 for (int i = 0; i < maxDoc; i++) { 46 if (reader.isDeleted(i)) 47 docMap[i] = -1; 48 else 49 docMap[i] = j++; 50 } 51 } 52 } 53 return docMap; 54 } 55 56 TermPositions getPositions() throws IOException { 57 if (postings == null) { 58 postings = reader.termPositions(); 59 } 60 return postings; 61 } 62 63 final boolean next() throws IOException { 64 if (termEnum.next()) { 65 term = termEnum.term(); 66 return true; 67 } else { 68 term = null; 69 return false; 70 } 71 } 72 73 final void close() throws IOException { 74 termEnum.close(); 75 if (postings != null) { 76 postings.close(); 77 } 78 } 79 } 80 81 | Popular Tags |