Lucene.Net.Facet: Renamed all type-derived properties and methods from Short, Int, Long, and Float to match CLR types Int16, Int32, Int64, and Single, respectively.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/bb41cd17 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/bb41cd17 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/bb41cd17 Branch: refs/heads/api-work Commit: bb41cd171a7b6c88c9bf887b393883364d3f971b Parents: ffa0fbf Author: Shad Storhaug <[email protected]> Authored: Tue Feb 7 20:46:02 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Wed Feb 8 21:08:21 2017 +0700 ---------------------------------------------------------------------- .../RandomSamplingFacetsCollector.cs | 14 +++++++++----- src/Lucene.Net.Facet/Range/DoubleRange.cs | 5 ++++- src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs | 4 +++- src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs | 6 ++++-- .../Taxonomy/FloatAssociationFacetField.cs | 16 ++++++++++------ .../Taxonomy/IntAssociationFacetField.cs | 15 +++++++++------ .../Taxonomy/WriterCache/NameHashIntCacheLRU.cs | 4 ++-- .../Taxonomy/TestFacetLabel.cs | 6 +++--- 8 files changed, 44 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/RandomSamplingFacetsCollector.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/RandomSamplingFacetsCollector.cs b/src/Lucene.Net.Facet/RandomSamplingFacetsCollector.cs index d853ebd..40ef17d 100644 --- a/src/Lucene.Net.Facet/RandomSamplingFacetsCollector.cs +++ b/src/Lucene.Net.Facet/RandomSamplingFacetsCollector.cs @@ -65,8 +65,10 @@ namespace Lucene.Net.Facet /// <summary> /// Get the next random long value + /// <para/> + /// NOTE: This was randomLong() in Lucene /// </summary> - public virtual long RandomLong() + public virtual long RandomInt64() { x ^= (x << 21); x ^= ((long)((ulong)x >> 35)); @@ -76,10 +78,12 @@ namespace Lucene.Net.Facet /// <summary> /// Get the next random int, between 0 (inclusive) and <paramref name="n"/> (exclusive) + /// <para/> + /// NOTE: This was nextInt() in Lucene /// </summary> - public virtual int NextInt(int n) + public virtual int NextInt32(int n) { - int res = (int)(RandomLong() % n); + int res = (int)(RandomInt64() % n); return (res < 0) ? -res : res; } } @@ -209,7 +213,7 @@ namespace Lucene.Net.Facet else { limit = binSize; - randomIndex = random.NextInt(binSize); + randomIndex = random.NextInt32(binSize); } DocIdSetIterator it = docs.Bits.GetIterator(); for (int doc = it.NextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.NextDoc()) @@ -223,7 +227,7 @@ namespace Lucene.Net.Facet { counter = 0; limit = binSize; - randomIndex = random.NextInt(binSize); + randomIndex = random.NextInt32(binSize); } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Range/DoubleRange.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Range/DoubleRange.cs b/src/Lucene.Net.Facet/Range/DoubleRange.cs index 3f3d034..c8201bc 100644 --- a/src/Lucene.Net.Facet/Range/DoubleRange.cs +++ b/src/Lucene.Net.Facet/Range/DoubleRange.cs @@ -105,7 +105,10 @@ namespace Lucene.Net.Facet.Range return value >= minIncl && value <= maxIncl; } - internal LongRange ToLongRange() + /// <summary> + /// NOTE: This was toLongRange() in Lucene + /// </summary> + internal LongRange ToInt64Range() { return new LongRange(Label, NumericUtils.DoubleToSortableInt64(minIncl), true, NumericUtils.DoubleToSortableInt64(maxIncl), true); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs b/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs index eca4372..870771f 100644 --- a/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs +++ b/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs @@ -248,8 +248,10 @@ namespace Lucene.Net.Facet.Taxonomy /// <summary> /// Calculate a 64-bit hash function for this path. + /// <para/> + /// NOTE: This was longHashCode() in Lucene /// </summary> - public virtual long LongHashCode() + public virtual long Int64HashCode() { if (Length == 0) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs b/src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs index 10ff894..1a54c0d 100644 --- a/src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs +++ b/src/Lucene.Net.Facet/Taxonomy/FacetLabel.cs @@ -179,9 +179,11 @@ namespace Lucene.Net.Facet.Taxonomy /// Calculate a 64-bit hash function for this path. This /// is necessary for <see cref="NameHashIntCacheLRU"/> (the /// default cache impl for <see cref="LruTaxonomyWriterCache"/>) - /// to reduce the chance of "silent but deadly" collisions. + /// to reduce the chance of "silent but deadly" collisions. + /// <para/> + /// NOTE: This was longHashCode() in Lucene /// </summary> - public virtual long LongHashCode() + public virtual long Int64HashCode() { if (Length == 0) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs b/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs index 67026cc..1257ff6 100644 --- a/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs +++ b/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs @@ -37,30 +37,34 @@ namespace Lucene.Net.Facet.Taxonomy /// float association /// </summary> public FloatAssociationFacetField(float assoc, string dim, params string[] path) - : base(FloatToBytesRef(assoc), dim, path) + : base(SingleToBytesRef(assoc), dim, path) { } /// <summary> /// Encodes a <see cref="float"/> as a 4-byte <see cref="BytesRef"/>. + /// <para/> + /// NOTE: This was floatToBytesRef() in Lucene /// </summary> - public static BytesRef FloatToBytesRef(float v) + public static BytesRef SingleToBytesRef(float v) { - return IntAssociationFacetField.IntToBytesRef(Number.SingleToInt32Bits(v)); + return IntAssociationFacetField.Int32ToBytesRef(Number.SingleToInt32Bits(v)); } /// <summary> /// Decodes a previously encoded <see cref="float"/>. + /// <para/> + /// NOTE: This was bytesRefToFloat() in Lucene /// </summary> - public static float BytesRefToFloat(BytesRef b) + public static float BytesRefToSingle(BytesRef b) { - return Number.Int32BitsToSingle(IntAssociationFacetField.BytesRefToInt(b)); + return Number.Int32BitsToSingle(IntAssociationFacetField.BytesRefToInt32(b)); } public override string ToString() { return "FloatAssociationFacetField(dim=" + Dim + " path=" + Arrays.ToString(Path) + - " value=" + BytesRefToFloat(Assoc).ToString("0.0#####", CultureInfo.InvariantCulture) + ")"; + " value=" + BytesRefToSingle(Assoc).ToString("0.0#####", CultureInfo.InvariantCulture) + ")"; } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Taxonomy/IntAssociationFacetField.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Taxonomy/IntAssociationFacetField.cs b/src/Lucene.Net.Facet/Taxonomy/IntAssociationFacetField.cs index 3cdf528..3385cdb 100644 --- a/src/Lucene.Net.Facet/Taxonomy/IntAssociationFacetField.cs +++ b/src/Lucene.Net.Facet/Taxonomy/IntAssociationFacetField.cs @@ -36,17 +36,18 @@ namespace Lucene.Net.Facet.Taxonomy /// int association /// </summary> public IntAssociationFacetField(int assoc, string dim, params string[] path) - : base(IntToBytesRef(assoc), dim, path) + : base(Int32ToBytesRef(assoc), dim, path) { } /// <summary> /// Encodes an <see cref="int"/> as a 4-byte <see cref="BytesRef"/>, - /// big-endian. + /// big-endian. + /// <para/> + /// NOTE: This was intToBytesRef() in Lucene /// </summary> - public static BytesRef IntToBytesRef(int v) + public static BytesRef Int32ToBytesRef(int v) { - byte[] bytes = new byte[4]; // big-endian: bytes[0] = (byte)(v >> 24); @@ -58,8 +59,10 @@ namespace Lucene.Net.Facet.Taxonomy /// <summary> /// Decodes a previously encoded <see cref="int"/>. + /// <para/> + /// NOTE: This was bytesRefToInt() in Lucene /// </summary> - public static int BytesRefToInt(BytesRef b) + public static int BytesRefToInt32(BytesRef b) { return ((b.Bytes[b.Offset] & 0xFF) << 24) | ((b.Bytes[b.Offset + 1] & 0xFF) << 16) | ((b.Bytes[b.Offset + 2] & 0xFF) << 8) | (b.Bytes[b.Offset + 3] & 0xFF); @@ -67,7 +70,7 @@ namespace Lucene.Net.Facet.Taxonomy public override string ToString() { - return "IntAssociationFacetField(dim=" + Dim + " path=" + Arrays.ToString(Path) + " value=" + BytesRefToInt(Assoc) + ")"; + return "IntAssociationFacetField(dim=" + Dim + " path=" + Arrays.ToString(Path) + " value=" + BytesRefToInt32(Assoc) + ")"; } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameHashIntCacheLRU.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameHashIntCacheLRU.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameHashIntCacheLRU.cs index 40d67f5..7e2c95e 100644 --- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameHashIntCacheLRU.cs +++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameHashIntCacheLRU.cs @@ -35,12 +35,12 @@ internal override object Key(FacetLabel name) { - return new long?(name.LongHashCode()); + return new long?(name.Int64HashCode()); } internal override object Key(FacetLabel name, int prefixLen) { - return new long?(name.Subpath(prefixLen).LongHashCode()); + return new long?(name.Subpath(prefixLen).Int64HashCode()); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bb41cd17/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs index 0226137..2b87829 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/TestFacetLabel.cs @@ -124,9 +124,9 @@ namespace Lucene.Net.Facet.Taxonomy [Test] public virtual void TestLongHashCode() { - Assert.AreEqual((new FacetLabel()).LongHashCode(), (new FacetLabel()).LongHashCode()); - Assert.False((new FacetLabel()).LongHashCode() == (new FacetLabel("hi")).LongHashCode()); - Assert.AreEqual((new FacetLabel("hello", "world")).LongHashCode(), (new FacetLabel("hello", "world")).LongHashCode()); + Assert.AreEqual((new FacetLabel()).Int64HashCode(), (new FacetLabel()).Int64HashCode()); + Assert.False((new FacetLabel()).Int64HashCode() == (new FacetLabel("hi")).Int64HashCode()); + Assert.AreEqual((new FacetLabel("hello", "world")).Int64HashCode(), (new FacetLabel("hello", "world")).Int64HashCode()); } [Test]
