-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from dynatrace-oss/polymurhash
upgraded reference for PolymurHash from 1.0 to 2.0
- Loading branch information
Showing
11 changed files
with
2,124 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
This file includes a Java port of the PolymurHash algorithm originally published | ||
at https://github.com/orlp/polymur-hash under the following license: | ||
|
||
Copyright (c) 2023 Orson Peters | ||
|
||
This software is provided 'as-is', without any express or implied warranty. In | ||
no event will the authors be held liable for any damages arising from the use of | ||
this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, including | ||
commercial applications, and to alter it and redistribute it freely, subject to | ||
the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; you must not claim | ||
that you wrote the original software. If you use this software in a product, | ||
an acknowledgment in the product documentation would be appreciated but is | ||
not required. | ||
|
||
2. Altered source versions must be plainly marked as such, and must not be | ||
misrepresented as being the original software. | ||
|
||
3. This notice may not be removed or altered from any source distribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule polymur-hash
deleted from
ffe06d
2,010 changes: 2,010 additions & 0 deletions
2,010
reference-implementations/polymur-hash_2_0/out.txt
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule polymur-hash
added at
c6cc68
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
reference-implementations/polymur-hash_2_0/reference_data.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2022-2023 Dynatrace LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "polymur-hash/polymur-hash.h" | ||
|
||
#include <iostream> | ||
#include <iomanip> | ||
#include <random> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char *argv[]) { | ||
|
||
mt19937_64 rng(0); | ||
|
||
uint64_t maxSize = 200; | ||
uint64_t numExamplesPerSize = 10; | ||
|
||
uniform_int_distribution < uint8_t > dist(0, 255); | ||
|
||
for (uint64_t size = 0; size <= maxSize; ++size) { | ||
vector < uint8_t > data(size); | ||
for (uint64_t i = 0; i < numExamplesPerSize; ++i) { | ||
for (uint64_t k = 0; k < size; ++k) { | ||
data[k] = dist(rng); | ||
} | ||
uint64_t tweak = rng(); | ||
uint64_t seed0 = rng(); | ||
uint64_t seed1 = rng(); | ||
|
||
PolymurHashParams params0; | ||
PolymurHashParams params1; | ||
|
||
polymur_init_params_from_seed(¶ms0, seed0); | ||
polymur_init_params(¶ms1, seed0, seed1); | ||
|
||
uint64_t hash0 = polymur_hash(&data[0], size, ¶ms0, tweak); | ||
uint64_t hash1 = polymur_hash(&data[0], size, ¶ms1, tweak); | ||
|
||
cout << "builder.add(0x"; | ||
cout << hex << setfill('0') << setw(16) << hash0; | ||
cout << "L, 0x"; | ||
cout << hex << setfill('0') << setw(16) << hash1; | ||
cout << "L, 0x"; | ||
cout << hex << setfill('0') << setw(16) << tweak; | ||
cout << "L, 0x"; | ||
cout << hex << setfill('0') << setw(16) << seed0; | ||
cout << "L, 0x"; | ||
cout << hex << setfill('0') << setw(16) << seed1 << 'L'; | ||
cout << ", \""; | ||
for (uint64_t k = 0; k < size; ++k) | ||
cout << hex << setfill('0') << setw(2) | ||
<< static_cast<uint64_t>(data[k]); | ||
cout << "\");"; | ||
|
||
cout << endl; | ||
} | ||
} | ||
} |