19 using System.Collections.Generic;
20 using Lucene.Net.Support;
23 namespace Lucene.Net.Index
32 private void InitBlock()
34 docFreeList =
new PerDoc[1];
46 internal override void SetFieldInfos(
FieldInfos fieldInfos)
48 base.SetFieldInfos(fieldInfos);
49 one.SetFieldInfos(fieldInfos);
50 two.SetFieldInfos(fieldInfos);
56 var oneThreadsAndFields =
new HashMap<DocFieldConsumerPerThread, ICollection<DocFieldConsumerPerField>>();
57 var twoThreadsAndFields =
new HashMap<DocFieldConsumerPerThread, ICollection<DocFieldConsumerPerField>>();
59 foreach(var entry
in threadsAndFields)
62 ICollection<DocFieldConsumerPerField> fields = entry.Value;
64 IEnumerator<DocFieldConsumerPerField> fieldsIt = fields.GetEnumerator();
65 ICollection<DocFieldConsumerPerField> oneFields =
new HashSet<DocFieldConsumerPerField>();
66 ICollection<DocFieldConsumerPerField> twoFields =
new HashSet<DocFieldConsumerPerField>();
67 while (fieldsIt.MoveNext())
70 oneFields.Add(perField.one);
71 twoFields.Add(perField.two);
74 oneThreadsAndFields[perThread.one] = oneFields;
75 twoThreadsAndFields[perThread.two] = twoFields;
79 one.Flush(oneThreadsAndFields, state);
80 two.Flush(twoThreadsAndFields, state);
87 one.CloseDocStore(state);
91 two.CloseDocStore(state);
95 public override void Abort()
107 public override bool FreeRAM()
109 bool any = one.FreeRAM();
110 any |= two.FreeRAM();
116 return new DocFieldConsumersPerThread(docFieldProcessorPerThread,
this, one.AddThread(docFieldProcessorPerThread), two.AddThread(docFieldProcessorPerThread));
119 internal PerDoc[] docFreeList;
120 internal int freeCount;
121 internal int allocCount;
123 internal PerDoc GetPerDoc()
130 if (allocCount > docFreeList.Length)
135 System.Diagnostics.Debug.Assert(allocCount == 1 + docFreeList.Length);
136 docFreeList =
new PerDoc[
ArrayUtil.GetNextSize(allocCount)];
138 return new PerDoc(
this);
141 return docFreeList[--freeCount];
145 internal void FreePerDoc(PerDoc perDoc)
149 System.Diagnostics.Debug.Assert(freeCount < docFreeList.Length);
150 docFreeList[freeCount++] = perDoc;
154 internal class PerDoc:DocumentsWriter.DocWriter
156 public PerDoc(DocFieldConsumers enclosingInstance)
158 InitBlock(enclosingInstance);
160 private void InitBlock(DocFieldConsumers enclosingInstance)
162 this.enclosingInstance = enclosingInstance;
164 private DocFieldConsumers enclosingInstance;
165 public DocFieldConsumers Enclosing_Instance
169 return enclosingInstance;
174 internal DocumentsWriter.DocWriter one;
175 internal DocumentsWriter.DocWriter two;
177 public override long SizeInBytes()
179 return one.SizeInBytes() + two.SizeInBytes();
182 public override void Finish()
197 Enclosing_Instance.FreePerDoc(
this);
201 public override void Abort()
216 Enclosing_Instance.FreePerDoc(
this);