Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
[assembly: CLSCompliant(false)]

#if !CUSTOM_VERSIONING
[assembly: AssemblyVersion("1.6.*")]
[assembly: AssemblyVersion("1.7.*")]
#endif
5 changes: 4 additions & 1 deletion src/Test/IHashFunctionTests_HashFunctionBase.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//! Automatically generated from IHashFunctionTests_HashFunctionBase.tt
//! Direct modifications to this file will be lost.

using Moq;
using System;
using System.Collections.Generic;
using System.Data.HashFunction.Test.Mocks;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Moq;
using MoreLinq;
using Xunit;

namespace System.Data.HashFunction.Test
Expand Down Expand Up @@ -2088,9 +2089,11 @@ protected override IEnumerable<KnownValue> KnownValues
new KnownValue(32, TestConstants.Empty, 0x02cc5d05),
new KnownValue(32, TestConstants.FooBar, 0xeda34aaf),
new KnownValue(32, TestConstants.LoremIpsum, 0x92ea46ac),
new KnownValue(32, TestConstants.LoremIpsum.Take(4), 0x0df3e9ea),
new KnownValue(64, TestConstants.Empty, 0xef46db3751d8e999),
new KnownValue(64, TestConstants.FooBar, 0xa2aa05ed9085aaf9),
new KnownValue(64, TestConstants.LoremIpsum, 0xaf35642971419cbe),
new KnownValue(64, TestConstants.LoremIpsum.Take(4), 0x103460bb4a599cab),
};
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/Test/IHashFunctionTests_HashFunctionBase.json
Original file line number Diff line number Diff line change
Expand Up @@ -1416,12 +1416,14 @@
"Async": true,
"ConstructionParameters": [ "hashSize" ],
"KnownValues": [
{ "Bits": 32, "TestValue": "TestConstants.Empty", "ExpectedValue": "0x02cc5d05" },
{ "Bits": 32, "TestValue": "TestConstants.FooBar", "ExpectedValue": "0xeda34aaf" },
{ "Bits": 32, "TestValue": "TestConstants.LoremIpsum", "ExpectedValue": "0x92ea46ac" },
{ "Bits": 64, "TestValue": "TestConstants.Empty", "ExpectedValue": "0xef46db3751d8e999" },
{ "Bits": 64, "TestValue": "TestConstants.FooBar", "ExpectedValue": "0xa2aa05ed9085aaf9" },
{ "Bits": 64, "TestValue": "TestConstants.LoremIpsum", "ExpectedValue": "0xaf35642971419cbe" }
{ "Bits": 32, "TestValue": "TestConstants.Empty", "ExpectedValue": "0x02cc5d05" },
{ "Bits": 32, "TestValue": "TestConstants.FooBar", "ExpectedValue": "0xeda34aaf" },
{ "Bits": 32, "TestValue": "TestConstants.LoremIpsum", "ExpectedValue": "0x92ea46ac" },
{ "Bits": 32, "TestValue": "TestConstants.LoremIpsum.Take(4)", "ExpectedValue": "0x0df3e9ea" },
{ "Bits": 64, "TestValue": "TestConstants.Empty", "ExpectedValue": "0xef46db3751d8e999" },
{ "Bits": 64, "TestValue": "TestConstants.FooBar", "ExpectedValue": "0xa2aa05ed9085aaf9" },
{ "Bits": 64, "TestValue": "TestConstants.LoremIpsum", "ExpectedValue": "0xaf35642971419cbe" },
{ "Bits": 64, "TestValue": "TestConstants.LoremIpsum.Take(4)", "ExpectedValue": "0x103460bb4a599cab" }
]
},

Expand Down
30 changes: 15 additions & 15 deletions src/xxHash/xxHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected override byte[] ComputeHashInternal(UnifiedData data)
{
var h = ((UInt32) InitVal) + _primes32[4];

int dataCount = 0;
ulong dataCount = 0;
byte[] remainder = null;


Expand All @@ -153,13 +153,13 @@ protected override byte[] ComputeHashInternal(UnifiedData data)
}
}

dataCount += length;
dataCount += (ulong)length;
},
(remainderData, position, length) => {
remainder = new byte[length];
Array.Copy(remainderData, position, remainder, 0, length);

dataCount += length;
dataCount += (ulong)length;
});


Expand All @@ -173,7 +173,7 @@ protected override byte[] ComputeHashInternal(UnifiedData data)
{
var h = InitVal + _primes64[4];

int dataCount = 0;
ulong dataCount = 0;
byte[] remainder = null;

var initValues = new[] {
Expand All @@ -197,13 +197,13 @@ protected override byte[] ComputeHashInternal(UnifiedData data)
}
}

dataCount += length;
dataCount += (ulong) length;
},
(remainderData, position, length) => {
remainder = new byte[length];
Array.Copy(remainderData, position, remainder, 0, length);

dataCount += length;
dataCount += (ulong) length;
});


Expand All @@ -230,7 +230,7 @@ protected override async Task<byte[]> ComputeHashAsyncInternal(UnifiedData data)
{
var h = ((UInt32) InitVal) + _primes32[4];

int dataCount = 0;
ulong dataCount = 0;
byte[] remainder = null;


Expand All @@ -253,13 +253,13 @@ await data.ForEachGroupAsync(16,
}
}

dataCount += length;
dataCount += (ulong) length;
},
(remainderData, position, length) => {
remainder = new byte[length];
Array.Copy(remainderData, position, remainder, 0, length);

dataCount += length;
dataCount += (ulong) length;
}).ConfigureAwait(false);

PostProcess(ref h, initValues, dataCount, remainder);
Expand All @@ -272,7 +272,7 @@ await data.ForEachGroupAsync(16,
{
var h = InitVal + _primes64[4];

int dataCount = 0;
ulong dataCount = 0;
byte[] remainder = null;

var initValues = new[] {
Expand All @@ -295,13 +295,13 @@ await data.ForEachGroupAsync(32,
}
}

dataCount += length;
dataCount += (ulong) length;
},
(remainderData, position, length) => {
remainder = new byte[length];
Array.Copy(remainderData, position, remainder, 0, length);

dataCount += remainder.Length;
dataCount += (ulong) remainder.Length;
}).ConfigureAwait(false);


Expand All @@ -320,7 +320,7 @@ await data.ForEachGroupAsync(32,
#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static void PostProcess(ref UInt32 h, UInt32[] initValues, int dataCount, byte[] remainder)
private static void PostProcess(ref UInt32 h, UInt32[] initValues, ulong dataCount, byte[] remainder)
{
if (dataCount >= 16)
{
Expand Down Expand Up @@ -361,7 +361,7 @@ private static void PostProcess(ref UInt32 h, UInt32[] initValues, int dataCount
#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
private static void PostProcess(ref UInt64 h, UInt64[] initValues, int dataCount, byte[] remainder)
private static void PostProcess(ref UInt64 h, UInt64[] initValues, ulong dataCount, byte[] remainder)
{
if (dataCount >= 32)
{
Expand Down Expand Up @@ -395,7 +395,7 @@ private static void PostProcess(ref UInt64 h, UInt64[] initValues, int dataCount


// Process a 4-byte chunk if it exists
if ((remainder.Length % 8) > 4)
if ((remainder.Length % 8) >= 4)
{
h ^= ((UInt64) BitConverter.ToUInt32(remainder, remainder.Length - (remainder.Length % 8))) * _primes64[0];
h = (h.RotateLeft(23) * _primes64[1]) + _primes64[2];
Expand Down