01 package gate.creole.annic.apache.lucene.index;
02
03 /**
04 * Copyright 2004 The Apache Software Foundation
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 import java.io.IOException;
20 import gate.creole.annic.apache.lucene.util.BitVector;
21
22 final class SegmentMergeInfo {
23 Term term;
24 int base;
25 TermEnum termEnum;
26 IndexReader reader;
27 TermPositions postings;
28 int[] docMap = null; // maps around deleted docs
29
30 SegmentMergeInfo(int b, TermEnum te, IndexReader r)
31 throws IOException {
32 base = b;
33 reader = r;
34 termEnum = te;
35 term = te.term();
36 postings = reader.termPositions();
37
38 // build array which maps document numbers around deletions
39 if (reader.hasDeletions()) {
40 int maxDoc = reader.maxDoc();
41 docMap = new int[maxDoc];
42 int j = 0;
43 for (int i = 0; i < maxDoc; i++) {
44 if (reader.isDeleted(i))
45 docMap[i] = -1;
46 else
47 docMap[i] = j++;
48 }
49 }
50 }
51
52 final boolean next() throws IOException {
53 if (termEnum.next()) {
54 term = termEnum.term();
55 return true;
56 } else {
57 term = null;
58 return false;
59 }
60 }
61
62 final void close() throws IOException {
63 termEnum.close();
64 postings.close();
65 }
66 }
|