http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Fst/IntSequenceOutputs.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Fst/IntSequenceOutputs.cs b/src/Lucene.Net.Core/Util/Fst/IntSequenceOutputs.cs index a031d83..0db64a6 100644 --- a/src/Lucene.Net.Core/Util/Fst/IntSequenceOutputs.cs +++ b/src/Lucene.Net.Core/Util/Fst/IntSequenceOutputs.cs @@ -56,7 +56,7 @@ namespace Lucene.Net.Util.Fst int stopAt1 = pos1 + Math.Min(output1.Length, output2.Length); while (pos1 < stopAt1) { - if (output1.Ints[pos1] != output2.Ints[pos2]) + if (output1.Int32s[pos1] != output2.Int32s[pos2]) { break; } @@ -81,7 +81,7 @@ namespace Lucene.Net.Util.Fst } else { - return new IntsRef(output1.Ints, output1.Offset, pos1 - output1.Offset); + return new IntsRef(output1.Int32s, output1.Offset, pos1 - output1.Offset); } } @@ -103,7 +103,7 @@ namespace Lucene.Net.Util.Fst { Debug.Assert(inc.Length < output.Length, "inc.length=" + inc.Length + " vs output.length=" + output.Length); Debug.Assert(inc.Length > 0); - return new IntsRef(output.Ints, output.Offset + inc.Length, output.Length - inc.Length); + return new IntsRef(output.Int32s, output.Offset + inc.Length, output.Length - inc.Length); } } @@ -124,8 +124,8 @@ namespace Lucene.Net.Util.Fst Debug.Assert(prefix.Length > 0); Debug.Assert(output.Length > 0); IntsRef result = new IntsRef(prefix.Length + output.Length); - Array.Copy(prefix.Ints, prefix.Offset, result.Ints, 0, prefix.Length); - Array.Copy(output.Ints, output.Offset, result.Ints, prefix.Length, output.Length); + Array.Copy(prefix.Int32s, prefix.Offset, result.Int32s, 0, prefix.Length); + Array.Copy(output.Int32s, output.Offset, result.Int32s, prefix.Length, output.Length); result.Length = prefix.Length + output.Length; return result; } @@ -134,16 +134,16 @@ namespace Lucene.Net.Util.Fst public override void Write(IntsRef prefix, DataOutput @out) { Debug.Assert(prefix != null); - @out.WriteVInt(prefix.Length); + @out.WriteVInt32(prefix.Length); for (int idx = 0; idx < prefix.Length; idx++) { - @out.WriteVInt(prefix.Ints[prefix.Offset + idx]); + @out.WriteVInt32(prefix.Int32s[prefix.Offset + idx]); } } public override IntsRef Read(DataInput @in) { - int len = @in.ReadVInt(); + int len = @in.ReadVInt32(); if (len == 0) { return NO_OUTPUT; @@ -153,7 +153,7 @@ namespace Lucene.Net.Util.Fst IntsRef output = new IntsRef(len); for (int idx = 0; idx < len; idx++) { - output.Ints[idx] = @in.ReadVInt(); + output.Int32s[idx] = @in.ReadVInt32(); } output.Length = len; return output;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs b/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs index 2f2edd9..fba0afb 100644 --- a/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs +++ b/src/Lucene.Net.Core/Util/Fst/IntsRefFSTEnum.cs @@ -108,7 +108,7 @@ namespace Lucene.Net.Util.Fst } else { - return target.Ints[target.Offset + m_upto - 1]; + return target.Int32s[target.Offset + m_upto - 1]; } } } @@ -118,17 +118,17 @@ namespace Lucene.Net.Util.Fst get { // current.offset fixed at 1 - return current.Ints[m_upto]; + return current.Int32s[m_upto]; } set { - current.Ints[m_upto] = value; + current.Int32s[m_upto] = value; } } protected override void Grow() { - current.Ints = ArrayUtil.Grow(current.Ints, m_upto + 1); + current.Int32s = ArrayUtil.Grow(current.Int32s, m_upto + 1); } private IntsRefFSTEnum.InputOutput<T> SetResult() http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Fst/PositiveIntOutputs.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Fst/PositiveIntOutputs.cs b/src/Lucene.Net.Core/Util/Fst/PositiveIntOutputs.cs index f06ece2..3713f83 100644 --- a/src/Lucene.Net.Core/Util/Fst/PositiveIntOutputs.cs +++ b/src/Lucene.Net.Core/Util/Fst/PositiveIntOutputs.cs @@ -104,12 +104,12 @@ namespace Lucene.Net.Util.Fst public override void Write(long? output, DataOutput @out) { Debug.Assert(Valid(output)); - @out.WriteVLong(output.Value); + @out.WriteVInt64(output.Value); } public override long? Read(DataInput @in) { - long v = @in.ReadVLong(); + long v = @in.ReadVInt64(); if (v == 0) { return NO_OUTPUT; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Fst/Util.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Fst/Util.cs b/src/Lucene.Net.Core/Util/Fst/Util.cs index ad7d2cb..e3329c2 100644 --- a/src/Lucene.Net.Core/Util/Fst/Util.cs +++ b/src/Lucene.Net.Core/Util/Fst/Util.cs @@ -50,7 +50,7 @@ namespace Lucene.Net.Util.Fst T output = fst.Outputs.NoOutput; for (int i = 0; i < input.Length; i++) { - if (fst.FindTargetArc(input.Ints[input.Offset + i], arc, arc, fstReader) == null) + if (fst.FindTargetArc(input.Int32s[input.Offset + i], arc, arc, fstReader) == null) { return default(T); } @@ -165,7 +165,7 @@ namespace Lucene.Net.Util.Fst if (FST<long?>.TargetHasArcs(arc)) { //System.out.println(" targetHasArcs"); - if (result.Ints.Length == upto) + if (result.Int32s.Length == upto) { result.Grow(1 + upto); } @@ -225,7 +225,7 @@ namespace Lucene.Net.Util.Fst } fst.ReadNextRealArc(arc, @in); - result.Ints[upto++] = arc.Label; + result.Int32s[upto++] = arc.Label; output += arc.Output.Value; } else @@ -245,7 +245,7 @@ namespace Lucene.Net.Util.Fst // Recurse on this arc: //System.out.println(" match! break"); output = minArcOutput; - result.Ints[upto++] = arc.Label; + result.Int32s[upto++] = arc.Label; break; } else if (minArcOutput > targetOutput) @@ -259,7 +259,7 @@ namespace Lucene.Net.Util.Fst { // Recurse on previous arc: arc.CopyFrom(prevArc); - result.Ints[upto++] = arc.Label; + result.Int32s[upto++] = arc.Label; output += arc.Output.Value; //System.out.println(" recurse prev label=" + (char) arc.label + " output=" + output); break; @@ -270,7 +270,7 @@ namespace Lucene.Net.Util.Fst // Recurse on this arc: output = minArcOutput; //System.out.println(" recurse last label=" + (char) arc.label + " output=" + output); - result.Ints[upto++] = arc.Label; + result.Int32s[upto++] = arc.Label; break; } else @@ -402,7 +402,7 @@ namespace Lucene.Net.Util.Fst { // Tie break by alpha sort on the input: path.Input.Grow(path.Input.Length + 1); - path.Input.Ints[path.Input.Length++] = path.Arc.Label; + path.Input.Int32s[path.Input.Length++] = path.Arc.Label; int cmp = bottom.Input.CompareTo(path.Input); path.Input.Length--; @@ -425,8 +425,8 @@ namespace Lucene.Net.Util.Fst // copy over the current input to the new input // and add the arc.label to the end IntsRef newInput = new IntsRef(path.Input.Length + 1); - Array.Copy(path.Input.Ints, 0, newInput.Ints, 0, path.Input.Length); - newInput.Ints[path.Input.Length] = path.Arc.Label; + Array.Copy(path.Input.Int32s, 0, newInput.Int32s, 0, path.Input.Length); + newInput.Int32s[path.Input.Length] = path.Arc.Label; newInput.Length = path.Input.Length + 1; FSTPath<T> newPath = new FSTPath<T>(cost, path.Arc, newInput); @@ -625,7 +625,7 @@ namespace Lucene.Net.Util.Fst else { path.Input.Grow(1 + path.Input.Length); - path.Input.Ints[path.Input.Length] = path.Arc.Label; + path.Input.Int32s[path.Input.Length] = path.Arc.Label; path.Input.Length++; path.Cost = fst.Outputs.Add(path.Cost, path.Arc.Output); } @@ -986,7 +986,7 @@ namespace Lucene.Net.Util.Fst scratch.Grow(charLimit); for (int idx = 0; idx < charLimit; idx++) { - scratch.Ints[idx] = (int)s[idx]; + scratch.Int32s[idx] = (int)s[idx]; } return scratch; } @@ -1005,7 +1005,7 @@ namespace Lucene.Net.Util.Fst { scratch.Grow(intIdx + 1); int utf32 = Character.CodePointAt(s, charIdx); - scratch.Ints[intIdx] = utf32; + scratch.Int32s[intIdx] = utf32; charIdx += Character.CharCount(utf32); intIdx++; } @@ -1027,7 +1027,7 @@ namespace Lucene.Net.Util.Fst { scratch.Grow(intIdx + 1); int utf32 = Character.CodePointAt(s, charIdx, charLimit); - scratch.Ints[intIdx] = utf32; + scratch.Int32s[intIdx] = utf32; charIdx += Character.CharCount(utf32); intIdx++; } @@ -1037,14 +1037,16 @@ namespace Lucene.Net.Util.Fst /// <summary> /// Just takes unsigned byte values from the BytesRef and - /// converts into an IntsRef. + /// converts into an IntsRef. + /// <para/> + /// NOTE: This was toIntsRef() in Lucene /// </summary> - public static IntsRef ToIntsRef(BytesRef input, IntsRef scratch) + public static IntsRef ToInt32sRef(BytesRef input, IntsRef scratch) { scratch.Grow(input.Length); for (int i = 0; i < input.Length; i++) { - scratch.Ints[i] = input.Bytes[i + input.Offset] & 0xFF; + scratch.Int32s[i] = input.Bytes[i + input.Offset] & 0xFF; } scratch.Length = input.Length; return scratch; @@ -1059,7 +1061,7 @@ namespace Lucene.Net.Util.Fst scratch.Grow(input.Length); for (int i = 0; i < input.Length; i++) { - int value = input.Ints[i + input.Offset]; + int value = input.Int32s[i + input.Offset]; // NOTE: we allow -128 to 255 Debug.Assert(value >= sbyte.MinValue && value <= 255, "value " + value + " doesn't fit into byte"); scratch.Bytes[i] = (byte)value; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/IntBlockPool.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/IntBlockPool.cs b/src/Lucene.Net.Core/Util/IntBlockPool.cs index 7b0ec79..0216498 100644 --- a/src/Lucene.Net.Core/Util/IntBlockPool.cs +++ b/src/Lucene.Net.Core/Util/IntBlockPool.cs @@ -45,9 +45,15 @@ namespace Lucene.Net.Util this.m_blockSize = blockSize; } - public abstract void RecycleIntBlocks(int[][] blocks, int start, int end); + /// <summary> + /// NOTE: This was recycleIntBlocks() in Lucene + /// </summary> + public abstract void RecycleInt32Blocks(int[][] blocks, int start, int end); - public virtual int[] GetIntBlock() // LUCENENET TODO: Rename GetInt32Block() ? + /// <summary> + /// NOTE: This was getIntBlock() in Lucene + /// </summary> + public virtual int[] GetInt32Block() { return new int[m_blockSize]; } @@ -65,7 +71,10 @@ namespace Lucene.Net.Util { } - public override void RecycleIntBlocks(int[][] blocks, int start, int end) + /// <summary> + /// NOTE: This was recycleIntBlocks() in Lucene + /// </summary> + public override void RecycleInt32Blocks(int[][] blocks, int start, int end) { } } @@ -86,8 +95,11 @@ namespace Lucene.Net.Util private int bufferUpto = -1; /// <summary> - /// Pointer to the current position in head buffer </summary> - public int IntUpto { get; set; } + /// Pointer to the current position in head buffer + /// <para/> + /// NOTE: This was intUpto in Lucene + /// </summary> + public int Int32Upto { get; set; } /// <summary> /// Current head buffer </summary> @@ -101,8 +113,11 @@ namespace Lucene.Net.Util private int[] buffer; /// <summary> - /// Current head offset </summary> - public int IntOffset { get; set; } + /// Current head offset + /// <para/> + /// NOTE: This was intOffset in Lucene + /// </summary> + public int Int32Offset { get; set; } private readonly Allocator allocator; @@ -120,8 +135,8 @@ namespace Lucene.Net.Util public IntBlockPool(Allocator allocator) { // set defaults - IntUpto = INT_BLOCK_SIZE; - IntOffset = -INT_BLOCK_SIZE; + Int32Upto = INT_BLOCK_SIZE; + Int32Offset = -INT_BLOCK_SIZE; this.allocator = allocator; } @@ -157,29 +172,29 @@ namespace Lucene.Net.Util Arrays.Fill(buffers[i], 0); } // Partial zero fill the final buffer - Arrays.Fill(buffers[bufferUpto], 0, IntUpto, 0); + Arrays.Fill(buffers[bufferUpto], 0, Int32Upto, 0); } if (bufferUpto > 0 || !reuseFirst) { int offset = reuseFirst ? 1 : 0; // Recycle all but the first buffer - allocator.RecycleIntBlocks(buffers, offset, 1 + bufferUpto); + allocator.RecycleInt32Blocks(buffers, offset, 1 + bufferUpto); Arrays.Fill(buffers, offset, bufferUpto + 1, null); } if (reuseFirst) { // Re-use the first buffer bufferUpto = 0; - IntUpto = 0; - IntOffset = 0; + Int32Upto = 0; + Int32Offset = 0; buffer = buffers[0]; } else { bufferUpto = -1; - IntUpto = INT_BLOCK_SIZE; - IntOffset = -INT_BLOCK_SIZE; + Int32Upto = INT_BLOCK_SIZE; + Int32Offset = -INT_BLOCK_SIZE; buffer = null; } } @@ -199,11 +214,11 @@ namespace Lucene.Net.Util Array.Copy(buffers, 0, newBuffers, 0, buffers.Length); buffers = newBuffers; } - buffer = buffers[1 + bufferUpto] = allocator.GetIntBlock(); + buffer = buffers[1 + bufferUpto] = allocator.GetInt32Block(); bufferUpto++; - IntUpto = 0; - IntOffset += INT_BLOCK_SIZE; + Int32Upto = 0; + Int32Offset += INT_BLOCK_SIZE; } /// <summary> @@ -211,15 +226,15 @@ namespace Lucene.Net.Util /// <seealso cref= SliceReader </seealso> private int NewSlice(int size) { - if (IntUpto > INT_BLOCK_SIZE - size) + if (Int32Upto > INT_BLOCK_SIZE - size) { NextBuffer(); Debug.Assert(AssertSliceBuffer(buffer)); } - int upto = IntUpto; - IntUpto += size; - buffer[IntUpto - 1] = 1; + int upto = Int32Upto; + Int32Upto += size; + buffer[Int32Upto - 1] = 1; return upto; } @@ -260,20 +275,20 @@ namespace Lucene.Net.Util int newLevel = NEXT_LEVEL_ARRAY[level - 1]; int newSize = LEVEL_SIZE_ARRAY[newLevel]; // Maybe allocate another block - if (IntUpto > INT_BLOCK_SIZE - newSize) + if (Int32Upto > INT_BLOCK_SIZE - newSize) { NextBuffer(); Debug.Assert(AssertSliceBuffer(buffer)); } - int newUpto = IntUpto; - int offset = newUpto + IntOffset; - IntUpto += newSize; + int newUpto = Int32Upto; + int offset = newUpto + Int32Offset; + Int32Upto += newSize; // Write forwarding address at end of last slice: slice[sliceOffset] = offset; // Write new level: - buffer[IntUpto - 1] = newLevel; + buffer[Int32Upto - 1] = newLevel; return newUpto; } @@ -301,8 +316,10 @@ namespace Lucene.Net.Util /// <summary> /// Writes the given value into the slice and resizes the slice if needed + /// <para/> + /// NOTE: This was writeInt() in Lucene /// </summary> - public virtual void WriteInt(int value) // LUCENENET TODO: rename WriteInt32 ? + public virtual void WriteInt32(int value) { int[] ints = pool.buffers[offset >> INT_BLOCK_SHIFT]; Debug.Assert(ints != null); @@ -312,7 +329,7 @@ namespace Lucene.Net.Util // End of slice; allocate a new one relativeOffset = pool.AllocSlice(ints, relativeOffset); ints = pool.buffer; - offset = relativeOffset + pool.IntOffset; + offset = relativeOffset + pool.Int32Offset; } ints[relativeOffset] = value; offset++; @@ -324,7 +341,7 @@ namespace Lucene.Net.Util /// </summary> public virtual int StartNewSlice() { - return offset = pool.NewSlice(FIRST_LEVEL_SIZE) + pool.IntOffset; + return offset = pool.NewSlice(FIRST_LEVEL_SIZE) + pool.Int32Offset; } /// <summary> @@ -403,9 +420,12 @@ namespace Lucene.Net.Util } /// <summary> - /// Reads the next int from the current slice and returns it. </summary> + /// Reads the next int from the current slice and returns it. + /// <para/> + /// NOTE: This was readInt() in Lucene + /// </summary> /// <seealso cref= SliceReader#endOfSlice() </seealso> - public int ReadInt() // LUCENENET TODO: Rename ReadInt32() ? + public int ReadInt32() { Debug.Assert(!EndOfSlice()); Debug.Assert(upto <= limit); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/IntsRef.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/IntsRef.cs b/src/Lucene.Net.Core/Util/IntsRef.cs index 67c50d8..26dd154 100644 --- a/src/Lucene.Net.Core/Util/IntsRef.cs +++ b/src/Lucene.Net.Core/Util/IntsRef.cs @@ -37,10 +37,13 @@ namespace Lucene.Net.Util public static readonly int[] EMPTY_INTS = new int[0]; /// <summary> - /// The contents of the IntsRef. Should never be {@code null}. </summary> + /// The contents of the IntsRef. Should never be {@code null}. + /// <para/> + /// NOTE: This was ints (field) in Lucene + /// </summary> [WritableArray] [SuppressMessage("Microsoft.Performance", "CA1819", Justification = "Lucene's design requires some writable array properties")] - public int[] Ints + public int[] Int32s { get { return ints; } set @@ -121,12 +124,15 @@ namespace Lucene.Net.Util } if (other is IntsRef) { - return this.IntsEquals((IntsRef)other); + return this.Int32sEquals((IntsRef)other); } return false; } - public bool IntsEquals(IntsRef other) + /// <summary> + /// NOTE: This was intsEquals() in Lucene + /// </summary> + public bool Int32sEquals(IntsRef other) { if (Length == other.Length) { @@ -182,7 +188,10 @@ namespace Lucene.Net.Util return this.Length - other.Length; } - public void CopyInts(IntsRef other) + /// <summary> + /// NOTE: This was copyInts() in Lucene + /// </summary> + public void CopyInt32s(IntsRef other) { if (ints.Length - Offset < other.Length) { @@ -235,7 +244,7 @@ namespace Lucene.Net.Util public static IntsRef DeepCopyOf(IntsRef other) { IntsRef clone = new IntsRef(); - clone.CopyInts(other); + clone.CopyInt32s(other); return clone; } @@ -255,7 +264,7 @@ namespace Lucene.Net.Util } if (Length > ints.Length) { - throw new InvalidOperationException("length is out of bounds: " + Length + ",ints.length=" + Ints.Length); + throw new InvalidOperationException("length is out of bounds: " + Length + ",ints.length=" + Int32s.Length); } if (Offset < 0) { @@ -263,15 +272,15 @@ namespace Lucene.Net.Util } if (Offset > ints.Length) { - throw new InvalidOperationException("offset out of bounds: " + Offset + ",ints.length=" + Ints.Length); + throw new InvalidOperationException("offset out of bounds: " + Offset + ",ints.length=" + Int32s.Length); } if (Offset + Length < 0) { throw new InvalidOperationException("offset+length is negative: offset=" + Offset + ",length=" + Length); } - if (Offset + Length > Ints.Length) + if (Offset + Length > Int32s.Length) { - throw new InvalidOperationException("offset+length out of bounds: offset=" + Offset + ",length=" + Length + ",ints.length=" + Ints.Length); + throw new InvalidOperationException("offset+length out of bounds: offset=" + Offset + ",length=" + Length + ",ints.length=" + Int32s.Length); } return true; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/LongsRef.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/LongsRef.cs b/src/Lucene.Net.Core/Util/LongsRef.cs index 2a1fa1e..6bfd5f1 100644 --- a/src/Lucene.Net.Core/Util/LongsRef.cs +++ b/src/Lucene.Net.Core/Util/LongsRef.cs @@ -37,10 +37,13 @@ namespace Lucene.Net.Util public static readonly long[] EMPTY_LONGS = new long[0]; /// <summary> - /// The contents of the LongsRef. Should never be {@code null}. </summary> + /// The contents of the LongsRef. Should never be {@code null}. + /// <para/> + /// NOTE: This was longs (field) in Lucene + /// </summary> [WritableArray] [SuppressMessage("Microsoft.Performance", "CA1819", Justification = "Lucene's design requires some writable array properties")] - public long[] Longs + public long[] Int64s { get { return longs; } set @@ -121,12 +124,15 @@ namespace Lucene.Net.Util } if (other is LongsRef) { - return this.LongsEquals((LongsRef)other); + return this.Int64sEquals((LongsRef)other); } return false; } - public bool LongsEquals(LongsRef other) + /// <summary> + /// NOTE: This was longsEquals() in Lucene + /// </summary> + public bool Int64sEquals(LongsRef other) { if (Length == other.Length) { @@ -182,7 +188,10 @@ namespace Lucene.Net.Util return this.Length - other.Length; } - public void CopyLongs(LongsRef other) + /// <summary> + /// NOTE: This was copyLongs() in Lucene + /// </summary> + public void CopyInt64s(LongsRef other) { if (longs.Length - Offset < other.Length) { @@ -235,7 +244,7 @@ namespace Lucene.Net.Util public static LongsRef DeepCopyOf(LongsRef other) { LongsRef clone = new LongsRef(); - clone.CopyLongs(other); + clone.CopyInt64s(other); return clone; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Mutable/MutableValueFloat.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Mutable/MutableValueFloat.cs b/src/Lucene.Net.Core/Util/Mutable/MutableValueFloat.cs index ccbdb13..a71386b 100644 --- a/src/Lucene.Net.Core/Util/Mutable/MutableValueFloat.cs +++ b/src/Lucene.Net.Core/Util/Mutable/MutableValueFloat.cs @@ -70,7 +70,7 @@ namespace Lucene.Net.Util.Mutable public override int GetHashCode() { - return Number.FloatToIntBits(Value); + return Number.SingleToInt32Bits(Value); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/NumericUtils.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/NumericUtils.cs b/src/Lucene.Net.Core/Util/NumericUtils.cs index 894e33b..b66a134 100644 --- a/src/Lucene.Net.Core/Util/NumericUtils.cs +++ b/src/Lucene.Net.Core/Util/NumericUtils.cs @@ -100,35 +100,44 @@ namespace Lucene.Net.Util /// <summary> /// Returns prefix coded bits after reducing the precision by <code>shift</code> bits. /// this is method is used by <seealso cref="NumericTokenStream"/>. - /// After encoding, {@code bytes.offset} will always be 0. </summary> + /// After encoding, {@code bytes.offset} will always be 0. + /// <para/> + /// NOTE: This was longToPrefixCoded() in Lucene + /// </summary> /// <param name="val"> the numeric value </param> /// <param name="shift"> how many bits to strip from the right </param> /// <param name="bytes"> will contain the encoded value </param> - public static void LongToPrefixCoded(long val, int shift, BytesRef bytes) // LUCENENET TODO: Rename to Int64ToPrefixCoded ? + public static void Int64ToPrefixCoded(long val, int shift, BytesRef bytes) { - LongToPrefixCodedBytes(val, shift, bytes); + Int64ToPrefixCodedBytes(val, shift, bytes); } /// <summary> /// Returns prefix coded bits after reducing the precision by <code>shift</code> bits. /// this is method is used by <seealso cref="NumericTokenStream"/>. - /// After encoding, {@code bytes.offset} will always be 0. </summary> + /// After encoding, {@code bytes.offset} will always be 0. + /// <para/> + /// NOTE: This was intToPrefixCoded() in Lucene + /// </summary> /// <param name="val"> the numeric value </param> /// <param name="shift"> how many bits to strip from the right </param> /// <param name="bytes"> will contain the encoded value </param> - public static void IntToPrefixCoded(int val, int shift, BytesRef bytes) // LUCENENET TODO: Rename to Int32ToPrefixCoded ? + public static void Int32ToPrefixCoded(int val, int shift, BytesRef bytes) { - IntToPrefixCodedBytes(val, shift, bytes); + Int32ToPrefixCodedBytes(val, shift, bytes); } /// <summary> /// Returns prefix coded bits after reducing the precision by <code>shift</code> bits. /// this is method is used by <seealso cref="NumericTokenStream"/>. - /// After encoding, {@code bytes.offset} will always be 0. </summary> + /// After encoding, {@code bytes.offset} will always be 0. + /// <para/> + /// NOTE: This was longToPrefixCodedBytes() in Lucene + /// </summary> /// <param name="val"> the numeric value </param> /// <param name="shift"> how many bits to strip from the right </param> /// <param name="bytes"> will contain the encoded value </param> - public static void LongToPrefixCodedBytes(long val, int shift, BytesRef bytes) // LUCENENET TODO: Rename to Int64ToPrefixCodedBytes ? + public static void Int64ToPrefixCodedBytes(long val, int shift, BytesRef bytes) { if ((shift & ~0x3f) != 0) // ensure shift is 0..63 { @@ -156,11 +165,14 @@ namespace Lucene.Net.Util /// <summary> /// Returns prefix coded bits after reducing the precision by <code>shift</code> bits. /// this is method is used by <seealso cref="NumericTokenStream"/>. - /// After encoding, {@code bytes.offset} will always be 0. </summary> + /// After encoding, {@code bytes.offset} will always be 0. + /// <para/> + /// NOTE: This was intToPrefixCodedBytes() in Lucene + /// </summary> /// <param name="val"> the numeric value </param> /// <param name="shift"> how many bits to strip from the right </param> /// <param name="bytes"> will contain the encoded value </param> - public static void IntToPrefixCodedBytes(int val, int shift, BytesRef bytes) // LUCENENET TODO: Int64ToPrefixCodedBytes ? + public static void Int32ToPrefixCodedBytes(int val, int shift, BytesRef bytes) { if ((shift & ~0x1f) != 0) // ensure shift is 0..31 { @@ -186,10 +198,13 @@ namespace Lucene.Net.Util } /// <summary> - /// Returns the shift value from a prefix encoded {@code long}. </summary> + /// Returns the shift value from a prefix encoded {@code long}. + /// <para/> + /// NOTE: This was getPrefixCodedLongShift() in Lucene + /// </summary> /// <exception cref="NumberFormatException"> if the supplied <seealso cref="BytesRef"/> is /// not correctly prefix encoded. </exception> - public static int GetPrefixCodedLongShift(BytesRef val) // LUCENENET TODO: Rename to GetPrefixCodedInt64Shift ? + public static int GetPrefixCodedInt64Shift(BytesRef val) { int shift = val.Bytes[val.Offset] - SHIFT_START_LONG; if (shift > 63 || shift < 0) @@ -200,10 +215,13 @@ namespace Lucene.Net.Util } /// <summary> - /// Returns the shift value from a prefix encoded {@code int}. </summary> + /// Returns the shift value from a prefix encoded {@code int}. + /// <para/> + /// NOTE: This was getPrefixCodedIntShift() in Lucene + /// </summary> /// <exception cref="NumberFormatException"> if the supplied <seealso cref="BytesRef"/> is /// not correctly prefix encoded. </exception> - public static int GetPrefixCodedIntShift(BytesRef val) // LUCENENET TODO: Rename GetPrefixCodedInt32Shift ? + public static int GetPrefixCodedInt32Shift(BytesRef val) { int shift = val.Bytes[val.Offset] - SHIFT_START_INT; if (shift > 31 || shift < 0) @@ -216,11 +234,14 @@ namespace Lucene.Net.Util /// <summary> /// Returns a long from prefixCoded bytes. /// Rightmost bits will be zero for lower precision codes. - /// this method can be used to decode a term's value. </summary> + /// this method can be used to decode a term's value. + /// <para/> + /// NOTE: This was prefixCodedToLong() in Lucene + /// </summary> /// <exception cref="NumberFormatException"> if the supplied <seealso cref="BytesRef"/> is /// not correctly prefix encoded. </exception> /// <seealso cref= #longToPrefixCodedBytes </seealso> - public static long PrefixCodedToLong(BytesRef val) // LUCENENET TODO: Rename PrefixCodedToInt64 ? + public static long PrefixCodedToInt64(BytesRef val) { long sortableBits = 0L; for (int i = val.Offset + 1, limit = val.Offset + val.Length; i < limit; i++) @@ -233,17 +254,20 @@ namespace Lucene.Net.Util } sortableBits |= (byte)b; } - return (long)((ulong)(sortableBits << GetPrefixCodedLongShift(val)) ^ 0x8000000000000000L); + return (long)((ulong)(sortableBits << GetPrefixCodedInt64Shift(val)) ^ 0x8000000000000000L); } /// <summary> /// Returns an int from prefixCoded bytes. /// Rightmost bits will be zero for lower precision codes. - /// this method can be used to decode a term's value. </summary> + /// this method can be used to decode a term's value. + /// <para/> + /// NOTE: This was prefixCodedToInt() in Lucene + /// </summary> /// <exception cref="NumberFormatException"> if the supplied <seealso cref="BytesRef"/> is /// not correctly prefix encoded. </exception> /// <seealso cref= #intToPrefixCodedBytes </seealso> - public static int PrefixCodedToInt(BytesRef val) // LUCENENET TODO: Rename PrefixCodedToInt32 ? + public static int PrefixCodedToInt32(BytesRef val) { long sortableBits = 0; for (int i = val.Offset, limit = val.Offset + val.Length; i < limit; i++) @@ -256,7 +280,7 @@ namespace Lucene.Net.Util } sortableBits |= (sbyte)b; } - return (int)((sortableBits << GetPrefixCodedIntShift(val)) ^ 0x80000000); + return (int)((sortableBits << GetPrefixCodedInt32Shift(val)) ^ 0x80000000); } /// <summary> @@ -265,11 +289,14 @@ namespace Lucene.Net.Util /// bit layout and then some bits are swapped, to be able to compare the result as long. /// By this the precision is not reduced, but the value can easily used as a long. /// The sort order (including <seealso cref="Double#NaN"/>) is defined by - /// <seealso cref="Double#compareTo"/>; {@code NaN} is greater than positive infinity. </summary> + /// <seealso cref="Double#compareTo"/>; {@code NaN} is greater than positive infinity. + /// <para/> + /// NOTE: This was doubleToSortableLong() in Lucene + /// </summary> /// <seealso cref= #sortableLongToDouble </seealso> - public static long DoubleToSortableLong(double val) // LUCENENET TODO: Rename DoubleToSortableInt64 ? + public static long DoubleToSortableInt64(double val) { - long f = Number.DoubleToLongBits(val); + long f = Number.DoubleToInt64Bits(val); if (f < 0) { f ^= 0x7fffffffffffffffL; @@ -278,9 +305,12 @@ namespace Lucene.Net.Util } /// <summary> - /// Converts a sortable <code>long</code> back to a <code>double</code>. </summary> + /// Converts a sortable <code>long</code> back to a <code>double</code>. + /// <para/> + /// NOTE: This was sortableLongToDouble() in Lucene + /// </summary> /// <seealso cref= #doubleToSortableLong </seealso> - public static double SortableLongToDouble(long val) // LUCENENET TODO: Rename SortableInt64ToDouble ? + public static double SortableInt64ToDouble(long val) { if (val < 0) { @@ -295,11 +325,14 @@ namespace Lucene.Net.Util /// bit layout and then some bits are swapped, to be able to compare the result as int. /// By this the precision is not reduced, but the value can easily used as an int. /// The sort order (including <seealso cref="Float#NaN"/>) is defined by - /// <seealso cref="Float#compareTo"/>; {@code NaN} is greater than positive infinity. </summary> + /// <seealso cref="Float#compareTo"/>; {@code NaN} is greater than positive infinity. + /// <para/> + /// NOTE: This was floatToSortableInt() in Lucene + /// </summary> /// <seealso cref= #sortableIntToFloat </seealso> - public static int FloatToSortableInt(float val) // LUCENENET TODO: rename SingleToSortableInt32 ? + public static int SingleToSortableInt32(float val) { - int f = Number.FloatToIntBits(val); + int f = Number.SingleToInt32Bits(val); if (f < 0) { f ^= 0x7fffffff; @@ -308,15 +341,18 @@ namespace Lucene.Net.Util } /// <summary> - /// Converts a sortable <code>int</code> back to a <code>float</code>. </summary> - /// <seealso cref= #floatToSortableInt </seealso> - public static float SortableIntToFloat(int val) // LUCENENET TODO: rename SortableInt32ToSingle ? + /// Converts a sortable <see cref="int"/> back to a <see cref="float"/>. + /// <para/> + /// NOTE: This was sortableIntToFloat() in Lucene + /// </summary> + /// <seealso cref="SingleToSortableInt32"/> + public static float SortableInt32ToSingle(int val) { if (val < 0) { val ^= 0x7fffffff; } - return Number.IntBitsToFloat(val); + return Number.Int32BitsToSingle(val); } /// <summary> @@ -325,9 +361,12 @@ namespace Lucene.Net.Util /// <seealso cref="Lucene.Net.Search.BooleanQuery"/> for each call to its /// <seealso cref="LongRangeBuilder#addRange(BytesRef,BytesRef)"/> /// method. - /// <p>this method is used by <seealso cref="NumericRangeQuery"/>. + /// <para/> + /// this method is used by <seealso cref="NumericRangeQuery"/>. + /// <para/> + /// NOTE: This was splitLongRange() in Lucene /// </summary> - public static void SplitLongRange(LongRangeBuilder builder, int precisionStep, long minBound, long maxBound) // LUCENENET TODO: Rename SplitIn64Range ? + public static void SplitInt64Range(LongRangeBuilder builder, int precisionStep, long minBound, long maxBound) { SplitRange(builder, 64, precisionStep, minBound, maxBound); } @@ -338,9 +377,12 @@ namespace Lucene.Net.Util /// <seealso cref="Lucene.Net.Search.BooleanQuery"/> for each call to its /// <seealso cref="IntRangeBuilder#addRange(BytesRef,BytesRef)"/> /// method. - /// <p>this method is used by <seealso cref="NumericRangeQuery"/>. + /// <para/> + /// this method is used by <seealso cref="NumericRangeQuery"/>. + /// <para/> + /// NOTE: This was splitIntRange() in Lucene /// </summary> - public static void SplitIntRange(IntRangeBuilder builder, int precisionStep, int minBound, int maxBound) // LUCENENET TODO: rename SplitInt32Range ? + public static void SplitInt32Range(IntRangeBuilder builder, int precisionStep, int minBound, int maxBound) { SplitRange(builder, 32, precisionStep, minBound, maxBound); } @@ -438,8 +480,8 @@ namespace Lucene.Net.Util public virtual void AddRange(long min, long max, int shift) { BytesRef minBytes = new BytesRef(BUF_SIZE_LONG), maxBytes = new BytesRef(BUF_SIZE_LONG); - LongToPrefixCodedBytes(min, shift, minBytes); - LongToPrefixCodedBytes(max, shift, maxBytes); + Int64ToPrefixCodedBytes(min, shift, minBytes); + Int64ToPrefixCodedBytes(max, shift, maxBytes); AddRange(minBytes, maxBytes); } } @@ -468,8 +510,8 @@ namespace Lucene.Net.Util public virtual void AddRange(int min, int max, int shift) { BytesRef minBytes = new BytesRef(BUF_SIZE_INT), maxBytes = new BytesRef(BUF_SIZE_INT); - IntToPrefixCodedBytes(min, shift, minBytes); - IntToPrefixCodedBytes(max, shift, maxBytes); + Int32ToPrefixCodedBytes(min, shift, minBytes); + Int32ToPrefixCodedBytes(max, shift, maxBytes); AddRange(minBytes, maxBytes); } } @@ -477,12 +519,14 @@ namespace Lucene.Net.Util /// <summary> /// Filters the given <seealso cref="TermsEnum"/> by accepting only prefix coded 64 bit /// terms with a shift value of <tt>0</tt>. + /// <para/> + /// NOTE: This was filterPrefixCodedLongs() in Lucene /// </summary> /// <param name="termsEnum"> /// the terms enum to filter </param> /// <returns> a filtered <seealso cref="TermsEnum"/> that only returns prefix coded 64 bit /// terms with a shift value of <tt>0</tt>. </returns> - public static TermsEnum FilterPrefixCodedLongs(TermsEnum termsEnum) // LUCENENET TODO: Rename FilterPrefixCodedInt64s ? + public static TermsEnum FilterPrefixCodedInt64s(TermsEnum termsEnum) { return new FilteredTermsEnumAnonymousInnerClassHelper(termsEnum); } @@ -496,19 +540,21 @@ namespace Lucene.Net.Util protected override AcceptStatus Accept(BytesRef term) { - return NumericUtils.GetPrefixCodedLongShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; + return NumericUtils.GetPrefixCodedInt64Shift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } } /// <summary> /// Filters the given <seealso cref="TermsEnum"/> by accepting only prefix coded 32 bit /// terms with a shift value of <tt>0</tt>. + /// <para/> + /// NOTE: This was filterPrefixCodedInts() in Lucene /// </summary> /// <param name="termsEnum"> /// the terms enum to filter </param> /// <returns> a filtered <seealso cref="TermsEnum"/> that only returns prefix coded 32 bit /// terms with a shift value of <tt>0</tt>. </returns> - public static TermsEnum FilterPrefixCodedInts(TermsEnum termsEnum) // LUCENENET TODO: Rename FilterPrefixCodedInt32s ? + public static TermsEnum FilterPrefixCodedInt32s(TermsEnum termsEnum) { return new FilteredTermsEnumAnonymousInnerClassHelper2(termsEnum); } @@ -522,7 +568,7 @@ namespace Lucene.Net.Util protected override AcceptStatus Accept(BytesRef term) { - return NumericUtils.GetPrefixCodedIntShift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; + return NumericUtils.GetPrefixCodedInt32Shift(term) == 0 ? AcceptStatus.YES : AcceptStatus.END; } } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/OfflineSorter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/OfflineSorter.cs b/src/Lucene.Net.Core/Util/OfflineSorter.cs index 72a2aea..379d6a8 100644 --- a/src/Lucene.Net.Core/Util/OfflineSorter.cs +++ b/src/Lucene.Net.Core/Util/OfflineSorter.cs @@ -571,7 +571,7 @@ namespace Lucene.Net.Util Debug.Assert(bytes != null); Debug.Assert(off >= 0 && off + len <= bytes.Length); Debug.Assert(len >= 0); - os.WriteShort((short)len); + os.WriteInt16((short)len); os.WriteBytes(bytes, off, len); // LUCENENET NOTE: We call WriteBytes, since there is no Write() on Lucene's version of DataOutput } @@ -622,7 +622,7 @@ namespace Lucene.Net.Util ushort length; try { - length = (ushort)inputStream.ReadShort(); + length = (ushort)inputStream.ReadInt16(); } catch (Exception) { @@ -649,7 +649,7 @@ namespace Lucene.Net.Util ushort length; try { - length = (ushort)inputStream.ReadShort(); + length = (ushort)inputStream.ReadInt16(); } #pragma warning disable 168 catch (Exception e) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs b/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs index 70e2905..250fa7d 100644 --- a/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs +++ b/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs @@ -35,8 +35,11 @@ namespace Lucene.Net.Util.Packed return (n >> 63) ^ (n << 1); } - // same as DataOutput.writeVLong but accepts negative values - internal static void WriteVLong(DataOutput @out, long i) + // same as DataOutput.WriteVInt64 but accepts negative values + /// <summary> + /// NOTE: This was writeVLong() in Lucene + /// </summary> + internal static void WriteVInt64(DataOutput @out, long i) { int k = 0; while ((i & ~0x7FL) != 0L && k++ < 8) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BlockPackedReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BlockPackedReader.cs b/src/Lucene.Net.Core/Util/Packed/BlockPackedReader.cs index 7e87b6e..43f1a0d 100644 --- a/src/Lucene.Net.Core/Util/Packed/BlockPackedReader.cs +++ b/src/Lucene.Net.Core/Util/Packed/BlockPackedReader.cs @@ -56,7 +56,7 @@ namespace Lucene.Net.Util.Packed { minValues = new long[numBlocks]; } - minValues[i] = BlockPackedReaderIterator.ZigZagDecode(1L + BlockPackedReaderIterator.ReadVLong(@in)); + minValues[i] = BlockPackedReaderIterator.ZigZagDecode(1L + BlockPackedReaderIterator.ReadVInt64(@in)); } if (bitsPerValue == 0) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs b/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs index c46123c..f837834 100644 --- a/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs +++ b/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs @@ -35,8 +35,11 @@ namespace Lucene.Net.Util.Packed return (((long)((ulong)n >> 1)) ^ -(n & 1)); } - // same as DataInput.readVLong but supports negative values - internal static long ReadVLong(DataInput @in) // LUCENENET TODO: rename to ReadVInt64 ? + // same as DataInput.ReadVInt64 but supports negative values + /// <summary> + /// NOTE: This was readVLong() in Lucene + /// </summary> + internal static long ReadVInt64(DataInput @in) { byte b = @in.ReadByte(); if ((sbyte)b >= 0) @@ -161,7 +164,7 @@ namespace Lucene.Net.Util.Packed } if ((token & AbstractBlockPackedWriter.MIN_VALUE_EQUALS_0) == 0) { - ReadVLong(@in); + ReadVInt64(@in); } long blockBytes = PackedInts.Format.PACKED.ByteCount(packedIntsVersion, blockSize, bitsPerValue); SkipBytes(blockBytes); @@ -253,7 +256,7 @@ namespace Lucene.Net.Util.Packed { throw new System.IO.IOException("Corrupted"); } - long minValue = minEquals0 ? 0L : ZigZagDecode(1L + ReadVLong(@in)); + long minValue = minEquals0 ? 0L : ZigZagDecode(1L + ReadVInt64(@in)); Debug.Assert(minEquals0 || minValue != 0); if (bitsPerValue == 0) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BlockPackedWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BlockPackedWriter.cs b/src/Lucene.Net.Core/Util/Packed/BlockPackedWriter.cs index 20d0edd..bbcf981 100644 --- a/src/Lucene.Net.Core/Util/Packed/BlockPackedWriter.cs +++ b/src/Lucene.Net.Core/Util/Packed/BlockPackedWriter.cs @@ -93,7 +93,7 @@ namespace Lucene.Net.Util.Packed if (min != 0) { - WriteVLong(m_out, ZigZagEncode(min) - 1); + WriteVInt64(m_out, ZigZagEncode(min) - 1); } if (bitsRequired > 0) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs index 486612d..9bcc8f2 100644 --- a/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs +++ b/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs @@ -47,9 +47,15 @@ namespace Lucene.Net.Util.Packed public abstract int ByteBlockCount { get; } - public abstract int LongValueCount { get; } // LUCENENET TODO: Rename Int64ValueCount ? + /// <summary> + /// NOTE: This was longValueCount() in Lucene + /// </summary> + public abstract int Int64ValueCount { get; } - public abstract int LongBlockCount { get; } // LUCENENET TODO: Rename Int64BlockCount ? + /// <summary> + /// NOTE: This was longBlockCount() in Lucene + /// </summary> + public abstract int Int64BlockCount { get; } private static readonly BulkOperation[] packedBulkOps = new BulkOperation[] { new BulkOperationPacked1(), @@ -172,7 +178,10 @@ namespace Lucene.Net.Util.Packed } } - protected virtual int WriteLong(long block, byte[] blocks, int blocksOffset) // LUCENENET TODO: Rename WriteInt64 ? + /// <summary> + /// NOTE: This was writeLong() in Lucene + /// </summary> + protected virtual int WriteInt64(long block, byte[] blocks, int blocksOffset) { for (int j = 1; j <= 8; ++j) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs index 83ebd19..2c32f31 100644 --- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs +++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs @@ -64,12 +64,18 @@ namespace Lucene.Net.Util.Packed Debug.Assert(longValueCount * bitsPerValue == 64 * longBlockCount); } - public override int LongBlockCount + /// <summary> + /// NOTE: This was longBlockCount() in Lucene + /// </summary> + public override int Int64BlockCount { get { return longBlockCount; } } - public override int LongValueCount + /// <summary> + /// NOTE: This was longValueCount() in Lucene + /// </summary> + public override int Int64ValueCount { get { return longValueCount; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs index 93ada86..a8cfa90 100644 --- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs +++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs @@ -35,7 +35,10 @@ namespace Lucene.Net.Util.Packed this.mask = (1L << bitsPerValue) - 1; } - public override sealed int LongBlockCount + /// <summary> + /// NOTE: This was longBlockCount() in Lucene + /// </summary> + public override sealed int Int64BlockCount { get { return BLOCK_COUNT; } } @@ -45,7 +48,10 @@ namespace Lucene.Net.Util.Packed get { return BLOCK_COUNT * 8; } } - public override int LongValueCount + /// <summary> + /// NOTE: This was longValueCount() in Lucene + /// </summary> + public override int Int64ValueCount { get { return valueCount; } } @@ -55,7 +61,10 @@ namespace Lucene.Net.Util.Packed get { return valueCount; } } - private static long ReadLong(byte[] blocks, int blocksOffset) + /// <summary> + /// NOTE: This was readLong() in Lucene + /// </summary> + private static long ReadInt64(byte[] blocks, int blocksOffset) { return (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 56 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 48 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 40 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 32 | @@ -118,7 +127,7 @@ namespace Lucene.Net.Util.Packed { for (int i = 0; i < iterations; ++i) { - long block = ReadLong(blocks, blocksOffset); + long block = ReadInt64(blocks, blocksOffset); blocksOffset += 8; valuesOffset = Decode(block, values, valuesOffset); } @@ -145,7 +154,7 @@ namespace Lucene.Net.Util.Packed } for (int i = 0; i < iterations; ++i) { - long block = ReadLong(blocks, blocksOffset); + long block = ReadInt64(blocks, blocksOffset); blocksOffset += 8; valuesOffset = Decode(block, values, valuesOffset); } @@ -175,7 +184,7 @@ namespace Lucene.Net.Util.Packed { long block = Encode(values, valuesOffset); valuesOffset += valueCount; - blocksOffset = WriteLong(block, blocks, blocksOffset); + blocksOffset = WriteInt64(block, blocks, blocksOffset); } } @@ -185,7 +194,7 @@ namespace Lucene.Net.Util.Packed { long block = Encode(values, valuesOffset); valuesOffset += valueCount; - blocksOffset = WriteLong(block, blocks, blocksOffset); + blocksOffset = WriteInt64(block, blocks, blocksOffset); } } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Direct16.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Direct16.cs b/src/Lucene.Net.Core/Util/Packed/Direct16.cs index b1ad785..1a834ea 100644 --- a/src/Lucene.Net.Core/Util/Packed/Direct16.cs +++ b/src/Lucene.Net.Core/Util/Packed/Direct16.cs @@ -44,7 +44,7 @@ namespace Lucene.Net.Util.Packed { for (int i = 0; i < valueCount; ++i) { - values[i] = @in.ReadShort(); + values[i] = @in.ReadInt16(); } // because packed ints have not always been byte-aligned int remaining = (int)(PackedInts.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 16) - 2L * valueCount); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Direct32.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Direct32.cs b/src/Lucene.Net.Core/Util/Packed/Direct32.cs index c74cb23..f9d62c2 100644 --- a/src/Lucene.Net.Core/Util/Packed/Direct32.cs +++ b/src/Lucene.Net.Core/Util/Packed/Direct32.cs @@ -44,7 +44,7 @@ namespace Lucene.Net.Util.Packed { for (int i = 0; i < valueCount; ++i) { - values[i] = @in.ReadInt(); + values[i] = @in.ReadInt32(); } // because packed ints have not always been byte-aligned int remaining = (int)(PackedInts.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 32) - 4L * valueCount); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Direct64.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Direct64.cs b/src/Lucene.Net.Core/Util/Packed/Direct64.cs index 978a23c..0c7cb36 100644 --- a/src/Lucene.Net.Core/Util/Packed/Direct64.cs +++ b/src/Lucene.Net.Core/Util/Packed/Direct64.cs @@ -44,7 +44,7 @@ namespace Lucene.Net.Util.Packed { for (int i = 0; i < valueCount; ++i) { - values[i] = @in.ReadLong(); + values[i] = @in.ReadInt64(); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/DirectPacked64SingleBlockReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/DirectPacked64SingleBlockReader.cs b/src/Lucene.Net.Core/Util/Packed/DirectPacked64SingleBlockReader.cs index 34bfbf5..1ca3e1f 100644 --- a/src/Lucene.Net.Core/Util/Packed/DirectPacked64SingleBlockReader.cs +++ b/src/Lucene.Net.Core/Util/Packed/DirectPacked64SingleBlockReader.cs @@ -45,7 +45,7 @@ namespace Lucene.Net.Util.Packed { @in.Seek(startPointer + skip); - long block = @in.ReadLong(); + long block = @in.ReadInt64(); int offsetInBlock = index % valuesPerBlock; return ((long)((ulong)block >> (offsetInBlock * m_bitsPerValue))) & mask; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/DirectPackedReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/DirectPackedReader.cs b/src/Lucene.Net.Core/Util/Packed/DirectPackedReader.cs index c63f34a..a6a2aac 100644 --- a/src/Lucene.Net.Core/Util/Packed/DirectPackedReader.cs +++ b/src/Lucene.Net.Core/Util/Packed/DirectPackedReader.cs @@ -67,37 +67,37 @@ namespace Lucene.Net.Util.Packed break; case 2: - rawValue = @in.ReadShort(); + rawValue = @in.ReadInt16(); break; case 3: - rawValue = ((long)@in.ReadShort() << 8) | (@in.ReadByte() & 0xFFL); + rawValue = ((long)@in.ReadInt16() << 8) | (@in.ReadByte() & 0xFFL); break; case 4: - rawValue = @in.ReadInt(); + rawValue = @in.ReadInt32(); break; case 5: - rawValue = ((long)@in.ReadInt() << 8) | (@in.ReadByte() & 0xFFL); + rawValue = ((long)@in.ReadInt32() << 8) | (@in.ReadByte() & 0xFFL); break; case 6: - rawValue = ((long)@in.ReadInt() << 16) | (@in.ReadShort() & 0xFFFFL); + rawValue = ((long)@in.ReadInt32() << 16) | (@in.ReadInt16() & 0xFFFFL); break; case 7: - rawValue = ((long)@in.ReadInt() << 24) | ((@in.ReadShort() & 0xFFFFL) << 8) | (@in.ReadByte() & 0xFFL); + rawValue = ((long)@in.ReadInt32() << 24) | ((@in.ReadInt16() & 0xFFFFL) << 8) | (@in.ReadByte() & 0xFFL); break; case 8: - rawValue = @in.ReadLong(); + rawValue = @in.ReadInt64(); break; case 9: // We must be very careful not to shift out relevant bits. So we account for right shift // we would normally do on return here, and reset it. - rawValue = (@in.ReadLong() << (8 - shiftRightBits)) | ((int)((uint)(@in.ReadByte() & 0xFFL) >> shiftRightBits)); + rawValue = (@in.ReadInt64() << (8 - shiftRightBits)) | ((int)((uint)(@in.ReadByte() & 0xFFL) >> shiftRightBits)); shiftRightBits = 0; break; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/EliasFanoDecoder.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/EliasFanoDecoder.cs b/src/Lucene.Net.Core/Util/Packed/EliasFanoDecoder.cs index 581044d..7e4c1d6 100644 --- a/src/Lucene.Net.Core/Util/Packed/EliasFanoDecoder.cs +++ b/src/Lucene.Net.Core/Util/Packed/EliasFanoDecoder.cs @@ -194,9 +194,11 @@ namespace Lucene.Net.Util.Packed /// <summary> /// The current high long has been determined to not contain the set bit that is needed. - /// Increment setBitForIndex to the next high long and set curHighLong accordingly. + /// Increment setBitForIndex to the next high long and set curHighLong accordingly. + /// <para/> + /// NOTE: this was toNextHighLong() in Lucene /// </summary> - private void ToNextHighLong() + private void ToNextHighInt64() { setBitForIndex += (sizeof(long) * 8) - (setBitForIndex & ((sizeof(long) * 8) - 1)); //assert getCurrentRightShift() == 0; @@ -212,7 +214,7 @@ namespace Lucene.Net.Util.Packed { while (curHighLong == 0L) { - ToNextHighLong(); // inlining and unrolling would simplify somewhat + ToNextHighInt64(); // inlining and unrolling would simplify somewhat } setBitForIndex += Number.NumberOfTrailingZeros(curHighLong); } @@ -265,7 +267,7 @@ namespace Lucene.Net.Util.Packed while ((efIndex + curSetBits) < index) // curHighLong has not enough set bits to reach index { efIndex += curSetBits; - ToNextHighLong(); + ToNextHighInt64(); curSetBits = Number.BitCount(curHighLong); } // curHighLong has enough set bits to reach index @@ -449,9 +451,11 @@ namespace Lucene.Net.Util.Packed /// <summary> /// The current high long has been determined to not contain the set bit that is needed. - /// Decrement setBitForIndex to the previous high long and set curHighLong accordingly. + /// Decrement setBitForIndex to the previous high long and set curHighLong accordingly. + /// <para/> + /// NOTE: this was toPreviousHighLong() in Lucene /// </summary> - private void ToPreviousHighLong() + private void ToPreviousHighInt64() { setBitForIndex -= (setBitForIndex & ((sizeof(long) * 8) - 1)) + 1; //assert getCurrentLeftShift() == 0; @@ -467,7 +471,7 @@ namespace Lucene.Net.Util.Packed { while (curHighLong == 0L) { - ToPreviousHighLong(); // inlining and unrolling would simplify somewhat + ToPreviousHighInt64(); // inlining and unrolling would simplify somewhat } setBitForIndex -= Number.NumberOfLeadingZeros(curHighLong); return CurrentHighValue(); @@ -506,7 +510,7 @@ namespace Lucene.Net.Util.Packed { return NO_MORE_VALUES; } - ToPreviousHighLong(); + ToPreviousHighInt64(); //assert getCurrentLeftShift() == 0; curSetBits = Number.BitCount(curHighLong); curClearBits = (sizeof(long) * 8) - curSetBits; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/EliasFanoEncoder.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/EliasFanoEncoder.cs b/src/Lucene.Net.Core/Util/Packed/EliasFanoEncoder.cs index cdf6231..2e09188 100644 --- a/src/Lucene.Net.Core/Util/Packed/EliasFanoEncoder.cs +++ b/src/Lucene.Net.Core/Util/Packed/EliasFanoEncoder.cs @@ -162,7 +162,7 @@ namespace Lucene.Net.Util.Packed this.numLowBits = nLowBits; this.lowerBitsMask = (long)(unchecked((ulong)long.MaxValue) >> (sizeof(long) * 8 - 1 - this.numLowBits)); - long numLongsForLowBits = NumLongsForBits(numValues * numLowBits); + long numLongsForLowBits = NumInt64sForBits(numValues * numLowBits); if (numLongsForLowBits > int.MaxValue) { throw new System.ArgumentException("numLongsForLowBits too large to index a long array: " + numLongsForLowBits); @@ -173,7 +173,7 @@ namespace Lucene.Net.Util.Packed Debug.Assert(numHighBitsClear <= (2 * this.numValues)); long numHighBitsSet = this.numValues; - long numLongsForHighBits = NumLongsForBits(numHighBitsClear + numHighBitsSet); + long numLongsForHighBits = NumInt64sForBits(numHighBitsClear + numHighBitsSet); if (numLongsForHighBits > int.MaxValue) { throw new System.ArgumentException("numLongsForHighBits too large to index a long array: " + numLongsForHighBits); @@ -189,7 +189,7 @@ namespace Lucene.Net.Util.Packed this.numIndexEntries = (nIndexEntries >= 0) ? nIndexEntries : 0; long maxIndexEntry = maxHighValue + numValues - 1; // clear upper bits, set upper bits, start at zero this.nIndexEntryBits = (maxIndexEntry <= 0) ? 0 : (64 - Number.NumberOfLeadingZeros(maxIndexEntry)); - long numLongsForIndexBits = NumLongsForBits(numIndexEntries * nIndexEntryBits); + long numLongsForIndexBits = NumInt64sForBits(numIndexEntries * nIndexEntryBits); if (numLongsForIndexBits > int.MaxValue) { throw new System.ArgumentException("numLongsForIndexBits too large to index a long array: " + numLongsForIndexBits); @@ -207,7 +207,10 @@ namespace Lucene.Net.Util.Packed { } - private static long NumLongsForBits(long numBits) // Note: int version in FixedBitSet.bits2words() + /// <summary> + /// NOTE: This was numLongsForBits() in Lucene + /// </summary> + private static long NumInt64sForBits(long numBits) // Note: int version in FixedBitSet.bits2words() { Debug.Assert(numBits >= 0, numBits.ToString()); return (long)((ulong)(numBits + (sizeof(long) * 8 - 1)) >> LOG2_LONG_SIZE); @@ -350,18 +353,18 @@ namespace Lucene.Net.Util.Packed s.Append("\nupperLongs[" + upperLongs.Length + "]"); for (int i = 0; i < upperLongs.Length; i++) { - s.Append(" " + ToStringUtils.LongHex(upperLongs[i])); + s.Append(" " + ToStringUtils.Int64Hex(upperLongs[i])); } s.Append("\nlowerLongs[" + lowerLongs.Length + "]"); for (int i = 0; i < lowerLongs.Length; i++) { - s.Append(" " + ToStringUtils.LongHex(lowerLongs[i])); + s.Append(" " + ToStringUtils.Int64Hex(lowerLongs[i])); } s.Append("\nindexInterval: " + indexInterval + ", nIndexEntryBits: " + nIndexEntryBits); s.Append("\nupperZeroBitPositionIndex[" + upperZeroBitPositionIndex.Length + "]"); for (int i = 0; i < upperZeroBitPositionIndex.Length; i++) { - s.Append(" " + ToStringUtils.LongHex(upperZeroBitPositionIndex[i])); + s.Append(" " + ToStringUtils.Int64Hex(upperZeroBitPositionIndex[i])); } return s.ToString(); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedReader.cs b/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedReader.cs index d7ac447..e9dcbf3 100644 --- a/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedReader.cs +++ b/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedReader.cs @@ -48,9 +48,9 @@ namespace Lucene.Net.Util.Packed subReaders = new PackedInts.Reader[numBlocks]; for (int i = 0; i < numBlocks; ++i) { - minValues[i] = @in.ReadVLong(); - averages[i] = Number.IntBitsToFloat(@in.ReadInt()); - int bitsPerValue = @in.ReadVInt(); + minValues[i] = @in.ReadVInt64(); + averages[i] = Number.Int32BitsToSingle(@in.ReadInt32()); + int bitsPerValue = @in.ReadVInt32(); if (bitsPerValue > 64) { throw new Exception("Corrupted"); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedWriter.cs b/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedWriter.cs index 545da3c..9d017bb 100644 --- a/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedWriter.cs +++ b/src/Lucene.Net.Core/Util/Packed/MonotonicBlockPackedWriter.cs @@ -83,16 +83,16 @@ namespace Lucene.Net.Util.Packed maxZigZagDelta = Math.Max(maxZigZagDelta, m_values[i]); } - m_out.WriteVLong(min); - m_out.WriteInt(Number.FloatToIntBits(avg)); + m_out.WriteVInt64(min); + m_out.WriteInt32(Number.SingleToInt32Bits(avg)); if (maxZigZagDelta == 0) { - m_out.WriteVInt(0); + m_out.WriteVInt32(0); } else { int bitsRequired = PackedInts.BitsRequired(maxZigZagDelta); - m_out.WriteVInt(bitsRequired); + m_out.WriteVInt32(bitsRequired); WriteValues(bitsRequired); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Packed16ThreeBlocks.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Packed16ThreeBlocks.cs b/src/Lucene.Net.Core/Util/Packed/Packed16ThreeBlocks.cs index 5d9dea6..470ebb8 100644 --- a/src/Lucene.Net.Core/Util/Packed/Packed16ThreeBlocks.cs +++ b/src/Lucene.Net.Core/Util/Packed/Packed16ThreeBlocks.cs @@ -50,7 +50,7 @@ namespace Lucene.Net.Util.Packed { for (int i = 0; i < 3 * valueCount; ++i) { - blocks[i] = @in.ReadShort(); + blocks[i] = @in.ReadInt16(); } // because packed ints have not always been byte-aligned int remaining = (int)(PackedInts.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 48) - 3L * valueCount * 2); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Packed64.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Packed64.cs b/src/Lucene.Net.Core/Util/Packed/Packed64.cs index cd3e1dc..9f2edf7 100644 --- a/src/Lucene.Net.Core/Util/Packed/Packed64.cs +++ b/src/Lucene.Net.Core/Util/Packed/Packed64.cs @@ -72,7 +72,7 @@ namespace Lucene.Net.Util.Packed : base(valueCount, bitsPerValue) { PackedInts.Format format = PackedInts.Format.PACKED; - int longCount = format.LongCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); + int longCount = format.Int64Count(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); this.blocks = new long[longCount]; // MaskRight = ~0L << (int)((uint)(BLOCK_SIZE - bitsPerValue) >> (BLOCK_SIZE - bitsPerValue)); //original // MaskRight = (uint)(~0L << (BLOCK_SIZE - bitsPerValue)) >> (BLOCK_SIZE - bitsPerValue); //mod @@ -100,12 +100,12 @@ namespace Lucene.Net.Util.Packed { PackedInts.Format format = PackedInts.Format.PACKED; long byteCount = format.ByteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read - int longCount = format.LongCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array + int longCount = format.Int64Count(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array blocks = new long[longCount]; // read as many longs as we can for (int i = 0; i < byteCount / 8; ++i) { - blocks[i] = @in.ReadLong(); + blocks[i] = @in.ReadInt64(); } int remaining = (int)(byteCount % 8); if (remaining != 0) @@ -183,10 +183,10 @@ namespace Lucene.Net.Util.Packed PackedInts.IDecoder decoder = BulkOperation.Of(PackedInts.Format.PACKED, m_bitsPerValue); // go to the next block where the value does not span across two blocks - int offsetInBlocks = index % decoder.LongValueCount; + int offsetInBlocks = index % decoder.Int64ValueCount; if (offsetInBlocks != 0) { - for (int i = offsetInBlocks; i < decoder.LongValueCount && len > 0; ++i) + for (int i = offsetInBlocks; i < decoder.Int64ValueCount && len > 0; ++i) { arr[off++] = Get(index++); --len; @@ -198,12 +198,12 @@ namespace Lucene.Net.Util.Packed } // bulk get - Debug.Assert(index % decoder.LongValueCount == 0); + Debug.Assert(index % decoder.Int64ValueCount == 0); int blockIndex = (int)((ulong)((long)index * m_bitsPerValue) >> BLOCK_BITS); Debug.Assert((((long)index * m_bitsPerValue) & MOD_MASK) == 0); - int iterations = len / decoder.LongValueCount; + int iterations = len / decoder.Int64ValueCount; decoder.Decode(blocks, blockIndex, arr, off, iterations); - int gotValues = iterations * decoder.LongValueCount; + int gotValues = iterations * decoder.Int64ValueCount; index += gotValues; len -= gotValues; Debug.Assert(len >= 0); @@ -251,10 +251,10 @@ namespace Lucene.Net.Util.Packed PackedInts.IEncoder encoder = BulkOperation.Of(PackedInts.Format.PACKED, m_bitsPerValue); // go to the next block where the value does not span across two blocks - int offsetInBlocks = index % encoder.LongValueCount; + int offsetInBlocks = index % encoder.Int64ValueCount; if (offsetInBlocks != 0) { - for (int i = offsetInBlocks; i < encoder.LongValueCount && len > 0; ++i) + for (int i = offsetInBlocks; i < encoder.Int64ValueCount && len > 0; ++i) { Set(index++, arr[off++]); --len; @@ -266,12 +266,12 @@ namespace Lucene.Net.Util.Packed } // bulk set - Debug.Assert(index % encoder.LongValueCount == 0); + Debug.Assert(index % encoder.Int64ValueCount == 0); int blockIndex = (int)((ulong)((long)index * m_bitsPerValue) >> BLOCK_BITS); Debug.Assert((((long)index * m_bitsPerValue) & MOD_MASK) == 0); - int iterations = len / encoder.LongValueCount; + int iterations = len / encoder.Int64ValueCount; encoder.Encode(arr, off, blocks, blockIndex, iterations); - int setValues = iterations * encoder.LongValueCount; + int setValues = iterations * encoder.Int64ValueCount; index += setValues; len -= setValues; Debug.Assert(len >= 0); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/Packed64SingleBlock.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/Packed64SingleBlock.cs b/src/Lucene.Net.Core/Util/Packed/Packed64SingleBlock.cs index 5b48982..7c3f9ff 100644 --- a/src/Lucene.Net.Core/Util/Packed/Packed64SingleBlock.cs +++ b/src/Lucene.Net.Core/Util/Packed/Packed64SingleBlock.cs @@ -98,8 +98,8 @@ namespace Lucene.Net.Util.Packed // bulk get Debug.Assert(index % valuesPerBlock == 0); PackedInts.IDecoder decoder = BulkOperation.Of(PackedInts.Format.PACKED_SINGLE_BLOCK, m_bitsPerValue); - Debug.Assert(decoder.LongBlockCount == 1); - Debug.Assert(decoder.LongValueCount == valuesPerBlock); + Debug.Assert(decoder.Int64BlockCount == 1); + Debug.Assert(decoder.Int64ValueCount == valuesPerBlock); int blockIndex = index / valuesPerBlock; int nblocks = (index + len) / valuesPerBlock - blockIndex; decoder.Decode(blocks, blockIndex, arr, off, nblocks); @@ -149,8 +149,8 @@ namespace Lucene.Net.Util.Packed // bulk set Debug.Assert(index % valuesPerBlock == 0); BulkOperation op = BulkOperation.Of(PackedInts.Format.PACKED_SINGLE_BLOCK, m_bitsPerValue); - Debug.Assert(op.LongBlockCount == 1); - Debug.Assert(op.LongValueCount == valuesPerBlock); + Debug.Assert(op.Int64BlockCount == 1); + Debug.Assert(op.Int64ValueCount == valuesPerBlock); int blockIndex = index / valuesPerBlock; int nblocks = (index + len) / valuesPerBlock - blockIndex; op.Encode(arr, off, blocks, blockIndex, nblocks); @@ -235,7 +235,7 @@ namespace Lucene.Net.Util.Packed Packed64SingleBlock reader = Create(valueCount, bitsPerValue); for (int i = 0; i < reader.blocks.Length; ++i) { - reader.blocks[i] = @in.ReadLong(); + reader.blocks[i] = @in.ReadInt64(); } return reader; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/PackedDataInput.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/PackedDataInput.cs b/src/Lucene.Net.Core/Util/Packed/PackedDataInput.cs index a5ec9e7..4fb79b4 100644 --- a/src/Lucene.Net.Core/Util/Packed/PackedDataInput.cs +++ b/src/Lucene.Net.Core/Util/Packed/PackedDataInput.cs @@ -45,8 +45,10 @@ namespace Lucene.Net.Util.Packed /// <summary> /// Read the next long using exactly <code>bitsPerValue</code> bits. + /// <para/> + /// NOTE: This was readLong() in Lucene /// </summary> - public long ReadLong(int bitsPerValue) + public long ReadInt64(int bitsPerValue) { Debug.Assert(bitsPerValue > 0 && bitsPerValue <= 64, bitsPerValue.ToString()); long r = 0; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f7432173/src/Lucene.Net.Core/Util/Packed/PackedDataOutput.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Util/Packed/PackedDataOutput.cs b/src/Lucene.Net.Core/Util/Packed/PackedDataOutput.cs index bbb5d0e..6ebe366 100644 --- a/src/Lucene.Net.Core/Util/Packed/PackedDataOutput.cs +++ b/src/Lucene.Net.Core/Util/Packed/PackedDataOutput.cs @@ -45,8 +45,10 @@ namespace Lucene.Net.Util.Packed /// <summary> /// Write a value using exactly <code>bitsPerValue</code> bits. + /// <para/> + /// NOTE: This was writeLong() in Lucene /// </summary> - public void WriteLong(long value, int bitsPerValue) // LUCENENET TODO: Rename WriteInt64 ? + public void WriteInt64(long value, int bitsPerValue) { Debug.Assert(bitsPerValue == 64 || (value >= 0 && value <= PackedInts.MaxValue(bitsPerValue))); while (bitsPerValue > 0)
