Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
FormatPostingsFieldsWriter.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 
20 using Directory = Lucene.Net.Store.Directory;
21 
22 namespace Lucene.Net.Index
23 {
24 
26  {
27 
28  internal Directory dir;
29  internal System.String segment;
30  internal TermInfosWriter termsOut;
31  internal FieldInfos fieldInfos;
32  internal FormatPostingsTermsWriter termsWriter;
33  internal DefaultSkipListWriter skipListWriter;
34  internal int totalNumDocs;
35 
36  public FormatPostingsFieldsWriter(SegmentWriteState state, FieldInfos fieldInfos):base()
37  {
38 
39  dir = state.directory;
40  segment = state.segmentName;
41  totalNumDocs = state.numDocs;
42  this.fieldInfos = fieldInfos;
43  termsOut = new TermInfosWriter(dir, segment, fieldInfos, state.termIndexInterval);
44 
45  // TODO: this is a nasty abstraction violation (that we
46  // peek down to find freqOut/proxOut) -- we need a
47  // better abstraction here whereby these child consumers
48  // can provide skip data or not
49  skipListWriter = new DefaultSkipListWriter(termsOut.skipInterval, termsOut.maxSkipLevels, totalNumDocs, null, null);
50 
51  state.flushedFiles.Add(state.SegmentFileName(IndexFileNames.TERMS_EXTENSION));
52  state.flushedFiles.Add(state.SegmentFileName(IndexFileNames.TERMS_INDEX_EXTENSION));
53 
54  termsWriter = new FormatPostingsTermsWriter(state, this);
55  }
56 
57  /// <summary>Add a new field </summary>
58  internal override FormatPostingsTermsConsumer AddField(FieldInfo field)
59  {
60  termsWriter.SetField(field);
61  return termsWriter;
62  }
63 
64  /// <summary>Called when we are done adding everything. </summary>
65  internal override void Finish()
66  {
67  termsOut.Dispose();
68  termsWriter.Dispose();
69  }
70  }
71 }