18 using System.Collections.Generic;
19 using Lucene.Net.Search;
20 using Lucene.Net.Support;
22 namespace Lucene.Net.Index
35 internal int numTerms;
36 internal IDictionary<Term,Num> terms = null;
37 internal IDictionary<Query, int> queries =
new HashMap<Query, int>();
38 internal List<int> docIDs =
new List<int>();
39 internal long bytesUsed;
40 internal bool doTermSort;
44 this.doTermSort = doTermSort;
48 terms =
new SortedDictionary<Term, Num>();
52 terms =
new HashMap<Term, Num>();
58 internal sealed
class Num
72 internal void SetNum(
int num)
85 internal virtual int Size()
91 return numTerms + queries.Count + docIDs.Count;
94 internal virtual void Update(BufferedDeletes @in)
96 numTerms += @in.numTerms;
97 bytesUsed += @in.bytesUsed;
98 foreach (KeyValuePair<Term, Num> term
in @in.terms)
100 terms[term.Key] = term.Value;
102 foreach (KeyValuePair<Query, int> term
in @in.queries)
104 queries[term.Key] = term.Value;
107 docIDs.AddRange(@in.docIDs);
111 internal virtual void Clear()
120 internal virtual void AddBytesUsed(
long b)
125 internal virtual bool Any()
127 return terms.Count > 0 || docIDs.Count > 0 || queries.Count > 0;
132 internal virtual void Remap(MergeDocIDRemapper mapper, SegmentInfos infos,
int[][] docMaps,
int[] delCounts, MergePolicy.OneMerge merge,
int mergeDocCount)
136 IDictionary<Term, Num> newDeleteTerms;
143 newDeleteTerms =
new SortedDictionary<Term, Num>();
147 newDeleteTerms =
new HashMap<Term, Num>();
149 foreach(var entry
in terms)
151 Num num = entry.Value;
152 newDeleteTerms[entry.Key] =
new Num(mapper.Remap(num.GetNum()));
156 newDeleteTerms = null;
159 List<int> newDeleteDocIDs;
161 if (docIDs.Count > 0)
163 newDeleteDocIDs =
new List<int>(docIDs.Count);
164 foreach(
int num
in docIDs)
166 newDeleteDocIDs.Add(mapper.Remap(num));
170 newDeleteDocIDs = null;
173 HashMap<Query, int> newDeleteQueries;
175 if (queries.Count > 0)
177 newDeleteQueries =
new HashMap<Query, int>(queries.Count);
178 foreach(var entry
in queries)
180 int num = entry.Value;
181 newDeleteQueries[entry.Key] = mapper.Remap(num);
185 newDeleteQueries = null;
187 if (newDeleteTerms != null)
188 terms = newDeleteTerms;
189 if (newDeleteDocIDs != null)
190 docIDs = newDeleteDocIDs;
191 if (newDeleteQueries != null)
192 queries = newDeleteQueries;