23 namespace Lucene.Net.Index
52 private int numberOfSkipLevels;
55 private int skipInterval;
62 this.skipInterval = skipInterval;
65 numberOfSkipLevels = df == 0?0:(int) System.Math.Floor(System.Math.Log(df) / System.Math.Log(skipInterval));
68 if (numberOfSkipLevels > maxSkipLevels)
70 numberOfSkipLevels = maxSkipLevels;
74 protected internal virtual void Init()
77 for (
int i = 0; i < numberOfSkipLevels; i++)
83 protected internal virtual void ResetSkip()
86 if (skipBuffer == null)
92 for (
int i = 0; i < skipBuffer.Length; i++)
94 skipBuffer[i].Reset();
106 protected internal abstract void WriteSkipData(
int level,
IndexOutput skipBuffer);
115 internal virtual void BufferSkip(
int df)
120 for (numLevels = 0; (df % skipInterval) == 0 && numLevels < numberOfSkipLevels; df /= skipInterval)
125 long childPointer = 0;
127 for (
int level = 0; level < numLevels; level++)
129 WriteSkipData(level, skipBuffer[level]);
131 long newChildPointer = skipBuffer[level].FilePointer;
136 skipBuffer[level].WriteVLong(childPointer);
140 childPointer = newChildPointer;
151 internal virtual long WriteSkip(
IndexOutput output)
153 long skipPointer = output.FilePointer;
154 if (skipBuffer == null || skipBuffer.Length == 0)
157 for (
int level = numberOfSkipLevels - 1; level > 0; level--)
159 long length = skipBuffer[level].FilePointer;
162 output.WriteVLong(length);
163 skipBuffer[level].WriteTo(output);
166 skipBuffer[0].WriteTo(output);