Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
DocInverter.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.Collections.Generic;
19 using Lucene.Net.Support;
20 
21 namespace Lucene.Net.Index
22 {
23 
28 
30  {
31 
32  internal InvertedDocConsumer consumer;
33  internal InvertedDocEndConsumer endConsumer;
34 
36  {
37  this.consumer = consumer;
38  this.endConsumer = endConsumer;
39  }
40 
41  internal override void SetFieldInfos(FieldInfos fieldInfos)
42  {
43  base.SetFieldInfos(fieldInfos);
44  consumer.SetFieldInfos(fieldInfos);
45  endConsumer.SetFieldInfos(fieldInfos);
46  }
47 
48  public override void Flush(IDictionary<DocFieldConsumerPerThread, ICollection<DocFieldConsumerPerField>> threadsAndFields, SegmentWriteState state)
49  {
50 
51  var childThreadsAndFields = new HashMap<InvertedDocConsumerPerThread, ICollection<InvertedDocConsumerPerField>>();
52  var endChildThreadsAndFields = new HashMap<InvertedDocEndConsumerPerThread, ICollection<InvertedDocEndConsumerPerField>>();
53 
54  foreach (var entry in threadsAndFields)
55  {
56  var perThread = (DocInverterPerThread) entry.Key;
57 
58  ICollection<InvertedDocConsumerPerField> childFields = new HashSet<InvertedDocConsumerPerField>();
59  ICollection<InvertedDocEndConsumerPerField> endChildFields = new HashSet<InvertedDocEndConsumerPerField>();
60  foreach(DocFieldConsumerPerField field in entry.Value)
61  {
62  var perField = (DocInverterPerField)field;
63  childFields.Add(perField.consumer);
64  endChildFields.Add(perField.endConsumer);
65  }
66 
67  childThreadsAndFields[perThread.consumer] = childFields;
68  endChildThreadsAndFields[perThread.endConsumer] = endChildFields;
69  }
70 
71  consumer.Flush(childThreadsAndFields, state);
72  endConsumer.Flush(endChildThreadsAndFields, state);
73  }
74 
75  public override void CloseDocStore(SegmentWriteState state)
76  {
77  consumer.CloseDocStore(state);
78  endConsumer.CloseDocStore(state);
79  }
80 
81  public override void Abort()
82  {
83  consumer.Abort();
84  endConsumer.Abort();
85  }
86 
87  public override bool FreeRAM()
88  {
89  return consumer.FreeRAM();
90  }
91 
92  public override DocFieldConsumerPerThread AddThread(DocFieldProcessorPerThread docFieldProcessorPerThread)
93  {
94  return new DocInverterPerThread(docFieldProcessorPerThread, this);
95  }
96  }
97 }