19 using Lucene.Net.Support;
21 namespace Lucene.Net.Index
32 internal int[] starts;
33 internal int[] newStarts;
34 internal int[][] docMaps;
35 internal int minDocID;
36 internal int maxDocID;
37 internal int docShift;
41 this.docMaps = docMaps;
47 if (info.
Equals(firstSegment))
54 for (
int j = 0; j < docMaps.Length; i++, j++)
57 System.Diagnostics.Debug.Assert(infos.
Info(i).
Equals(merge.segments.Info(j)));
59 maxDocID = minDocID + numDocs;
61 starts =
new int[docMaps.Length];
62 newStarts =
new int[docMaps.Length];
65 newStarts[0] = minDocID;
66 for (i = 1; i < docMaps.Length; i++)
68 int lastDocCount = merge.segments.Info(i - 1).docCount;
69 starts[i] = starts[i - 1] + lastDocCount;
70 newStarts[i] = newStarts[i - 1] + lastDocCount - delCounts[i - 1];
72 docShift = numDocs - mergedDocCount;
82 System.Diagnostics.Debug.Assert(docShift == maxDocID -(newStarts [docMaps.Length - 1] + merge.segments.Info(docMaps.Length - 1).docCount - delCounts [docMaps.Length - 1]));
85 public int Remap(
int oldDocID)
87 if (oldDocID < minDocID)
90 else if (oldDocID >= maxDocID)
92 return oldDocID - docShift;
97 int hi = docMaps.Length - 1;
102 int midValue = starts[mid];
103 if (oldDocID < midValue)
105 else if (oldDocID > midValue)
110 while (mid + 1 < docMaps.Length && starts[mid + 1] == midValue)
114 if (docMaps[mid] != null)
115 return newStarts[mid] + docMaps[mid][oldDocID - starts[mid]];
117 return newStarts[mid] + oldDocID - starts[mid];
120 if (docMaps[hi] != null)
121 return newStarts[hi] + docMaps[hi][oldDocID - starts[hi]];
123 return newStarts[hi] + oldDocID - starts[hi];