Initial revision
[beagle.git] / Lucene.Net / Index / SegmentMergeInfo.cs
blobbea8d5c33879e3b24cced5a5409a9e4fec95fe7d
1 using Lucene.Net.Util;
3 namespace Lucene.Net.Index
5 /* ====================================================================
6 * The Apache Software License, Version 1.1
8 * Copyright (c) 2001 The Apache Software Foundation. All rights
9 * reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided with the
21 * distribution.
23 * 3. The end-user documentation included with the redistribution,
24 * if any, must include the following acknowledgment:
25 * "This product includes software developed by the
26 * Apache Software Foundation (http://www.apache.org/)."
27 * Alternately, this acknowledgment may appear in the software itself,
28 * if and wherever such third-party acknowledgments normally appear.
30 * 4. The names "Apache" and "Apache Software Foundation" and
31 * "Apache Lucene" must not be used to endorse or promote products
32 * derived from this software without prior written permission. For
33 * written permission, please contact apache@apache.org.
35 * 5. Products derived from this software may not be called "Apache",
36 * "Apache Lucene", nor may "Apache" appear in their name, without
37 * prior written permission of the Apache Software Foundation.
39 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 * ====================================================================
53 * This software consists of voluntary contributions made by many
54 * individuals on behalf of the Apache Software Foundation. For more
55 * information on the Apache Software Foundation, please see
56 * <http://www.apache.org/>.
59 sealed class SegmentMergeInfo
61 internal Term term;
62 internal int _base;
63 internal TermEnum termEnum;
64 internal IndexReader reader;
65 internal TermPositions postings;
66 internal int[] docMap = null; // maps around deleted docs
68 internal SegmentMergeInfo(int b, TermEnum te, IndexReader r)
70 _base = b;
71 reader = r;
72 termEnum = te;
73 term = te.Term();
74 postings = reader.TermPositions();
76 if (reader.HasDeletions())
78 // build array which maps document numbers around deletions
79 int maxDoc = reader.MaxDoc();
80 docMap = new int[maxDoc];
81 int j = 0;
82 for (int i = 0; i < maxDoc; i++)
84 if (reader.IsDeleted(i))
85 docMap[i] = -1;
86 else
87 docMap[i] = j++;
92 internal bool Next()
94 if (termEnum.Next())
96 term = termEnum.Term();
97 return true;
99 else
101 term = null;
102 return false;
106 internal void Close()
108 termEnum.Close();
109 postings.Close();