Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Index / SegmentMergeInfo.cs
blob9c304e39144dd770af3f7fcd9bccef00ff2aa6a6
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 using System;
17 namespace Lucene.Net.Index
20 sealed class SegmentMergeInfo
22 internal Term term;
23 internal int base_Renamed;
24 internal TermEnum termEnum;
25 internal IndexReader reader;
26 internal TermPositions postings;
27 internal int[] docMap = null; // maps around deleted docs
29 internal SegmentMergeInfo(int b, TermEnum te, IndexReader r)
31 base_Renamed = b;
32 reader = r;
33 termEnum = te;
34 term = te.Term();
35 postings = reader.TermPositions();
37 // build array which maps document numbers around deletions
38 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++)
45 if (reader.IsDeleted(i))
46 docMap[i] = - 1;
47 else
48 docMap[i] = j++;
53 internal bool Next()
55 if (termEnum.Next())
57 term = termEnum.Term();
58 return true;
60 else
62 term = null;
63 return false;
67 internal void Close()
69 termEnum.Close();
70 postings.Close();