You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/02/08 14:32:00 UTC
[21/53] [abbrv] lucenenet git commit: Lucene.Net.Core: Renamed all
type-derived classes and interfaces from Short, Int, Long,
and Float to match CLR types Int16, Int32, Int64, and Single, respectively.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Support/TestLongBuffer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Support/TestLongBuffer.cs b/src/Lucene.Net.Tests/core/Support/TestLongBuffer.cs
index c4f0947..f83ffcc 100644
--- a/src/Lucene.Net.Tests/core/Support/TestLongBuffer.cs
+++ b/src/Lucene.Net.Tests/core/Support/TestLongBuffer.cs
@@ -19,7 +19,7 @@ namespace Lucene.Net.Support
};
- private static void relGet(LongBuffer b)
+ private static void relGet(Int64Buffer b)
{
int n = b.Capacity;
//long v; // LUCENENET: Not used
@@ -28,7 +28,7 @@ namespace Lucene.Net.Support
b.Rewind();
}
- private static void relGet(LongBuffer b, int start)
+ private static void relGet(Int64Buffer b, int start)
{
int n = b.Remaining;
//long v; // LUCENENET: Not used
@@ -37,7 +37,7 @@ namespace Lucene.Net.Support
b.Rewind();
}
- private static void absGet(LongBuffer b)
+ private static void absGet(Int64Buffer b)
{
int n = b.Capacity;
//long v; // LUCENENET: Not used
@@ -46,7 +46,7 @@ namespace Lucene.Net.Support
b.Rewind();
}
- private static void bulkGet(LongBuffer b)
+ private static void bulkGet(Int64Buffer b)
{
int n = b.Capacity;
long[] a = new long[n + 7];
@@ -55,7 +55,7 @@ namespace Lucene.Net.Support
ck(b, (long)a[i + 7], (long)((long)Ic(i)));
}
- private static void relPut(LongBuffer b)
+ private static void relPut(Int64Buffer b)
{
int n = b.Capacity;
b.Clear();
@@ -64,7 +64,7 @@ namespace Lucene.Net.Support
b.Flip();
}
- private static void absPut(LongBuffer b)
+ private static void absPut(Int64Buffer b)
{
int n = b.Capacity;
b.Clear();
@@ -74,7 +74,7 @@ namespace Lucene.Net.Support
b.Position = (0);
}
- private static void bulkPutArray(LongBuffer b)
+ private static void bulkPutArray(Int64Buffer b)
{
int n = b.Capacity;
b.Clear();
@@ -85,11 +85,11 @@ namespace Lucene.Net.Support
b.Flip();
}
- private static void bulkPutBuffer(LongBuffer b)
+ private static void bulkPutBuffer(Int64Buffer b)
{
int n = b.Capacity;
b.Clear();
- LongBuffer c = LongBuffer.Allocate(n + 7);
+ Int64Buffer c = Int64Buffer.Allocate(n + 7);
c.Position = (7);
for (int i = 0; i < n; i++)
c.Put((long)Ic(i));
@@ -100,7 +100,7 @@ namespace Lucene.Net.Support
}
//6231529
- private static void callReset(LongBuffer b)
+ private static void callReset(Int64Buffer b)
{
b.Position = (0);
b.Mark();
@@ -122,23 +122,23 @@ namespace Lucene.Net.Support
// LUCENENET: AllocateDirect not implemented
//LongBuffer direct1 = ByteBuffer.AllocateDirect(cap).AsLongBuffer();
- LongBuffer nondirect1 = ByteBuffer.Allocate(cap).AsInt64Buffer();
+ Int64Buffer nondirect1 = ByteBuffer.Allocate(cap).AsInt64Buffer();
//direct1.Put(nondirect1);
//LongBuffer direct2 = ByteBuffer.AllocateDirect(cap).AsLongBuffer();
- LongBuffer nondirect2 = ByteBuffer.Allocate(cap).AsInt64Buffer();
+ Int64Buffer nondirect2 = ByteBuffer.Allocate(cap).AsInt64Buffer();
//nondirect2.Put(direct2);
//LongBuffer direct3 = ByteBuffer.AllocateDirect(cap).AsLongBuffer();
//LongBuffer direct4 = ByteBuffer.AllocateDirect(cap).AsLongBuffer();
//direct3.Put(direct4);
- LongBuffer nondirect3 = ByteBuffer.Allocate(cap).AsInt64Buffer();
- LongBuffer nondirect4 = ByteBuffer.Allocate(cap).AsInt64Buffer();
+ Int64Buffer nondirect3 = ByteBuffer.Allocate(cap).AsInt64Buffer();
+ Int64Buffer nondirect4 = ByteBuffer.Allocate(cap).AsInt64Buffer();
nondirect3.Put(nondirect4);
}
- private static void checkSlice(LongBuffer b, LongBuffer slice)
+ private static void checkSlice(Int64Buffer b, Int64Buffer slice)
{
ck(slice, 0, slice.Position);
ck(slice, b.Remaining, slice.Limit);
@@ -150,7 +150,7 @@ namespace Lucene.Net.Support
}
private static void fail(string problem,
- LongBuffer xb, LongBuffer yb,
+ Int64Buffer xb, Int64Buffer yb,
long x, long y)
{
fail(problem + string.Format(": x={0} y={1}", x, y), xb, yb);
@@ -180,10 +180,10 @@ namespace Lucene.Net.Support
private static void tryCatch(long[] t, Type ex, Action thunk)
{
- tryCatch(LongBuffer.Wrap(t), ex, thunk);
+ tryCatch(Int64Buffer.Wrap(t), ex, thunk);
}
- public static void test(int level, LongBuffer b, bool direct)
+ public static void test(int level, Int64Buffer b, bool direct)
{
Show(level, b);
@@ -276,7 +276,7 @@ namespace Lucene.Net.Support
// Comparison
b.Rewind();
- LongBuffer b2 = Lucene.Net.Support.LongBuffer.Allocate(b.Capacity);
+ Int64Buffer b2 = Lucene.Net.Support.Int64Buffer.Allocate(b.Capacity);
b2.Put(b);
b2.Flip();
b.Position = (2);
@@ -315,7 +315,7 @@ namespace Lucene.Net.Support
// Check equals and compareTo with interesting values
foreach (long x in VALUES)
{
- LongBuffer xb = Lucene.Net.Support.LongBuffer.Wrap(new long[] { x });
+ Int64Buffer xb = Lucene.Net.Support.Int64Buffer.Wrap(new long[] { x });
if (xb.CompareTo(xb) != 0)
{
fail("compareTo not reflexive", xb, xb, x, x);
@@ -326,7 +326,7 @@ namespace Lucene.Net.Support
}
foreach (long y in VALUES)
{
- LongBuffer yb = Lucene.Net.Support.LongBuffer.Wrap(new long[] { y });
+ Int64Buffer yb = Lucene.Net.Support.Int64Buffer.Wrap(new long[] { y });
if (xb.CompareTo(yb) != -yb.CompareTo(xb))
{
fail("compareTo not anti-symmetric",
@@ -365,10 +365,10 @@ namespace Lucene.Net.Support
// Slice
b.Position = (5);
- LongBuffer sb = b.Slice();
+ Int64Buffer sb = b.Slice();
checkSlice(b, sb);
b.Position = (0);
- LongBuffer sb2 = sb.Slice();
+ Int64Buffer sb2 = sb.Slice();
checkSlice(sb, sb2);
if (!sb.equals(sb2))
@@ -462,7 +462,7 @@ namespace Lucene.Net.Support
{
int offset = 47;
int length = 900;
- LongBuffer b = LongBuffer.Wrap(ba, offset, length);
+ Int64Buffer b = Int64Buffer.Wrap(ba, offset, length);
Show(0, b);
ck(b, b.Capacity, ba.Length);
ck(b, b.Position, offset);
@@ -471,29 +471,29 @@ namespace Lucene.Net.Support
// The offset must be non-negative and no larger than <array.length>.
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
- LongBuffer.Wrap(ba, -1, ba.Length);
+ Int64Buffer.Wrap(ba, -1, ba.Length);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
- LongBuffer.Wrap(ba, ba.Length + 1, ba.Length);
+ Int64Buffer.Wrap(ba, ba.Length + 1, ba.Length);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
- LongBuffer.Wrap(ba, 0, -1);
+ Int64Buffer.Wrap(ba, 0, -1);
});
tryCatch(ba, typeof(ArgumentOutOfRangeException), () =>
{
- LongBuffer.Wrap(ba, 0, ba.Length + 1);
+ Int64Buffer.Wrap(ba, 0, ba.Length + 1);
});
// A NullPointerException will be thrown if the array is null.
tryCatch(ba, typeof(NullReferenceException), () =>
{
- LongBuffer.Wrap((long[])null, 0, 5);
+ Int64Buffer.Wrap((long[])null, 0, 5);
});
tryCatch(ba, typeof(NullReferenceException), () =>
{
- LongBuffer.Wrap((long[])null);
+ Int64Buffer.Wrap((long[])null);
});
}
@@ -503,7 +503,7 @@ namespace Lucene.Net.Support
// An IllegalArgumentException will be thrown for negative capacities.
tryCatch((Buffer)null, typeof(ArgumentException), () =>
{
- LongBuffer.Allocate(-1);
+ Int64Buffer.Allocate(-1);
});
}
@@ -511,11 +511,11 @@ namespace Lucene.Net.Support
public static void Test()
{
TestAllocate();
- test(0, LongBuffer.Allocate(7 * 1024), false);
- test(0, LongBuffer.Wrap(new long[7 * 1024], 0, 7 * 1024), false);
+ test(0, Int64Buffer.Allocate(7 * 1024), false);
+ test(0, Int64Buffer.Wrap(new long[7 * 1024], 0, 7 * 1024), false);
test(new long[1024]);
- callReset(LongBuffer.Allocate(10));
+ callReset(Int64Buffer.Allocate(10));
putBuffer();
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Util/Automaton/TestSpecialOperations.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Automaton/TestSpecialOperations.cs b/src/Lucene.Net.Tests/core/Util/Automaton/TestSpecialOperations.cs
index 5eb06cc..106983b 100644
--- a/src/Lucene.Net.Tests/core/Util/Automaton/TestSpecialOperations.cs
+++ b/src/Lucene.Net.Tests/core/Util/Automaton/TestSpecialOperations.cs
@@ -48,12 +48,12 @@ namespace Lucene.Net.Util.Automaton
{
Automaton a = BasicOperations.Union(BasicAutomata.MakeString("dog"), BasicAutomata.MakeString("duck"));
MinimizationOperations.Minimize(a);
- ISet<IntsRef> strings = SpecialOperations.GetFiniteStrings(a, -1);
+ ISet<Int32sRef> strings = SpecialOperations.GetFiniteStrings(a, -1);
Assert.AreEqual(2, strings.Count);
- IntsRef dog = new IntsRef();
+ Int32sRef dog = new Int32sRef();
Util.ToInt32sRef(new BytesRef("dog"), dog);
Assert.IsTrue(strings.Contains(dog));
- IntsRef duck = new IntsRef();
+ Int32sRef duck = new Int32sRef();
Util.ToInt32sRef(new BytesRef("duck"), duck);
Assert.IsTrue(strings.Contains(duck));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
index 7127487..4a22f6d 100644
--- a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
+++ b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
@@ -26,7 +26,7 @@ namespace Lucene.Net.Util.Fst
using IndexOutput = Lucene.Net.Store.IndexOutput;
using IOContext = Lucene.Net.Store.IOContext;
using MMapDirectory = Lucene.Net.Store.MMapDirectory;
- using PackedInts = Lucene.Net.Util.Packed.PackedInts;
+ using PackedInt32s = Lucene.Net.Util.Packed.PackedInt32s;
//ORIGINAL LINE: @TimeoutSuite(millis = 100 * TimeUnits.HOUR) public class Test2BFST extends Lucene.Net.Util.LuceneTestCase
[Ignore("Requires tons of heap to run (420G works)")]
@@ -39,7 +39,7 @@ namespace Lucene.Net.Util.Fst
public virtual void Test()
{
int[] ints = new int[7];
- IntsRef input = new IntsRef(ints, 0, ints.Length);
+ Int32sRef input = new Int32sRef(ints, 0, ints.Length);
int seed = Random().Next();
Directory dir = new MMapDirectory(CreateTempDir("2BFST"));
@@ -54,12 +54,12 @@ namespace Lucene.Net.Util.Fst
Console.WriteLine("\nTEST: 3B nodes; doPack=false output=NO_OUTPUTS");
Outputs<object> outputs = NoOutputs.Singleton;
object NO_OUTPUT = outputs.NoOutput;
- Builder<object> b = new Builder<object>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInts.COMPACT, true, 15);
+ Builder<object> b = new Builder<object>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInt32s.COMPACT, true, 15);
int count = 0;
Random r = new Random(seed);
int[] ints2 = new int[200];
- IntsRef input2 = new IntsRef(ints2, 0, ints2.Length);
+ Int32sRef input2 = new Int32sRef(ints2, 0, ints2.Length);
while (true)
{
//System.out.println("add: " + input + " -> " + output);
@@ -104,14 +104,14 @@ namespace Lucene.Net.Util.Fst
}
Console.WriteLine("\nTEST: enum all input/outputs");
- IntsRefFSTEnum<object> fstEnum = new IntsRefFSTEnum<object>(fst);
+ Int32sRefFSTEnum<object> fstEnum = new Int32sRefFSTEnum<object>(fst);
Arrays.Fill(ints2, 0);
r = new Random(seed);
int upto = 0;
while (true)
{
- IntsRefFSTEnum.InputOutput<object> pair = fstEnum.Next();
+ Int32sRefFSTEnum.InputOutput<object> pair = fstEnum.Next();
if (pair == null)
{
break;
@@ -149,7 +149,7 @@ namespace Lucene.Net.Util.Fst
{
Console.WriteLine("\nTEST: 3 GB size; doPack=" + doPack + " outputs=bytes");
Outputs<BytesRef> outputs = ByteSequenceOutputs.Singleton;
- Builder<BytesRef> b = new Builder<BytesRef>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInts.COMPACT, true, 15);
+ Builder<BytesRef> b = new Builder<BytesRef>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInt32s.COMPACT, true, 15);
var outputBytes = new byte[20];
BytesRef output = new BytesRef(outputBytes);
@@ -193,14 +193,14 @@ namespace Lucene.Net.Util.Fst
}
Console.WriteLine("\nTEST: enum all input/outputs");
- IntsRefFSTEnum<BytesRef> fstEnum = new IntsRefFSTEnum<BytesRef>(fst);
+ Int32sRefFSTEnum<BytesRef> fstEnum = new Int32sRefFSTEnum<BytesRef>(fst);
Arrays.Fill(ints, 0);
r = new Random(seed);
int upto = 0;
while (true)
{
- IntsRefFSTEnum.InputOutput<BytesRef> pair = fstEnum.Next();
+ Int32sRefFSTEnum.InputOutput<BytesRef> pair = fstEnum.Next();
if (pair == null)
{
break;
@@ -234,8 +234,8 @@ namespace Lucene.Net.Util.Fst
// size = 3GB
{
Console.WriteLine("\nTEST: 3 GB size; doPack=" + doPack + " outputs=long");
- Outputs<long?> outputs = PositiveIntOutputs.Singleton;
- Builder<long?> b = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInts.COMPACT, true, 15);
+ Outputs<long?> outputs = PositiveInt32Outputs.Singleton;
+ Builder<long?> b = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInt32s.COMPACT, true, 15);
long output = 1;
@@ -285,7 +285,7 @@ namespace Lucene.Net.Util.Fst
}
Console.WriteLine("\nTEST: enum all input/outputs");
- IntsRefFSTEnum<long?> fstEnum = new IntsRefFSTEnum<long?>(fst);
+ Int32sRefFSTEnum<long?> fstEnum = new Int32sRefFSTEnum<long?>(fst);
Arrays.Fill(ints, 0);
r = new Random(seed);
@@ -293,7 +293,7 @@ namespace Lucene.Net.Util.Fst
output = 1;
while (true)
{
- IntsRefFSTEnum.InputOutput<long?> pair = fstEnum.Next();
+ Int32sRefFSTEnum.InputOutput<long?> pair = fstEnum.Next();
if (pair == null)
{
break;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
index 83b3f07..a69292c 100644
--- a/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
+++ b/src/Lucene.Net.Tests/core/Util/Fst/TestFSTs.cs
@@ -53,7 +53,7 @@ namespace Lucene.Net.Util.Fst
//using ResultLong = Lucene.Net.Util.Fst.Util.Result<long?>;
//using ResultPair = Lucene.Net.Util.Fst.Util.Result<long?>;
using OpenMode = Lucene.Net.Index.OpenMode;
- using PackedInts = Lucene.Net.Util.Packed.PackedInts;
+ using PackedInt32s = Lucene.Net.Util.Packed.PackedInt32s;
using Pair = Lucene.Net.Util.Fst.PairOutputs<long?, long?>.Pair;
using RandomIndexWriter = Lucene.Net.Index.RandomIndexWriter;
using RegExp = Lucene.Net.Util.Automaton.RegExp;
@@ -93,8 +93,8 @@ namespace Lucene.Net.Util.Fst
{
string[] strings = new string[] { "station", "commotion", "elation", "elastic", "plastic", "stop", "ftop", "ftation", "stat" };
string[] strings2 = new string[] { "station", "commotion", "elation", "elastic", "plastic", "stop", "ftop", "ftation" };
- IntsRef[] terms = new IntsRef[strings.Length];
- IntsRef[] terms2 = new IntsRef[strings2.Length];
+ Int32sRef[] terms = new Int32sRef[strings.Length];
+ Int32sRef[] terms2 = new Int32sRef[strings2.Length];
for (int inputMode = 0; inputMode < 2; inputMode++)
{
if (VERBOSE)
@@ -121,7 +121,7 @@ namespace Lucene.Net.Util.Fst
Outputs<object> outputs = NoOutputs.Singleton;
object NO_OUTPUT = outputs.NoOutput;
List<FSTTester<object>.InputOutput<object>> pairs = new List<FSTTester<object>.InputOutput<object>>(terms2.Length);
- foreach (IntsRef term in terms2)
+ foreach (Int32sRef term in terms2)
{
pairs.Add(new FSTTester<object>.InputOutput<object>(term, NO_OUTPUT));
}
@@ -133,7 +133,7 @@ namespace Lucene.Net.Util.Fst
// FST ord pos int
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
List<FSTTester<long?>.InputOutput<long?>> pairs = new List<FSTTester<long?>.InputOutput<long?>>(terms2.Length);
for (int idx = 0; idx < terms2.Length; idx++)
{
@@ -164,7 +164,7 @@ namespace Lucene.Net.Util.Fst
}
// given set of terms, test the different outputs for them
- private void DoTest(int inputMode, IntsRef[] terms)
+ private void DoTest(int inputMode, Int32sRef[] terms)
{
Array.Sort(terms);
@@ -173,7 +173,7 @@ namespace Lucene.Net.Util.Fst
Outputs<object> outputs = NoOutputs.Singleton;
object NO_OUTPUT = outputs.NoOutput;
List<FSTTester<object>.InputOutput<object>> pairs = new List<FSTTester<object>.InputOutput<object>>(terms.Length);
- foreach (IntsRef term in terms)
+ foreach (Int32sRef term in terms)
{
pairs.Add(new FSTTester<object>.InputOutput<object>(term, NO_OUTPUT));
}
@@ -182,7 +182,7 @@ namespace Lucene.Net.Util.Fst
// PositiveIntOutput (ord)
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
List<FSTTester<long?>.InputOutput<long?>> pairs = new List<FSTTester<long?>.InputOutput<long?>>(terms.Length);
for (int idx = 0; idx < terms.Length; idx++)
{
@@ -193,7 +193,7 @@ namespace Lucene.Net.Util.Fst
// PositiveIntOutput (random monotonically increasing positive number)
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
List<FSTTester<long?>.InputOutput<long?>> pairs = new List<FSTTester<long?>.InputOutput<long?>>(terms.Length);
long lastOutput = 0;
for (int idx = 0; idx < terms.Length; idx++)
@@ -207,7 +207,7 @@ namespace Lucene.Net.Util.Fst
// PositiveIntOutput (random positive number)
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
List<FSTTester<long?>.InputOutput<long?>> pairs = new List<FSTTester<long?>.InputOutput<long?>>(terms.Length);
for (int idx = 0; idx < terms.Length; idx++)
{
@@ -218,8 +218,8 @@ namespace Lucene.Net.Util.Fst
// Pair<ord, (random monotonically increasing positive number>
{
- PositiveIntOutputs o1 = PositiveIntOutputs.Singleton;
- PositiveIntOutputs o2 = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs o1 = PositiveInt32Outputs.Singleton;
+ PositiveInt32Outputs o2 = PositiveInt32Outputs.Singleton;
PairOutputs<long?, long?> outputs = new PairOutputs<long?, long?>(o1, o2);
List<FSTTester<Pair>.InputOutput<Pair>> pairs = new List<FSTTester<Pair>.InputOutput<Pair>>(terms.Length);
long lastOutput = 0;
@@ -247,20 +247,20 @@ namespace Lucene.Net.Util.Fst
// Sequence-of-ints
{
- IntSequenceOutputs outputs = IntSequenceOutputs.Singleton;
- List<FSTTester<IntsRef>.InputOutput<IntsRef>> pairs = new List<FSTTester<IntsRef>.InputOutput<IntsRef>>(terms.Length);
+ Int32SequenceOutputs outputs = Int32SequenceOutputs.Singleton;
+ List<FSTTester<Int32sRef>.InputOutput<Int32sRef>> pairs = new List<FSTTester<Int32sRef>.InputOutput<Int32sRef>>(terms.Length);
for (int idx = 0; idx < terms.Length; idx++)
{
string s = Convert.ToString(idx);
- IntsRef output = new IntsRef(s.Length);
+ Int32sRef output = new Int32sRef(s.Length);
output.Length = s.Length;
for (int idx2 = 0; idx2 < output.Length; idx2++)
{
output.Int32s[idx2] = s[idx2];
}
- pairs.Add(new FSTTester<IntsRef>.InputOutput<IntsRef>(terms[idx], output));
+ pairs.Add(new FSTTester<Int32sRef>.InputOutput<Int32sRef>(terms[idx], output));
}
- (new FSTTester<IntsRef>(Random(), Dir, inputMode, pairs, outputs, false)).DoTest(true);
+ (new FSTTester<Int32sRef>(Random(), Dir, inputMode, pairs, outputs, false)).DoTest(true);
}
}
@@ -302,8 +302,8 @@ namespace Lucene.Net.Util.Fst
for (int inputMode = 0; inputMode < 2; inputMode++)
{
int numWords = random.Next(maxNumWords + 1);
- HashSet<IntsRef> termsSet = new HashSet<IntsRef>();
- IntsRef[] terms = new IntsRef[numWords];
+ HashSet<Int32sRef> termsSet = new HashSet<Int32sRef>();
+ Int32sRef[] terms = new Int32sRef[numWords];
while (termsSet.Count < numWords)
{
string term = FSTTester<object>.GetRandomString(random);
@@ -346,11 +346,11 @@ namespace Lucene.Net.Util.Fst
}
IndexReader r = DirectoryReader.Open(writer, true);
writer.Dispose();
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
bool doRewrite = Random().NextBoolean();
- Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doRewrite, PackedInts.DEFAULT, true, 15);
+ Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doRewrite, PackedInt32s.DEFAULT, true, 15);
bool storeOrd = Random().NextBoolean();
if (VERBOSE)
@@ -367,7 +367,7 @@ namespace Lucene.Net.Util.Fst
Terms terms = MultiFields.GetTerms(r, "body");
if (terms != null)
{
- IntsRef scratchIntsRef = new IntsRef();
+ Int32sRef scratchIntsRef = new Int32sRef();
TermsEnum termsEnum = terms.GetIterator(null);
if (VERBOSE)
{
@@ -536,17 +536,17 @@ namespace Lucene.Net.Util.Fst
this.Outputs = outputs;
this.DoPack = doPack;
- Builder = new Builder<T>(inputMode == 0 ? FST.INPUT_TYPE.BYTE1 : FST.INPUT_TYPE.BYTE4, 0, prune, prune == 0, true, int.MaxValue, outputs, null, doPack, PackedInts.DEFAULT, !noArcArrays, 15);
+ Builder = new Builder<T>(inputMode == 0 ? FST.INPUT_TYPE.BYTE1 : FST.INPUT_TYPE.BYTE4, 0, prune, prune == 0, true, int.MaxValue, outputs, null, doPack, PackedInt32s.DEFAULT, !noArcArrays, 15);
}
- protected internal abstract T GetOutput(IntsRef input, int ord);
+ protected internal abstract T GetOutput(Int32sRef input, int ord);
public virtual void Run(int limit, bool verify, bool verifyByOutput)
{
TextReader @is = new StreamReader(new FileStream(WordsFileIn, FileMode.Open), Encoding.UTF8);
try
{
- IntsRef intsRef = new IntsRef(10);
+ Int32sRef intsRef = new Int32sRef(10);
long tStart = Environment.TickCount;
int ord = 0;
while (true)
@@ -650,7 +650,7 @@ namespace Lucene.Net.Util.Fst
{
// Get by output
long? output = GetOutput(intsRef, ord) as long?;
- IntsRef actual = Util.GetByOutput(fst as FST<long?>, output.GetValueOrDefault());
+ Int32sRef actual = Util.GetByOutput(fst as FST<long?>, output.GetValueOrDefault());
if (actual == null)
{
throw new Exception("unexpected null input from output=" + output);
@@ -826,7 +826,7 @@ namespace Lucene.Net.Util.Fst
}
internal Random rand;
- protected internal override Pair GetOutput(IntsRef input, int ord)
+ protected internal override Pair GetOutput(Int32sRef input, int ord)
{
if (ord == 0)
{
@@ -838,12 +838,12 @@ namespace Lucene.Net.Util.Fst
private class VisitTermsAnonymousInnerClassHelper2 : VisitTerms<long?>
{
- public VisitTermsAnonymousInnerClassHelper2(string dirOut, string wordsFileIn, int inputMode, int prune, PositiveIntOutputs outputs, bool doPack, bool noArcArrays)
+ public VisitTermsAnonymousInnerClassHelper2(string dirOut, string wordsFileIn, int inputMode, int prune, PositiveInt32Outputs outputs, bool doPack, bool noArcArrays)
: base(dirOut, wordsFileIn, inputMode, prune, outputs, doPack, noArcArrays)
{
}
- protected internal override long? GetOutput(IntsRef input, int ord)
+ protected internal override long? GetOutput(Int32sRef input, int ord)
{
return ord;
}
@@ -851,13 +851,13 @@ namespace Lucene.Net.Util.Fst
private class VisitTermsAnonymousInnerClassHelper3 : VisitTerms<long?>
{
- public VisitTermsAnonymousInnerClassHelper3(string dirOut, string wordsFileIn, int inputMode, int prune, PositiveIntOutputs outputs, bool doPack, bool noArcArrays)
+ public VisitTermsAnonymousInnerClassHelper3(string dirOut, string wordsFileIn, int inputMode, int prune, PositiveInt32Outputs outputs, bool doPack, bool noArcArrays)
: base(dirOut, wordsFileIn, inputMode, prune, outputs, doPack, noArcArrays)
{
}
internal Random rand;
- protected internal override long? GetOutput(IntsRef input, int ord)
+ protected internal override long? GetOutput(Int32sRef input, int ord)
{
if (ord == 0)
{
@@ -877,7 +877,7 @@ namespace Lucene.Net.Util.Fst
this.NO_OUTPUT = NO_OUTPUT;
}
- protected internal override object GetOutput(IntsRef input, int ord)
+ protected internal override object GetOutput(Int32sRef input, int ord)
{
return NO_OUTPUT;
}
@@ -888,7 +888,7 @@ namespace Lucene.Net.Util.Fst
{
Outputs<object> outputs = NoOutputs.Singleton;
Builder<object> b = new Builder<object>(FST.INPUT_TYPE.BYTE1, outputs);
- b.Add(Util.ToInt32sRef(new BytesRef("foobar"), new IntsRef()), outputs.NoOutput);
+ b.Add(Util.ToInt32sRef(new BytesRef("foobar"), new Int32sRef()), outputs.NoOutput);
BytesRefFSTEnum<object> fstEnum = new BytesRefFSTEnum<object>(b.Finish());
Assert.IsNull(fstEnum.SeekFloor(new BytesRef("foo")));
Assert.IsNull(fstEnum.SeekCeil(new BytesRef("foobaz")));
@@ -901,7 +901,7 @@ namespace Lucene.Net.Util.Fst
string str = "foobar";
Outputs<object> outputs = NoOutputs.Singleton;
Builder<object> b = new Builder<object>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef ints = new IntsRef();
+ Int32sRef ints = new Int32sRef();
for (int i = 0; i < 10; i++)
{
b.Add(Util.ToInt32sRef(new BytesRef(str), ints), outputs.NoOutput);
@@ -970,7 +970,7 @@ namespace Lucene.Net.Util.Fst
// smaller FST if the outputs grow monotonically. But
// if numbers are "random", false should give smaller
// final size:
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
// Build an FST mapping BytesRef -> Long
Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);
@@ -979,9 +979,9 @@ namespace Lucene.Net.Util.Fst
BytesRef b = new BytesRef("b");
BytesRef c = new BytesRef("c");
- builder.Add(Util.ToInt32sRef(a, new IntsRef()), 17L);
- builder.Add(Util.ToInt32sRef(b, new IntsRef()), 42L);
- builder.Add(Util.ToInt32sRef(c, new IntsRef()), 13824324872317238L);
+ builder.Add(Util.ToInt32sRef(a, new Int32sRef()), 17L);
+ builder.Add(Util.ToInt32sRef(b, new Int32sRef()), 42L);
+ builder.Add(Util.ToInt32sRef(c, new Int32sRef()), 13824324872317238L);
FST<long?> fst = builder.Finish();
@@ -1006,10 +1006,10 @@ namespace Lucene.Net.Util.Fst
Assert.AreEqual(b, seekResult.Input);
Assert.AreEqual(42, seekResult.Output);
- Assert.AreEqual(Util.ToInt32sRef(new BytesRef("c"), new IntsRef()), Util.GetByOutput(fst, 13824324872317238L));
+ Assert.AreEqual(Util.ToInt32sRef(new BytesRef("c"), new Int32sRef()), Util.GetByOutput(fst, 13824324872317238L));
Assert.IsNull(Util.GetByOutput(fst, 47));
- Assert.AreEqual(Util.ToInt32sRef(new BytesRef("b"), new IntsRef()), Util.GetByOutput(fst, 42));
- Assert.AreEqual(Util.ToInt32sRef(new BytesRef("a"), new IntsRef()), Util.GetByOutput(fst, 17));
+ Assert.AreEqual(Util.ToInt32sRef(new BytesRef("b"), new Int32sRef()), Util.GetByOutput(fst, 42));
+ Assert.AreEqual(Util.ToInt32sRef(new BytesRef("a"), new Int32sRef()), Util.GetByOutput(fst, 17));
}
[Test]
@@ -1277,7 +1277,7 @@ namespace Lucene.Net.Util.Fst
int line = 0;
BytesRef term = new BytesRef();
- IntsRef scratchIntsRef = new IntsRef();
+ Int32sRef scratchIntsRef = new Int32sRef();
while (line < lines.Length)
{
@@ -1338,11 +1338,11 @@ namespace Lucene.Net.Util.Fst
[Test]
public virtual void TestFinalOutputOnEndState()
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
- Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE4, 2, 0, true, true, int.MaxValue, outputs, null, Random().NextBoolean(), PackedInts.DEFAULT, true, 15);
- builder.Add(Util.ToUTF32("stat", new IntsRef()), 17L);
- builder.Add(Util.ToUTF32("station", new IntsRef()), 10L);
+ Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE4, 2, 0, true, true, int.MaxValue, outputs, null, Random().NextBoolean(), PackedInt32s.DEFAULT, true, 15);
+ builder.Add(Util.ToUTF32("stat", new Int32sRef()), 17L);
+ builder.Add(Util.ToUTF32("station", new Int32sRef()), 10L);
FST<long?> fst = builder.Finish();
//Writer w = new OutputStreamWriter(new FileOutputStream("/x/tmp3/out.dot"));
StringWriter w = new StringWriter();
@@ -1355,11 +1355,11 @@ namespace Lucene.Net.Util.Fst
[Test]
public virtual void TestInternalFinalState()
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
bool willRewrite = Random().NextBoolean();
- Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, willRewrite, PackedInts.DEFAULT, true, 15);
- builder.Add(Util.ToInt32sRef(new BytesRef("stat"), new IntsRef()), outputs.NoOutput);
- builder.Add(Util.ToInt32sRef(new BytesRef("station"), new IntsRef()), outputs.NoOutput);
+ Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, willRewrite, PackedInt32s.DEFAULT, true, 15);
+ builder.Add(Util.ToInt32sRef(new BytesRef("stat"), new Int32sRef()), outputs.NoOutput);
+ builder.Add(Util.ToInt32sRef(new BytesRef("station"), new Int32sRef()), outputs.NoOutput);
FST<long?> fst = builder.Finish();
StringWriter w = new StringWriter();
//Writer w = new OutputStreamWriter(new FileOutputStream("/x/tmp/out.dot"));
@@ -1378,11 +1378,11 @@ namespace Lucene.Net.Util.Fst
[Test]
public virtual void TestNonFinalStopNode()
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
long? nothing = outputs.NoOutput;
Builder<long?> b = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);
- FST<long?> fst = new FST<long?>(FST.INPUT_TYPE.BYTE1, outputs, false, PackedInts.COMPACT, true, 15);
+ FST<long?> fst = new FST<long?>(FST.INPUT_TYPE.BYTE1, outputs, false, PackedInt32s.COMPACT, true, 15);
Builder.UnCompiledNode<long?> rootNode = new Builder.UnCompiledNode<long?>(b, 0);
@@ -1432,7 +1432,7 @@ namespace Lucene.Net.Util.Fst
dir.Dispose();
}
- private void CheckStopNodes(FST<long?> fst, PositiveIntOutputs outputs)
+ private void CheckStopNodes(FST<long?> fst, PositiveInt32Outputs outputs)
{
long? nothing = outputs.NoOutput;
FST.Arc<long?> startArc = fst.GetFirstArc(new FST.Arc<long?>());
@@ -1467,10 +1467,10 @@ namespace Lucene.Net.Util.Fst
[Test]
public virtual void TestShortestPaths()
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef scratch = new IntsRef();
+ Int32sRef scratch = new Int32sRef();
builder.Add(Util.ToInt32sRef(new BytesRef("aab"), scratch), 22L);
builder.Add(Util.ToInt32sRef(new BytesRef("aac"), scratch), 7L);
builder.Add(Util.ToInt32sRef(new BytesRef("ax"), scratch), 17L);
@@ -1495,10 +1495,10 @@ namespace Lucene.Net.Util.Fst
[Test]
public virtual void TestRejectNoLimits()
{
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef scratch = new IntsRef();
+ Int32sRef scratch = new Int32sRef();
builder.Add(Util.ToInt32sRef(new BytesRef("aab"), scratch), 22L);
builder.Add(Util.ToInt32sRef(new BytesRef("aac"), scratch), 7L);
builder.Add(Util.ToInt32sRef(new BytesRef("adcd"), scratch), 17L);
@@ -1506,10 +1506,10 @@ namespace Lucene.Net.Util.Fst
builder.Add(Util.ToInt32sRef(new BytesRef("ax"), scratch), 17L);
FST<long?> fst = builder.Finish();
- AtomicInteger rejectCount = new AtomicInteger();
+ AtomicInt32 rejectCount = new AtomicInt32();
Util.TopNSearcher<long?> searcher = new TopNSearcherAnonymousInnerClassHelper(this, fst, minLongComparer, rejectCount);
- searcher.AddStartPaths(fst.GetFirstArc(new FST.Arc<long?>()), outputs.NoOutput, true, new IntsRef());
+ searcher.AddStartPaths(fst.GetFirstArc(new FST.Arc<long?>()), outputs.NoOutput, true, new Int32sRef());
Util.TopResults<long?> res = searcher.Search();
Assert.AreEqual(rejectCount.Get(), 4);
Assert.IsTrue(res.IsComplete); // rejected(4) + topN(2) <= maxQueueSize(6)
@@ -1520,7 +1520,7 @@ namespace Lucene.Net.Util.Fst
rejectCount.Set(0);
searcher = new TopNSearcherAnonymousInnerClassHelper2(this, fst, minLongComparer, rejectCount);
- searcher.AddStartPaths(fst.GetFirstArc(new FST.Arc<long?>()), outputs.NoOutput, true, new IntsRef());
+ searcher.AddStartPaths(fst.GetFirstArc(new FST.Arc<long?>()), outputs.NoOutput, true, new Int32sRef());
res = searcher.Search();
Assert.AreEqual(rejectCount.Get(), 4);
Assert.IsFalse(res.IsComplete); // rejected(4) + topN(2) > maxQueueSize(5)
@@ -1530,16 +1530,16 @@ namespace Lucene.Net.Util.Fst
{
private readonly TestFSTs OuterInstance;
- private AtomicInteger RejectCount;
+ private AtomicInt32 RejectCount;
- public TopNSearcherAnonymousInnerClassHelper(TestFSTs outerInstance, FST<long?> fst, IComparer<long?> minLongComparer, AtomicInteger rejectCount)
+ public TopNSearcherAnonymousInnerClassHelper(TestFSTs outerInstance, FST<long?> fst, IComparer<long?> minLongComparer, AtomicInt32 rejectCount)
: base(fst, 2, 6, minLongComparer)
{
this.OuterInstance = outerInstance;
this.RejectCount = rejectCount;
}
- protected override bool AcceptResult(IntsRef input, long? output)
+ protected override bool AcceptResult(Int32sRef input, long? output)
{
bool accept = (int)output == 7;
if (!accept)
@@ -1554,16 +1554,16 @@ namespace Lucene.Net.Util.Fst
{
private readonly TestFSTs OuterInstance;
- private AtomicInteger RejectCount;
+ private AtomicInt32 RejectCount;
- public TopNSearcherAnonymousInnerClassHelper2(TestFSTs outerInstance, FST<long?> fst, IComparer<long?> minLongComparer, AtomicInteger rejectCount)
+ public TopNSearcherAnonymousInnerClassHelper2(TestFSTs outerInstance, FST<long?> fst, IComparer<long?> minLongComparer, AtomicInt32 rejectCount)
: base(fst, 2, 5, minLongComparer)
{
this.OuterInstance = outerInstance;
this.RejectCount = rejectCount;
}
- protected override bool AcceptResult(IntsRef input, long? output)
+ protected override bool AcceptResult(Int32sRef input, long? output)
{
bool accept = (int)output == 7;
if (!accept)
@@ -1595,11 +1595,11 @@ namespace Lucene.Net.Util.Fst
public virtual void TestShortestPathsWFST()
{
- PairOutputs<long?, long?> outputs = new PairOutputs<long?, long?>(PositiveIntOutputs.Singleton, PositiveIntOutputs.Singleton); // output - weight
+ PairOutputs<long?, long?> outputs = new PairOutputs<long?, long?>(PositiveInt32Outputs.Singleton, PositiveInt32Outputs.Singleton); // output - weight
Builder<Pair> builder = new Builder<Pair>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef scratch = new IntsRef();
+ Int32sRef scratch = new Int32sRef();
builder.Add(Util.ToInt32sRef(new BytesRef("aab"), scratch), outputs.NewPair(22L, 57L));
builder.Add(Util.ToInt32sRef(new BytesRef("aac"), scratch), outputs.NewPair(7L, 36L));
builder.Add(Util.ToInt32sRef(new BytesRef("ax"), scratch), outputs.NewPair(17L, 85L));
@@ -1634,9 +1634,9 @@ namespace Lucene.Net.Util.Fst
SortedDictionary<string, long> slowCompletor = new SortedDictionary<string, long>();
SortedSet<string> allPrefixes = new SortedSet<string>();
- PositiveIntOutputs outputs = PositiveIntOutputs.Singleton;
+ PositiveInt32Outputs outputs = PositiveInt32Outputs.Singleton;
Builder<long?> builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef scratch = new IntsRef();
+ Int32sRef scratch = new Int32sRef();
for (int i = 0; i < numWords; i++)
{
@@ -1703,7 +1703,7 @@ namespace Lucene.Net.Util.Fst
if (e.Key.StartsWith(prefix))
{
//System.out.println(" consider " + e.getKey());
- matches.Add(new Util.Result<long?>(Util.ToInt32sRef(new BytesRef(e.Key.Substring(prefix.Length)), new IntsRef()), e.Value - prefixOutput));
+ matches.Add(new Util.Result<long?>(Util.ToInt32sRef(new BytesRef(e.Key.Substring(prefix.Length)), new Int32sRef()), e.Value - prefixOutput));
}
}
@@ -1773,9 +1773,9 @@ namespace Lucene.Net.Util.Fst
SortedDictionary<string, TwoLongs> slowCompletor = new SortedDictionary<string, TwoLongs>();
SortedSet<string> allPrefixes = new SortedSet<string>();
- PairOutputs<long?, long?> outputs = new PairOutputs<long?, long?>(PositiveIntOutputs.Singleton, PositiveIntOutputs.Singleton); // output - weight
+ PairOutputs<long?, long?> outputs = new PairOutputs<long?, long?>(PositiveInt32Outputs.Singleton, PositiveInt32Outputs.Singleton); // output - weight
Builder<Pair> builder = new Builder<Pair>(FST.INPUT_TYPE.BYTE1, outputs);
- IntsRef scratch = new IntsRef();
+ Int32sRef scratch = new Int32sRef();
Random random = Random();
for (int i = 0; i < numWords; i++)
@@ -1845,7 +1845,7 @@ namespace Lucene.Net.Util.Fst
if (e.Key.StartsWith(prefix))
{
//System.out.println(" consider " + e.getKey());
- matches.Add(new Util.Result<Pair>(Util.ToInt32sRef(new BytesRef(e.Key.Substring(prefix.Length)), new IntsRef()),
+ matches.Add(new Util.Result<Pair>(Util.ToInt32sRef(new BytesRef(e.Key.Substring(prefix.Length)), new Int32sRef()),
outputs.NewPair(e.Value.a - prefixOutput.Output1, e.Value.b - prefixOutput.Output2)));
}
}
@@ -1875,7 +1875,7 @@ namespace Lucene.Net.Util.Fst
Builder<BytesRef> builder = new Builder<BytesRef>(FST.INPUT_TYPE.BYTE1, outputs);
byte[] bytes = new byte[300];
- IntsRef input = new IntsRef();
+ Int32sRef input = new Int32sRef();
input.Grow(1);
input.Length = 1;
BytesRef output = new BytesRef(bytes);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs b/src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs
index 35de442..6c64516 100644
--- a/src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs
+++ b/src/Lucene.Net.Tests/core/Util/Packed/TestPackedInts.cs
@@ -34,7 +34,7 @@ namespace Lucene.Net.Util.Packed
using IndexOutput = Lucene.Net.Store.IndexOutput;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
//using Slow = Lucene.Net.Util.LuceneTestCase.Slow;
- using Reader = Lucene.Net.Util.Packed.PackedInts.Reader;
+ using Reader = Lucene.Net.Util.Packed.PackedInt32s.Reader;
using Attributes;
[TestFixture]
@@ -47,14 +47,14 @@ namespace Lucene.Net.Util.Packed
for (int i = 0; i < iters; ++i)
{
int valueCount = RandomInts.NextIntBetween(Random(), 1, int.MaxValue);
- foreach (PackedInts.Format format in PackedInts.Format.Values())
+ foreach (PackedInt32s.Format format in PackedInt32s.Format.Values())
{
for (int bpv = 1; bpv <= 64; ++bpv)
{
- long byteCount = format.ByteCount(PackedInts.VERSION_CURRENT, valueCount, bpv);
+ long byteCount = format.ByteCount(PackedInt32s.VERSION_CURRENT, valueCount, bpv);
string msg = "format=" + format + ", byteCount=" + byteCount + ", valueCount=" + valueCount + ", bpv=" + bpv;
Assert.IsTrue(byteCount * 8 >= (long)valueCount * bpv, msg);
- if (format == PackedInts.Format.PACKED)
+ if (format == PackedInt32s.Format.PACKED)
{
Assert.IsTrue((byteCount - 1) * 8 < (long)valueCount * bpv, msg);
}
@@ -66,20 +66,20 @@ namespace Lucene.Net.Util.Packed
[Test]
public virtual void TestBitsRequired()
{
- Assert.AreEqual(61, PackedInts.BitsRequired((long)Math.Pow(2, 61) - 1));
- Assert.AreEqual(61, PackedInts.BitsRequired(0x1FFFFFFFFFFFFFFFL));
- Assert.AreEqual(62, PackedInts.BitsRequired(0x3FFFFFFFFFFFFFFFL));
- Assert.AreEqual(63, PackedInts.BitsRequired(0x7FFFFFFFFFFFFFFFL));
+ Assert.AreEqual(61, PackedInt32s.BitsRequired((long)Math.Pow(2, 61) - 1));
+ Assert.AreEqual(61, PackedInt32s.BitsRequired(0x1FFFFFFFFFFFFFFFL));
+ Assert.AreEqual(62, PackedInt32s.BitsRequired(0x3FFFFFFFFFFFFFFFL));
+ Assert.AreEqual(63, PackedInt32s.BitsRequired(0x7FFFFFFFFFFFFFFFL));
}
[Test]
public virtual void TestMaxValues()
{
- Assert.AreEqual(1, PackedInts.MaxValue(1), "1 bit -> max == 1");
- Assert.AreEqual(3, PackedInts.MaxValue(2), "2 bit -> max == 3");
- Assert.AreEqual(255, PackedInts.MaxValue(8), "8 bit -> max == 255");
- Assert.AreEqual(long.MaxValue, PackedInts.MaxValue(63), "63 bit -> max == Long.MAX_VALUE");
- Assert.AreEqual(long.MaxValue, PackedInts.MaxValue(64), "64 bit -> max == Long.MAX_VALUE (same as for 63 bit)");
+ Assert.AreEqual(1, PackedInt32s.MaxValue(1), "1 bit -> max == 1");
+ Assert.AreEqual(3, PackedInt32s.MaxValue(2), "2 bit -> max == 3");
+ Assert.AreEqual(255, PackedInt32s.MaxValue(8), "8 bit -> max == 255");
+ Assert.AreEqual(long.MaxValue, PackedInt32s.MaxValue(63), "63 bit -> max == Long.MAX_VALUE");
+ Assert.AreEqual(long.MaxValue, PackedInt32s.MaxValue(64), "64 bit -> max == Long.MAX_VALUE (same as for 63 bit)");
}
[Test]
@@ -90,7 +90,7 @@ namespace Lucene.Net.Util.Packed
{
for (int nbits = 1; nbits <= 64; nbits++)
{
- long maxValue = PackedInts.MaxValue(nbits);
+ long maxValue = PackedInt32s.MaxValue(nbits);
int valueCount = TestUtil.NextInt(Random(), 1, 600);
int bufferSize = Random().NextBoolean() ? TestUtil.NextInt(Random(), 0, 48) : TestUtil.NextInt(Random(), 0, 4096);
Directory d = NewDirectory();
@@ -106,7 +106,7 @@ namespace Lucene.Net.Util.Packed
{
acceptableOverhead = Random().NextFloat();
}
- PackedInts.Writer w = PackedInts.GetWriter(@out, valueCount, nbits, acceptableOverhead);
+ PackedInt32s.Writer w = PackedInt32s.GetWriter(@out, valueCount, nbits, acceptableOverhead);
long startFp = @out.FilePointer;
int actualValueCount = Random().NextBoolean() ? valueCount : TestUtil.NextInt(Random(), 0, valueCount);
@@ -128,13 +128,13 @@ namespace Lucene.Net.Util.Packed
@out.Dispose();
// ensure that finish() added the (valueCount-actualValueCount) missing values
- long bytes = w.Format.ByteCount(PackedInts.VERSION_CURRENT, valueCount, w.BitsPerValue);
+ long bytes = w.Format.ByteCount(PackedInt32s.VERSION_CURRENT, valueCount, w.BitsPerValue);
Assert.AreEqual(bytes, fp - startFp);
{ // test header
IndexInput @in = d.OpenInput("out.bin", NewIOContext(Random()));
// header = codec header | bitsPerValue | valueCount | format
- CodecUtil.CheckHeader(@in, PackedInts.CODEC_NAME, PackedInts.VERSION_START, PackedInts.VERSION_CURRENT); // codec header
+ CodecUtil.CheckHeader(@in, PackedInt32s.CODEC_NAME, PackedInt32s.VERSION_START, PackedInt32s.VERSION_CURRENT); // codec header
Assert.AreEqual(w.BitsPerValue, @in.ReadVInt32());
Assert.AreEqual(valueCount, @in.ReadVInt32());
Assert.AreEqual(w.Format.Id, @in.ReadVInt32());
@@ -144,7 +144,7 @@ namespace Lucene.Net.Util.Packed
{ // test reader
IndexInput @in = d.OpenInput("out.bin", NewIOContext(Random()));
- PackedInts.Reader r = PackedInts.GetReader(@in);
+ PackedInt32s.Reader r = PackedInt32s.GetReader(@in);
Assert.AreEqual(fp, @in.FilePointer);
for (int i = 0; i < valueCount; i++)
{
@@ -159,7 +159,7 @@ namespace Lucene.Net.Util.Packed
{ // test reader iterator next
IndexInput @in = d.OpenInput("out.bin", NewIOContext(Random()));
- PackedInts.IReaderIterator r = PackedInts.GetReaderIterator(@in, bufferSize);
+ PackedInt32s.IReaderIterator r = PackedInt32s.GetReaderIterator(@in, bufferSize);
for (int i = 0; i < valueCount; i++)
{
Assert.AreEqual(values[i], r.Next(), "index=" + i + " valueCount=" + valueCount + " nbits=" + nbits + " for " + r.GetType().Name);
@@ -171,12 +171,12 @@ namespace Lucene.Net.Util.Packed
{ // test reader iterator bulk next
IndexInput @in = d.OpenInput("out.bin", NewIOContext(Random()));
- PackedInts.IReaderIterator r = PackedInts.GetReaderIterator(@in, bufferSize);
+ PackedInt32s.IReaderIterator r = PackedInt32s.GetReaderIterator(@in, bufferSize);
int i = 0;
while (i < valueCount)
{
int count = TestUtil.NextInt(Random(), 1, 95);
- LongsRef next = r.Next(count);
+ Int64sRef next = r.Next(count);
for (int k = 0; k < next.Length; ++k)
{
Assert.AreEqual(values[i + k], next.Int64s[next.Offset + k], "index=" + i + " valueCount=" + valueCount + " nbits=" + nbits + " for " + r.GetType().Name);
@@ -189,7 +189,7 @@ namespace Lucene.Net.Util.Packed
{ // test direct reader get
IndexInput @in = d.OpenInput("out.bin", NewIOContext(Random()));
- PackedInts.Reader intsEnum = PackedInts.GetDirectReader(@in);
+ PackedInt32s.Reader intsEnum = PackedInt32s.GetDirectReader(@in);
for (int i = 0; i < valueCount; i++)
{
string msg = "index=" + i + " valueCount=" + valueCount + " nbits=" + nbits + " for " + intsEnum.GetType().Name;
@@ -217,11 +217,11 @@ namespace Lucene.Net.Util.Packed
}
@out.Dispose();
IndexInput @in = dir.OpenInput("tests.bin", NewIOContext(Random()));
- for (int version = PackedInts.VERSION_START; version <= PackedInts.VERSION_CURRENT; ++version)
+ for (int version = PackedInt32s.VERSION_START; version <= PackedInt32s.VERSION_CURRENT; ++version)
{
for (int bpv = 1; bpv <= 64; ++bpv)
{
- foreach (PackedInts.Format format in PackedInts.Format.Values())
+ foreach (PackedInt32s.Format format in PackedInt32s.Format.Values())
{
if (!format.IsSupported(bpv))
{
@@ -232,7 +232,7 @@ namespace Lucene.Net.Util.Packed
// test iterator
@in.Seek(0L);
- PackedInts.IReaderIterator it = PackedInts.GetReaderIteratorNoHeader(@in, format, version, valueCount, bpv, RandomInts.NextIntBetween(Random(), 1, 1 << 16));
+ PackedInt32s.IReaderIterator it = PackedInt32s.GetReaderIteratorNoHeader(@in, format, version, valueCount, bpv, RandomInts.NextIntBetween(Random(), 1, 1 << 16));
for (int i = 0; i < valueCount; ++i)
{
it.Next();
@@ -241,13 +241,13 @@ namespace Lucene.Net.Util.Packed
// test direct reader
@in.Seek(0L);
- PackedInts.Reader directReader = PackedInts.GetDirectReaderNoHeader(@in, format, version, valueCount, bpv);
+ PackedInt32s.Reader directReader = PackedInt32s.GetDirectReaderNoHeader(@in, format, version, valueCount, bpv);
directReader.Get(valueCount - 1);
Assert.AreEqual(byteCount, @in.FilePointer, msg);
// test reader
@in.Seek(0L);
- PackedInts.GetReaderNoHeader(@in, format, version, valueCount, bpv);
+ PackedInt32s.GetReaderNoHeader(@in, format, version, valueCount, bpv);
Assert.AreEqual(byteCount, @in.FilePointer, msg);
}
}
@@ -262,8 +262,8 @@ namespace Lucene.Net.Util.Packed
const int VALUE_COUNT = 255;
const int BITS_PER_VALUE = 8;
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(VALUE_COUNT, BITS_PER_VALUE);
- foreach (PackedInts.Mutable packedInt in packedInts)
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(VALUE_COUNT, BITS_PER_VALUE);
+ foreach (PackedInt32s.Mutable packedInt in packedInts)
{
for (int i = 0; i < packedInt.Count; i++)
{
@@ -297,10 +297,10 @@ namespace Lucene.Net.Util.Packed
Console.WriteLine(" valueCount=" + valueCount + " bits1=" + bits1 + " bits2=" + bits2);
}
- PackedInts.Mutable packed1 = PackedInts.GetMutable(valueCount, bits1, PackedInts.COMPACT);
- PackedInts.Mutable packed2 = PackedInts.GetMutable(valueCount, bits2, PackedInts.COMPACT);
+ PackedInt32s.Mutable packed1 = PackedInt32s.GetMutable(valueCount, bits1, PackedInt32s.COMPACT);
+ PackedInt32s.Mutable packed2 = PackedInt32s.GetMutable(valueCount, bits2, PackedInt32s.COMPACT);
- long maxValue = PackedInts.MaxValue(bits1);
+ long maxValue = PackedInt32s.MaxValue(bits1);
for (int i = 0; i < valueCount; i++)
{
long val = TestUtil.NextLong(Random(), 0, maxValue);
@@ -337,7 +337,7 @@ namespace Lucene.Net.Util.Packed
}
else
{
- PackedInts.Copy(packed1, offset, packed2, offset, len, Random().Next(10 * len));
+ PackedInt32s.Copy(packed1, offset, packed2, offset, len, Random().Next(10 * len));
}
/*
@@ -371,12 +371,12 @@ namespace Lucene.Net.Util.Packed
private static void AssertRandomEquality(int valueCount, int bitsPerValue, long randomSeed)
{
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(valueCount, bitsPerValue);
- foreach (PackedInts.Mutable packedInt in packedInts)
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(valueCount, bitsPerValue);
+ foreach (PackedInt32s.Mutable packedInt in packedInts)
{
try
{
- Fill(packedInt, PackedInts.MaxValue(bitsPerValue), randomSeed);
+ Fill(packedInt, PackedInt32s.MaxValue(bitsPerValue), randomSeed);
}
catch (Exception e)
{
@@ -387,9 +387,9 @@ namespace Lucene.Net.Util.Packed
AssertListEquality(packedInts);
}
- private static IList<PackedInts.Mutable> CreatePackedInts(int valueCount, int bitsPerValue)
+ private static IList<PackedInt32s.Mutable> CreatePackedInts(int valueCount, int bitsPerValue)
{
- IList<PackedInts.Mutable> packedInts = new List<PackedInts.Mutable>();
+ IList<PackedInt32s.Mutable> packedInts = new List<PackedInt32s.Mutable>();
if (bitsPerValue <= 8)
{
packedInts.Add(new Direct8(valueCount));
@@ -425,7 +425,7 @@ namespace Lucene.Net.Util.Packed
return packedInts;
}
- private static void Fill(PackedInts.Mutable packedInt, long maxValue, long randomSeed)
+ private static void Fill(PackedInt32s.Mutable packedInt, long maxValue, long randomSeed)
{
Random rnd2 = new Random((int)randomSeed);
for (int i = 0; i < packedInt.Count; i++)
@@ -436,20 +436,20 @@ namespace Lucene.Net.Util.Packed
}
}
- private static void AssertListEquality<T1>(IList<T1> packedInts) where T1 : PackedInts.Reader
+ private static void AssertListEquality<T1>(IList<T1> packedInts) where T1 : PackedInt32s.Reader
{
AssertListEquality("", packedInts);
}
- private static void AssertListEquality<T1>(string message, IList<T1> packedInts) where T1 : PackedInts.Reader
+ private static void AssertListEquality<T1>(string message, IList<T1> packedInts) where T1 : PackedInt32s.Reader
{
if (packedInts.Count == 0)
{
return;
}
- PackedInts.Reader @base = packedInts[0];
+ PackedInt32s.Reader @base = packedInts[0];
int valueCount = @base.Count;
- foreach (PackedInts.Reader packedInt in packedInts)
+ foreach (PackedInt32s.Reader packedInt in packedInts)
{
Assert.AreEqual(valueCount, packedInt.Count, message + ". The number of values should be the same ");
}
@@ -469,15 +469,15 @@ namespace Lucene.Net.Util.Packed
{
Directory dir = NewDirectory();
IndexOutput @out = dir.CreateOutput("out", NewIOContext(Random()));
- PackedInts.Writer w = PackedInts.GetWriter(@out, 1, bitsPerValue, PackedInts.DEFAULT);
- long value = 17L & PackedInts.MaxValue(bitsPerValue);
+ PackedInt32s.Writer w = PackedInt32s.GetWriter(@out, 1, bitsPerValue, PackedInt32s.DEFAULT);
+ long value = 17L & PackedInt32s.MaxValue(bitsPerValue);
w.Add(value);
w.Finish();
long end = @out.FilePointer;
@out.Dispose();
IndexInput @in = dir.OpenInput("out", NewIOContext(Random()));
- Reader reader = PackedInts.GetReader(@in);
+ Reader reader = PackedInt32s.GetReader(@in);
string msg = "Impl=" + w.GetType().Name + ", bitsPerValue=" + bitsPerValue;
Assert.AreEqual(1, reader.Count, msg);
Assert.AreEqual(value, reader.Get(0), msg);
@@ -491,7 +491,7 @@ namespace Lucene.Net.Util.Packed
[Test]
public virtual void TestSecondaryBlockChange()
{
- PackedInts.Mutable mutable = new Packed64(26, 5);
+ PackedInt32s.Mutable mutable = new Packed64(26, 5);
mutable.Set(24, 31);
Assert.AreEqual(31, mutable.Get(24), "The value #24 should be correct");
mutable.Set(4, 16);
@@ -597,9 +597,9 @@ namespace Lucene.Net.Util.Packed
int to = from + Random().Next(valueCount + 1 - from);
for (int bpv = 1; bpv <= 64; ++bpv)
{
- long val = TestUtil.NextLong(Random(), 0, PackedInts.MaxValue(bpv));
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
- foreach (PackedInts.Mutable ints in packedInts)
+ long val = TestUtil.NextLong(Random(), 0, PackedInt32s.MaxValue(bpv));
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
+ foreach (PackedInt32s.Mutable ints in packedInts)
{
string msg = ints.GetType().Name + " bpv=" + bpv + ", from=" + from + ", to=" + to + ", val=" + val;
ints.Fill(0, ints.Count, 1);
@@ -624,7 +624,7 @@ namespace Lucene.Net.Util.Packed
{
// must be > 10 for the bulk reads below
int size = TestUtil.NextInt(Random(), 11, 256);
- Reader packedInts = new PackedInts.NullReader(size);
+ Reader packedInts = new PackedInt32s.NullReader(size);
Assert.AreEqual(0, packedInts.Get(TestUtil.NextInt(Random(), 0, size - 1)));
long[] arr = new long[size + 10];
int r;
@@ -655,10 +655,10 @@ namespace Lucene.Net.Util.Packed
for (int bpv = 1; bpv <= 64; ++bpv)
{
- long mask = PackedInts.MaxValue(bpv);
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
+ long mask = PackedInt32s.MaxValue(bpv);
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
- foreach (PackedInts.Mutable ints in packedInts)
+ foreach (PackedInt32s.Mutable ints in packedInts)
{
for (int i = 0; i < ints.Count; ++i)
{
@@ -699,14 +699,14 @@ namespace Lucene.Net.Util.Packed
for (int bpv = 1; bpv <= 64; ++bpv)
{
- long mask = PackedInts.MaxValue(bpv);
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
+ long mask = PackedInt32s.MaxValue(bpv);
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
for (int i = 0; i < arr.Length; ++i)
{
arr[i] = (31L * i + 19) & mask;
}
- foreach (PackedInts.Mutable ints in packedInts)
+ foreach (PackedInt32s.Mutable ints in packedInts)
{
string msg = ints.GetType().Name + " valueCount=" + valueCount + ", index=" + index + ", len=" + len + ", off=" + off;
int sets = ints.Set(index, arr, off, len);
@@ -740,17 +740,17 @@ namespace Lucene.Net.Util.Packed
for (int bpv = 1; bpv <= 64; ++bpv)
{
- long mask = PackedInts.MaxValue(bpv);
- foreach (PackedInts.Mutable r1 in CreatePackedInts(valueCount, bpv))
+ long mask = PackedInt32s.MaxValue(bpv);
+ foreach (PackedInt32s.Mutable r1 in CreatePackedInts(valueCount, bpv))
{
for (int i = 0; i < r1.Count; ++i)
{
r1.Set(i, (31L * i - 1023) & mask);
}
- foreach (PackedInts.Mutable r2 in CreatePackedInts(valueCount, bpv))
+ foreach (PackedInt32s.Mutable r2 in CreatePackedInts(valueCount, bpv))
{
string msg = "src=" + r1 + ", dest=" + r2 + ", srcPos=" + off1 + ", destPos=" + off2 + ", len=" + len + ", mem=" + mem;
- PackedInts.Copy(r1, off1, r2, off2, len, mem);
+ PackedInt32s.Copy(r1, off1, r2, off2, len, mem);
for (int i = 0; i < r2.Count; ++i)
{
string m = msg + ", i=" + i;
@@ -772,7 +772,7 @@ namespace Lucene.Net.Util.Packed
public virtual void TestGrowableWriter()
{
int valueCount = 113 + Random().Next(1111);
- GrowableWriter wrt = new GrowableWriter(1, valueCount, PackedInts.DEFAULT);
+ GrowableWriter wrt = new GrowableWriter(1, valueCount, PackedInt32s.DEFAULT);
wrt.Set(4, 2);
wrt.Set(7, 10);
wrt.Set(valueCount - 10, 99);
@@ -804,7 +804,7 @@ namespace Lucene.Net.Util.Packed
Assert.AreEqual(0, writer.Count);
// compare against AppendingDeltaPackedLongBuffer
- AppendingDeltaPackedLongBuffer buf = new AppendingDeltaPackedLongBuffer();
+ AppendingDeltaPackedInt64Buffer buf = new AppendingDeltaPackedInt64Buffer();
int size = Random().Next(1000000);
long max = 5;
for (int i = 0; i < size; ++i)
@@ -812,7 +812,7 @@ namespace Lucene.Net.Util.Packed
buf.Add(TestUtil.NextLong(Random(), 0, max));
if (Rarely())
{
- max = PackedInts.MaxValue(Rarely() ? TestUtil.NextInt(Random(), 0, 63) : TestUtil.NextInt(Random(), 0, 31));
+ max = PackedInt32s.MaxValue(Rarely() ? TestUtil.NextInt(Random(), 0, 63) : TestUtil.NextInt(Random(), 0, 31));
}
}
writer = new PagedGrowableWriter(size, pageSize, TestUtil.NextInt(Random(), 1, 64), Random().NextFloat());
@@ -862,14 +862,14 @@ namespace Lucene.Net.Util.Packed
public virtual void TestPagedMutable()
{
int bitsPerValue = TestUtil.NextInt(Random(), 1, 64);
- long max = PackedInts.MaxValue(bitsPerValue);
+ long max = PackedInt32s.MaxValue(bitsPerValue);
int pageSize = 1 << (TestUtil.NextInt(Random(), 6, 30));
// supports 0 values?
PagedMutable writer = new PagedMutable(0, pageSize, bitsPerValue, Random().NextFloat() / 2);
Assert.AreEqual(0, writer.Count);
// compare against AppendingDeltaPackedLongBuffer
- AppendingDeltaPackedLongBuffer buf = new AppendingDeltaPackedLongBuffer();
+ AppendingDeltaPackedInt64Buffer buf = new AppendingDeltaPackedInt64Buffer();
int size = Random().Next(1000000);
for (int i = 0; i < size; ++i)
@@ -949,10 +949,10 @@ namespace Lucene.Net.Util.Packed
int valueCount = TestUtil.NextInt(Random(), 1, 2048);
for (int bpv = 1; bpv <= 64; ++bpv)
{
- int maxValue = (int)Math.Min(PackedInts.MaxValue(31), PackedInts.MaxValue(bpv));
+ int maxValue = (int)Math.Min(PackedInt32s.MaxValue(31), PackedInt32s.MaxValue(bpv));
RAMDirectory directory = new RAMDirectory();
- IList<PackedInts.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
- foreach (PackedInts.Mutable mutable in packedInts)
+ IList<PackedInt32s.Mutable> packedInts = CreatePackedInts(valueCount, bpv);
+ foreach (PackedInt32s.Mutable mutable in packedInts)
{
for (int i = 0; i < mutable.Count; ++i)
{
@@ -964,7 +964,7 @@ namespace Lucene.Net.Util.Packed
@out.Dispose();
IndexInput @in = directory.OpenInput("packed-ints.bin", IOContext.DEFAULT);
- PackedInts.Reader reader = PackedInts.GetReader(@in);
+ PackedInt32s.Reader reader = PackedInt32s.GetReader(@in);
Assert.AreEqual(mutable.BitsPerValue, reader.BitsPerValue);
Assert.AreEqual(valueCount, reader.Count);
if (mutable is Packed64SingleBlock)
@@ -992,7 +992,7 @@ namespace Lucene.Net.Util.Packed
[Test]
public virtual void TestEncodeDecode()
{
- foreach (PackedInts.Format format in PackedInts.Format.Values())
+ foreach (PackedInt32s.Format format in PackedInt32s.Format.Values())
{
for (int bpv = 1; bpv <= 64; ++bpv)
{
@@ -1002,8 +1002,8 @@ namespace Lucene.Net.Util.Packed
}
string msg = format + " " + bpv;
- PackedInts.IEncoder encoder = PackedInts.GetEncoder(format, PackedInts.VERSION_CURRENT, bpv);
- PackedInts.IDecoder decoder = PackedInts.GetDecoder(format, PackedInts.VERSION_CURRENT, bpv);
+ PackedInt32s.IEncoder encoder = PackedInt32s.GetEncoder(format, PackedInt32s.VERSION_CURRENT, bpv);
+ PackedInt32s.IDecoder decoder = PackedInt32s.GetDecoder(format, PackedInt32s.VERSION_CURRENT, bpv);
int longBlockCount = encoder.Int64BlockCount;
int longValueCount = encoder.Int64ValueCount;
int byteBlockCount = encoder.ByteBlockCount;
@@ -1026,7 +1026,7 @@ namespace Lucene.Net.Util.Packed
for (int i = 0; i < blocks.Length; ++i)
{
blocks[i] = Random().NextLong();
- if (format == PackedInts.Format.PACKED_SINGLE_BLOCK && 64 % bpv != 0)
+ if (format == PackedInt32s.Format.PACKED_SINGLE_BLOCK && 64 % bpv != 0)
{
// clear highest bits for packed
int toClear = 64 % bpv;
@@ -1039,7 +1039,7 @@ namespace Lucene.Net.Util.Packed
decoder.Decode(blocks, blocksOffset, values, valuesOffset, longIterations);
foreach (long value in values)
{
- Assert.IsTrue(value <= PackedInts.MaxValue(bpv));
+ Assert.IsTrue(value <= PackedInt32s.MaxValue(bpv));
}
// test decoding to int[]
int[] intValues;
@@ -1073,7 +1073,7 @@ namespace Lucene.Net.Util.Packed
decoder.Decode(byteBlocks, blocksOffset * 8, values2, valuesOffset, byteIterations);
foreach (long value in values2)
{
- Assert.IsTrue(value <= PackedInts.MaxValue(bpv), msg);
+ Assert.IsTrue(value <= PackedInt32s.MaxValue(bpv), msg);
}
Assert.AreEqual(values, values2, msg);
// test decoding to int[]
@@ -1087,7 +1087,7 @@ namespace Lucene.Net.Util.Packed
// 5. byte[] encoding
byte[] blocks3_ = new byte[8 * (blocksOffset2 + blocksLen)];
encoder.Encode(values, valuesOffset, blocks3_, 8 * blocksOffset2, byteIterations);
- assertEquals(msg, LongBuffer.Wrap(blocks2), ByteBuffer.Wrap(blocks3_).AsInt64Buffer());
+ assertEquals(msg, Int64Buffer.Wrap(blocks2), ByteBuffer.Wrap(blocks3_).AsInt64Buffer());
// test encoding from int[]
if (bpv <= 32)
{
@@ -1132,7 +1132,7 @@ namespace Lucene.Net.Util.Packed
{
long[] arr = new long[RandomInts.NextIntBetween(Random(), 1, 1000000)];
- float[] ratioOptions = new float[] { PackedInts.DEFAULT, PackedInts.COMPACT, PackedInts.FAST };
+ float[] ratioOptions = new float[] { PackedInt32s.DEFAULT, PackedInt32s.COMPACT, PackedInt32s.FAST };
foreach (int bpv in new int[] { 0, 1, 63, 64, RandomInts.NextIntBetween(Random(), 2, 62) })
{
foreach (DataType dataType in Enum.GetValues(typeof(DataType)))
@@ -1140,20 +1140,20 @@ namespace Lucene.Net.Util.Packed
int pageSize = 1 << TestUtil.NextInt(Random(), 6, 20);
int initialPageCount = TestUtil.NextInt(Random(), 0, 16);
float acceptableOverheadRatio = ratioOptions[TestUtil.NextInt(Random(), 0, ratioOptions.Length - 1)];
- AbstractAppendingLongBuffer buf;
+ AbstractAppendingInt64Buffer buf;
int inc;
switch (dataType)
{
case Lucene.Net.Util.Packed.TestPackedInts.DataType.PACKED:
- buf = new AppendingPackedLongBuffer(initialPageCount, pageSize, acceptableOverheadRatio);
+ buf = new AppendingPackedInt64Buffer(initialPageCount, pageSize, acceptableOverheadRatio);
inc = 0;
break;
case Lucene.Net.Util.Packed.TestPackedInts.DataType.DELTA_PACKED:
- buf = new AppendingDeltaPackedLongBuffer(initialPageCount, pageSize, acceptableOverheadRatio);
+ buf = new AppendingDeltaPackedInt64Buffer(initialPageCount, pageSize, acceptableOverheadRatio);
inc = 0;
break;
case Lucene.Net.Util.Packed.TestPackedInts.DataType.MONOTONIC:
- buf = new MonotonicAppendingLongBuffer(initialPageCount, pageSize, acceptableOverheadRatio);
+ buf = new MonotonicAppendingInt64Buffer(initialPageCount, pageSize, acceptableOverheadRatio);
inc = TestUtil.NextInt(Random(), -1000, 1000);
break;
default:
@@ -1178,10 +1178,10 @@ namespace Lucene.Net.Util.Packed
}
else
{
- long minValue = TestUtil.NextLong(Random(), long.MinValue, long.MaxValue - PackedInts.MaxValue(bpv));
+ long minValue = TestUtil.NextLong(Random(), long.MinValue, long.MaxValue - PackedInt32s.MaxValue(bpv));
for (int i = 0; i < arr.Length; ++i)
{
- arr[i] = minValue + inc * i + Random().NextLong() & PackedInts.MaxValue(bpv); // TestUtil.nextLong is too slow
+ arr[i] = minValue + inc * i + Random().NextLong() & PackedInt32s.MaxValue(bpv); // TestUtil.nextLong is too slow
}
}
@@ -1206,7 +1206,7 @@ namespace Lucene.Net.Util.Packed
Assert.AreEqual(arr[i], buf.Get(i));
}
- AbstractAppendingLongBuffer.Iterator it = buf.GetIterator();
+ AbstractAppendingInt64Buffer.Iterator it = buf.GetIterator();
for (int i = 0; i < arr.Length; ++i)
{
if (Random().NextBoolean())
@@ -1263,7 +1263,7 @@ namespace Lucene.Net.Util.Packed
}
else
{
- longs[i] = TestUtil.NextLong(Random(), 0, PackedInts.MaxValue(bpv));
+ longs[i] = TestUtil.NextLong(Random(), 0, PackedInt32s.MaxValue(bpv));
}
skip[i] = Rarely();
}
@@ -1352,7 +1352,7 @@ namespace Lucene.Net.Util.Packed
in1.Seek(0L);
ByteArrayDataInput in2 = new ByteArrayDataInput((byte[])(Array)buf);
DataInput @in = Random().NextBoolean() ? (DataInput)in1 : in2;
- BlockPackedReaderIterator it = new BlockPackedReaderIterator(@in, PackedInts.VERSION_CURRENT, blockSize, valueCount);
+ BlockPackedReaderIterator it = new BlockPackedReaderIterator(@in, PackedInt32s.VERSION_CURRENT, blockSize, valueCount);
for (int i = 0; i < valueCount; )
{
if (Random().NextBoolean())
@@ -1362,7 +1362,7 @@ namespace Lucene.Net.Util.Packed
}
else
{
- LongsRef nextValues = it.Next(TestUtil.NextInt(Random(), 1, 1024));
+ Int64sRef nextValues = it.Next(TestUtil.NextInt(Random(), 1, 1024));
for (int j = 0; j < nextValues.Length; ++j)
{
Assert.AreEqual(values[i + j], nextValues.Int64s[nextValues.Offset + j], "" + (i + j));
@@ -1392,7 +1392,7 @@ namespace Lucene.Net.Util.Packed
{
((IndexInput)@in).Seek(0L);
}
- BlockPackedReaderIterator it2 = new BlockPackedReaderIterator(@in, PackedInts.VERSION_CURRENT, blockSize, valueCount);
+ BlockPackedReaderIterator it2 = new BlockPackedReaderIterator(@in, PackedInt32s.VERSION_CURRENT, blockSize, valueCount);
int k = 0;
while (true)
{
@@ -1424,7 +1424,7 @@ namespace Lucene.Net.Util.Packed
}
in1.Seek(0L);
- BlockPackedReader reader = new BlockPackedReader(in1, PackedInts.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
+ BlockPackedReader reader = new BlockPackedReader(in1, PackedInt32s.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
Assert.AreEqual(in1.FilePointer, in1.Length);
for (k = 0; k < valueCount; ++k)
{
@@ -1473,7 +1473,7 @@ namespace Lucene.Net.Util.Packed
@out.Dispose();
IndexInput @in = dir.OpenInput("out.bin", IOContext.DEFAULT);
- MonotonicBlockPackedReader reader = new MonotonicBlockPackedReader(@in, PackedInts.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
+ MonotonicBlockPackedReader reader = new MonotonicBlockPackedReader(@in, PackedInt32s.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
Assert.AreEqual(fp, @in.FilePointer);
for (int i = 0; i < valueCount; ++i)
{
@@ -1520,11 +1520,11 @@ namespace Lucene.Net.Util.Packed
writer.Finish();
@out.Dispose();
IndexInput @in = dir.OpenInput("out.bin", IOContext.DEFAULT);
- BlockPackedReaderIterator it = new BlockPackedReaderIterator(@in, PackedInts.VERSION_CURRENT, blockSize, valueCount);
+ BlockPackedReaderIterator it = new BlockPackedReaderIterator(@in, PackedInt32s.VERSION_CURRENT, blockSize, valueCount);
it.Skip(valueOffset);
Assert.AreEqual(value, it.Next());
@in.Seek(0L);
- BlockPackedReader reader = new BlockPackedReader(@in, PackedInts.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
+ BlockPackedReader reader = new BlockPackedReader(@in, PackedInt32s.VERSION_CURRENT, blockSize, valueCount, Random().NextBoolean());
Assert.AreEqual(value, reader.Get(valueOffset));
for (int i = 0; i < 5; ++i)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8b7f4185/src/Lucene.Net.Tests/core/Util/TestIntsRef.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestIntsRef.cs b/src/Lucene.Net.Tests/core/Util/TestIntsRef.cs
index 7b50d74..4ed5c73 100644
--- a/src/Lucene.Net.Tests/core/Util/TestIntsRef.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestIntsRef.cs
@@ -25,8 +25,8 @@ namespace Lucene.Net.Util
[Test]
public virtual void TestEmpty()
{
- IntsRef i = new IntsRef();
- Assert.AreEqual(IntsRef.EMPTY_INTS, i.Int32s);
+ Int32sRef i = new Int32sRef();
+ Assert.AreEqual(Int32sRef.EMPTY_INTS, i.Int32s);
Assert.AreEqual(0, i.Offset);
Assert.AreEqual(0, i.Length);
}
@@ -35,13 +35,13 @@ namespace Lucene.Net.Util
public virtual void TestFromInts()
{
int[] ints = new int[] { 1, 2, 3, 4 };
- IntsRef i = new IntsRef(ints, 0, 4);
+ Int32sRef i = new Int32sRef(ints, 0, 4);
Assert.AreEqual(ints, i.Int32s);
Assert.AreEqual(0, i.Offset);
Assert.AreEqual(4, i.Length);
- IntsRef i2 = new IntsRef(ints, 1, 3);
- Assert.AreEqual(new IntsRef(new int[] { 2, 3, 4 }, 0, 3), i2);
+ Int32sRef i2 = new Int32sRef(ints, 1, 3);
+ Assert.AreEqual(new Int32sRef(new int[] { 2, 3, 4 }, 0, 3), i2);
Assert.IsFalse(i.Equals(i2));
}