Skip to content

Commit

Permalink
Merge pull request #146 from dynatrace-oss/mix-implementations
Browse files Browse the repository at this point in the history
Mix implementations
  • Loading branch information
oertl authored Sep 3, 2023
2 parents 50a507b + 2592c39 commit ae63546
Show file tree
Hide file tree
Showing 20 changed files with 5,441 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "reference-implementations/polymur-hash_2_0/polymur-hash"]
path = reference-implementations/polymur-hash_2_0/polymur-hash
url = https://github.com/orlp/polymur-hash.git
[submodule "reference-implementations/komihash_5_7/komihash"]
path = reference-implementations/komihash_5_7/komihash
url = https://github.com/avaneev/komihash.git
10 changes: 10 additions & 0 deletions .palantir/revapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ acceptedBreaks:
old: "method void com.dynatrace.hash4j.hashing.AbstractHashStream64::<init>()"
new: "method void com.dynatrace.hash4j.hashing.AbstractHashStream64::<init>()"
justification: "reduced unintended visibility"
"0.11.0":
com.dynatrace.hash4j:hash4j:
- code: "java.method.addedToInterface"
new: "method long com.dynatrace.hash4j.hashing.Hasher64::hashLongLongLongToLong(long,\
\ long, long)"
justification: "added new methods"
- code: "java.method.addedToInterface"
new: "method long com.dynatrace.hash4j.hashing.Hasher64::hashLongLongToLong(long,\
\ long)"
justification: "added new methods"
"0.7.1":
com.dynatrace.hash4j:hash4j:
- code: "java.class.noLongerImplementsInterface"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ hash4j currently implements the following hash algorithms:
* [final version 4](https://github.com/wangyi-fudan/wyhash/releases/tag/wyhash_final4)
* [Komihash](https://github.com/avaneev/komihash)
* [version 4.3](https://github.com/avaneev/komihash/releases/tag/4.3) (compatible with [version 4.7](https://github.com/avaneev/komihash/releases/tag/4.7))
* [version 5.0](https://github.com/avaneev/komihash/releases/tag/5.0) (compatible with [version 5.1](https://github.com/avaneev/komihash/releases/tag/5.1))
* [version 5.0](https://github.com/avaneev/komihash/releases/tag/5.0) (compatible with [version 5.1](https://github.com/avaneev/komihash/releases/tag/5.1) and [version 5.7](https://github.com/avaneev/komihash/releases/tag/5.7))

All hash functions are thoroughly tested against the native reference implementations and also other libraries like [Guava Hashing](https://javadoc.io/doc/com.google.guava/guava/latest/com/google/common/hash/package-summary.html), [Zero-Allocation Hashing](https://github.com/OpenHFT/Zero-Allocation-Hashing), [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/apidocs/index.html), or [crypto](https://github.com/appmattus/crypto) (see [CrossCheckTest.java](src/test/java/com/dynatrace/hash4j/hashing/CrossCheckTest.java)).

Expand Down
1 change: 1 addition & 0 deletions reference-implementations/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ komihash_4_5/komihash_4_5_checksum_config.cpp \
komihash_4_7/komihash_4_7_checksum_config.cpp \
komihash_5_0/komihash_5_0_checksum_config.cpp \
komihash_5_1/komihash_5_1_checksum_config.cpp \
komihash_5_7/komihash_5_7_checksum_config.cpp \
murmur3_32/murmur3_32_checksum_config.cpp \
murmur3_128/murmur3_128_checksum_config.cpp \
murmur3_128/smhasher/src/MurmurHash3.cpp \
Expand Down
2 changes: 2 additions & 0 deletions reference-implementations/calculate_checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "komihash_4_7/komihash_4_7_checksum_config.hpp"
#include "komihash_5_0/komihash_5_0_checksum_config.hpp"
#include "komihash_5_1/komihash_5_1_checksum_config.hpp"
#include "komihash_5_7/komihash_5_7_checksum_config.hpp"
#include "polymur-hash_2_0/polymur-hash_2_0_checksum_config.hpp"
#include "wyhash_final_3/wyhash_final_3_checksum_config.hpp"
#include "wyhash_final_4/wyhash_final_4_checksum_config.hpp"
Expand Down Expand Up @@ -98,6 +99,7 @@ int main(int argc, char *argv[]) {
computeAndPrintChecksum<Komihash4_7ChecksumConfig>();
computeAndPrintChecksum<Komihash5_0ChecksumConfig>();
computeAndPrintChecksum<Komihash5_1ChecksumConfig>();
computeAndPrintChecksum<Komihash5_7ChecksumConfig>();
computeAndPrintChecksum<WyhashFinal3ChecksumConfig>();
computeAndPrintChecksum<WyhashFinal4ChecksumConfig>();
computeAndPrintChecksum<Murmur3_128_ChecksumConfig>();
Expand Down
2,522 changes: 2,522 additions & 0 deletions reference-implementations/komihash_5_1/out.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions reference-implementations/komihash_5_7/komihash
Submodule komihash added at 58e69f
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 "komihash_5_7_checksum_config.hpp"
#include "komihash/komihash.h"
#include <cstring>

void Komihash5_7ChecksumConfig::calculateHash(const uint8_t *seedBytes,
uint8_t *hashBytes, const uint8_t *dataBytes, uint64_t size) const {

uint64_t seed;
memcpy(&seed, seedBytes, 8);

uint64_t hash0 = komihash((char*) (&dataBytes[0]), size, 0);
uint64_t hash1 = komihash((char*) (&dataBytes[0]), size, seed);

memcpy(hashBytes, &hash0, 8);
memcpy(hashBytes + 8, &hash1, 8);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/
#ifndef KOMIHASH_5_7_CHECKSUM_CONFIG_HPP
#define KOMIHASH_5_7_CHECKSUM_CONFIG_HPP

#include <string>

class Komihash5_7ChecksumConfig {

public:

uint64_t getSeedSize() const {
return 8;
}

uint64_t getHashSize() const {
return 16;
}

std::string getName() const {
return "Komihash 5.7";
}

void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes,
const uint8_t *dataBytes, uint64_t size) const;

};

#endif // KOMIHASH_5_7_CHECKSUM_CONFIG_HPP
Loading

0 comments on commit ae63546

Please sign in to comment.