diff --git a/build.gradle b/build.gradle index 8477249..b3f0160 100644 --- a/build.gradle +++ b/build.gradle @@ -169,7 +169,7 @@ static def readPythonLicense(licenseName) { spotless { def googleJavaFormatVersion = '1.25.0' - def eclipseCdtVersion = '11.6' + def clangFormatVersion = '15.0.6' def blackVersion = '24.10.0' def greclipseVersion = '4.32' def specialLicenseHeaders = [ @@ -215,7 +215,7 @@ spotless { } cpp { target 'reference-implementations/*/*.cpp', 'reference-implementations/*/*.hpp', 'reference-implementations/*.cpp', 'reference-implementations/*.hpp' - eclipseCdt(eclipseCdtVersion) + clangFormat(clangFormatVersion) licenseHeader readJavaLicense('APACHE_2_0_DYNATRACE') } java { diff --git a/reference-implementations/calculate_checksums.cpp b/reference-implementations/calculate_checksums.cpp index b08e201..6a2afbf 100644 --- a/reference-implementations/calculate_checksums.cpp +++ b/reference-implementations/calculate_checksums.cpp @@ -13,139 +13,137 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include -#include #include +#include "farmhash_na/farmhash_na_checksum_config.hpp" +#include "farmhash_uo/farmhash_uo_checksum_config.hpp" #include "komihash_4_3/komihash_4_3_checksum_config.hpp" #include "komihash_4_5/komihash_4_5_checksum_config.hpp" #include "komihash_4_7/komihash_4_7_checksum_config.hpp" #include "komihash_5_0/komihash_5_0_checksum_config.hpp" #include "komihash_5_10/komihash_5_10_checksum_config.hpp" +#include "murmur3_128/murmur3_128_checksum_config.hpp" +#include "murmur3_32/murmur3_32_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" -#include "murmur3_128/murmur3_128_checksum_config.hpp" -#include "murmur3_32/murmur3_32_checksum_config.hpp" -#include "farmhash_na/farmhash_na_checksum_config.hpp" -#include "farmhash_uo/farmhash_uo_checksum_config.hpp" #include "xxh3/xxh3_checksum_config.hpp" #include "xxh3_128/xxh3_128_checksum_config.hpp" using namespace std; uint64_t splitmix_v1_update(uint64_t &state) { - state += UINT64_C(0x9e3779b97f4a7c15); - uint64_t z = state; - z = (z ^ (z >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); - z = (z ^ (z >> 27)) * UINT64_C(0x94d049bb133111eb); - return z ^ (z >> 31); + state += UINT64_C(0x9e3779b97f4a7c15); + uint64_t z = state; + z = (z ^ (z >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); + z = (z ^ (z >> 27)) * UINT64_C(0x94d049bb133111eb); + return z ^ (z >> 31); } -template +template void computeAndPrintChecksum( - const uint64_t maxSupportedLength = std::numeric_limits < uint64_t - > ::max(), const T &hashFunctionConfig = T()) { - - mt19937_64 rng(0); + const uint64_t maxSupportedLength = std::numeric_limits::max(), + const T &hashFunctionConfig = T()) { - ofstream outputFile( - "../src/test/resources/" + hashFunctionConfig.getName() + ".txt"); + mt19937_64 rng(0); - std::vector> lengthAndCycles; - lengthAndCycles.emplace_back(0, 1); - for (uint64_t dataLength = 1; dataLength <= 1024; ++dataLength) { - lengthAndCycles.emplace_back(dataLength, 100); - } - for (uint64_t dataLength = 1025; dataLength <= 4096; ++dataLength) { - lengthAndCycles.emplace_back(dataLength, 10); - } - lengthAndCycles.emplace_back((UINT64_C(1) << 31) - 1, 1); - lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 0, 1); - lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 1, 1); - lengthAndCycles.emplace_back((UINT64_C(1) << 32) - 1, 1); - lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 0, 1); - lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 1, 1); + ofstream outputFile("../src/test/resources/" + hashFunctionConfig.getName() + + ".txt"); - for (const auto &lengthAndCycle : lengthAndCycles) { + std::vector> lengthAndCycles; + lengthAndCycles.emplace_back(0, 1); + for (uint64_t dataLength = 1; dataLength <= 1024; ++dataLength) { + lengthAndCycles.emplace_back(dataLength, 100); + } + for (uint64_t dataLength = 1025; dataLength <= 4096; ++dataLength) { + lengthAndCycles.emplace_back(dataLength, 10); + } + lengthAndCycles.emplace_back((UINT64_C(1) << 31) - 1, 1); + lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 0, 1); + lengthAndCycles.emplace_back((UINT64_C(1) << 31) + 1, 1); + lengthAndCycles.emplace_back((UINT64_C(1) << 32) - 1, 1); + lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 0, 1); + lengthAndCycles.emplace_back((UINT64_C(1) << 32) + 1, 1); - uint64_t dataLength = lengthAndCycle.first; - uint64_t numCycles = lengthAndCycle.second; + for (const auto &lengthAndCycle : lengthAndCycles) { - if (dataLength > maxSupportedLength) - continue; + uint64_t dataLength = lengthAndCycle.first; + uint64_t numCycles = lengthAndCycle.second; - uint8_t checkSum[EVP_MAX_MD_SIZE]; - EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); + if (dataLength > maxSupportedLength) + continue; - EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); + uint8_t checkSum[EVP_MAX_MD_SIZE]; + EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); - uint64_t seed = rng(); - uint64_t rngState = seed; - uint64_t effectiveSeedLength = (hashFunctionConfig.getSeedSize() + 7) - >> 3; + EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL); - std::vector < uint64_t > seedBytesTemp(effectiveSeedLength); - std::vector < uint8_t > hashBytes(hashFunctionConfig.getHashSize()); + uint64_t seed = rng(); + uint64_t rngState = seed; + uint64_t effectiveSeedLength = (hashFunctionConfig.getSeedSize() + 7) >> 3; - uint64_t effectiveDataLength = (dataLength + 7) >> 3; + std::vector seedBytesTemp(effectiveSeedLength); + std::vector hashBytes(hashFunctionConfig.getHashSize()); - std::vector < uint64_t > dataBytesTemp(effectiveDataLength); + uint64_t effectiveDataLength = (dataLength + 7) >> 3; - for (uint64_t cycle = 0; cycle < numCycles; ++cycle) { - for (uint64_t i = 0; i < effectiveSeedLength; ++i) { - seedBytesTemp[i] = splitmix_v1_update(rngState); - } - for (uint64_t i = 0; i < effectiveDataLength; ++i) { - dataBytesTemp[i] = splitmix_v1_update(rngState); - } + std::vector dataBytesTemp(effectiveDataLength); - uint8_t *dataBytes = reinterpret_cast(&dataBytesTemp[0]); - uint8_t *seedBytes = reinterpret_cast(&seedBytesTemp[0]); + for (uint64_t cycle = 0; cycle < numCycles; ++cycle) { + for (uint64_t i = 0; i < effectiveSeedLength; ++i) { + seedBytesTemp[i] = splitmix_v1_update(rngState); + } + for (uint64_t i = 0; i < effectiveDataLength; ++i) { + dataBytesTemp[i] = splitmix_v1_update(rngState); + } - hashFunctionConfig.calculateHash(seedBytes, &hashBytes[0], - dataBytes, dataLength); + uint8_t *dataBytes = reinterpret_cast(&dataBytesTemp[0]); + uint8_t *seedBytes = reinterpret_cast(&seedBytesTemp[0]); - EVP_DigestUpdate(mdctx, &hashBytes[0], hashBytes.size()); + hashFunctionConfig.calculateHash(seedBytes, &hashBytes[0], dataBytes, + dataLength); - } + EVP_DigestUpdate(mdctx, &hashBytes[0], hashBytes.size()); + } - unsigned int lengthOfHash = 0; - EVP_DigestFinal_ex(mdctx, checkSum, &lengthOfHash); - EVP_MD_CTX_free(mdctx); + unsigned int lengthOfHash = 0; + EVP_DigestFinal_ex(mdctx, checkSum, &lengthOfHash); + EVP_MD_CTX_free(mdctx); - outputFile << dec << dataLength << ","; - outputFile << dec << numCycles << ","; - outputFile << hex << setfill('0') << setw(16) << seed << ","; - for (uint64_t k = 0; k < lengthOfHash; ++k) - outputFile << hex << setfill('0') << setw(2) - << static_cast(checkSum[k]); + outputFile << dec << dataLength << ","; + outputFile << dec << numCycles << ","; + outputFile << hex << setfill('0') << setw(16) << seed << ","; + for (uint64_t k = 0; k < lengthOfHash; ++k) + outputFile << hex << setfill('0') << setw(2) + << static_cast(checkSum[k]); - outputFile << endl; - } - outputFile.close(); + outputFile << endl; + } + outputFile.close(); } int main(int argc, char *argv[]) { - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum( - std::numeric_limits::max()); - computeAndPrintChecksum( - std::numeric_limits::max()); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - computeAndPrintChecksum(); - - return 0; + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum( + std::numeric_limits::max()); + computeAndPrintChecksum( + std::numeric_limits::max()); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + computeAndPrintChecksum(); + + return 0; } diff --git a/reference-implementations/farmhash_na/farmhash_na_checksum_config.hpp b/reference-implementations/farmhash_na/farmhash_na_checksum_config.hpp index a384d65..96179a6 100644 --- a/reference-implementations/farmhash_na/farmhash_na_checksum_config.hpp +++ b/reference-implementations/farmhash_na/farmhash_na_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef FARMHASH_NA_CHECKSUM_CONFIG_HPP #define FARMHASH_NA_CHECKSUM_CONFIG_HPP -#include #include +#include class FarmHashNaChecksumConfig { public: + uint64_t getSeedSize() const { return 24; } - uint64_t getSeedSize() const { - return 24; - } - - uint64_t getHashSize() const { - return 24; - } - - std::string getName() const { - return "FarmHash NA"; - } + uint64_t getHashSize() const { return 24; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "FarmHash NA"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // FARMHASH_NA_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/farmhash_uo/farmhash_uo_checksum_config.hpp b/reference-implementations/farmhash_uo/farmhash_uo_checksum_config.hpp index 83db9dd..0952090 100644 --- a/reference-implementations/farmhash_uo/farmhash_uo_checksum_config.hpp +++ b/reference-implementations/farmhash_uo/farmhash_uo_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef FARMHASH_UO_CHECKSUM_CONFIG_HPP #define FARMHASH_UO_CHECKSUM_CONFIG_HPP -#include #include +#include class FarmHashUoChecksumConfig { public: + uint64_t getSeedSize() const { return 24; } - uint64_t getSeedSize() const { - return 24; - } - - uint64_t getHashSize() const { - return 24; - } - - std::string getName() const { - return "FarmHash UO"; - } + uint64_t getHashSize() const { return 24; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "FarmHash UO"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // FARMHASH_UO_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/komihash_4_3/komihash_4_3_checksum_config.hpp b/reference-implementations/komihash_4_3/komihash_4_3_checksum_config.hpp index bcb939d..1870b75 100644 --- a/reference-implementations/komihash_4_3/komihash_4_3_checksum_config.hpp +++ b/reference-implementations/komihash_4_3/komihash_4_3_checksum_config.hpp @@ -16,27 +16,20 @@ #ifndef KOMIHASH_4_3_CHECKSUM_CONFIG_HPP #define KOMIHASH_4_3_CHECKSUM_CONFIG_HPP -#include #include +#include class Komihash4_3ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } + uint64_t getHashSize() const { return 16; } - std::string getName() const { - return "Komihash 4.3"; - } + std::string getName() const { return "Komihash 4.3"; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // KOMIHASH_4_3_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/komihash_4_5/komihash_4_5_checksum_config.hpp b/reference-implementations/komihash_4_5/komihash_4_5_checksum_config.hpp index ff32357..2f6d6f1 100644 --- a/reference-implementations/komihash_4_5/komihash_4_5_checksum_config.hpp +++ b/reference-implementations/komihash_4_5/komihash_4_5_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef KOMIHASH_4_5_CHECKSUM_CONFIG_HPP #define KOMIHASH_4_5_CHECKSUM_CONFIG_HPP -#include #include +#include class Komihash4_5ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "Komihash 4.5"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Komihash 4.5"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // KOMIHASH_4_5_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/komihash_4_7/komihash_4_7_checksum_config.hpp b/reference-implementations/komihash_4_7/komihash_4_7_checksum_config.hpp index 857ef9e..40b6c2b 100644 --- a/reference-implementations/komihash_4_7/komihash_4_7_checksum_config.hpp +++ b/reference-implementations/komihash_4_7/komihash_4_7_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef KOMIHASH_4_7_CHECKSUM_CONFIG_HPP #define KOMIHASH_4_7_CHECKSUM_CONFIG_HPP -#include #include +#include class Komihash4_7ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "Komihash 4.7"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Komihash 4.7"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // KOMIHASH_4_7_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/komihash_5_0/komihash_5_0_checksum_config.hpp b/reference-implementations/komihash_5_0/komihash_5_0_checksum_config.hpp index 804dfcf..7818c45 100644 --- a/reference-implementations/komihash_5_0/komihash_5_0_checksum_config.hpp +++ b/reference-implementations/komihash_5_0/komihash_5_0_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef KOMIHASH_5_0_CHECKSUM_CONFIG_HPP #define KOMIHASH_5_0_CHECKSUM_CONFIG_HPP -#include #include +#include class Komihash5_0ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "Komihash 5.0"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Komihash 5.0"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // KOMIHASH_5_0_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/komihash_5_10/komihash_5_10_checksum_config.hpp b/reference-implementations/komihash_5_10/komihash_5_10_checksum_config.hpp index 5c75285..17eb84f 100644 --- a/reference-implementations/komihash_5_10/komihash_5_10_checksum_config.hpp +++ b/reference-implementations/komihash_5_10/komihash_5_10_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef KOMIHASH_5_10_CHECKSUM_CONFIG_HPP #define KOMIHASH_5_10_CHECKSUM_CONFIG_HPP -#include #include +#include class Komihash5_10ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "Komihash 5.10"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Komihash 5.10"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // KOMIHASH_5_10_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/murmur3_128/murmur3_128_checksum_config.hpp b/reference-implementations/murmur3_128/murmur3_128_checksum_config.hpp index 0259891..73ff350 100644 --- a/reference-implementations/murmur3_128/murmur3_128_checksum_config.hpp +++ b/reference-implementations/murmur3_128/murmur3_128_checksum_config.hpp @@ -16,27 +16,20 @@ #ifndef MURMUR3_128_CHECKSUM_CONFIG_HPP #define MURMUR3_128_CHECKSUM_CONFIG_HPP -#include #include +#include class Murmur3_128_ChecksumConfig { public: + uint64_t getSeedSize() const { return 4; } - uint64_t getSeedSize() const { - return 4; - } - - uint64_t getHashSize() const { - return 32; - } + uint64_t getHashSize() const { return 32; } - std::string getName() const { - return "Murmur3 128"; - } + std::string getName() const { return "Murmur3 128"; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // MURMUR3_128_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/murmur3_32/murmur3_32_checksum_config.hpp b/reference-implementations/murmur3_32/murmur3_32_checksum_config.hpp index 119e174..0085814 100644 --- a/reference-implementations/murmur3_32/murmur3_32_checksum_config.hpp +++ b/reference-implementations/murmur3_32/murmur3_32_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef MURMUR3_32_CHECKSUM_CONFIG_HPP #define MURMUR3_32_CHECKSUM_CONFIG_HPP -#include #include +#include class Murmur3_32_ChecksumConfig { public: + uint64_t getSeedSize() const { return 4; } - uint64_t getSeedSize() const { - return 4; - } - - uint64_t getHashSize() const { - return 8; - } - - std::string getName() const { - return "Murmur3 32"; - } + uint64_t getHashSize() const { return 8; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Murmur3 32"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // MURMUR3_32_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/polymur-hash_2_0/polymur-hash_2_0_checksum_config.hpp b/reference-implementations/polymur-hash_2_0/polymur-hash_2_0_checksum_config.hpp index dc4345c..3a0cfcc 100644 --- a/reference-implementations/polymur-hash_2_0/polymur-hash_2_0_checksum_config.hpp +++ b/reference-implementations/polymur-hash_2_0/polymur-hash_2_0_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef POLYMURHASH_2_0_CHECKSUM_CONFIG_HPP #define POLYMURHASH_2_0_CHECKSUM_CONFIG_HPP -#include #include +#include class PolymurHash_2_0_ChecksumConfig { public: + uint64_t getSeedSize() const { return 24; } - uint64_t getSeedSize() const { - return 24; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "PolymurHash 2.0"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "PolymurHash 2.0"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // POLYMURHASH_2_0_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/wyhash_final_3/wyhash_final_3_checksum_config.hpp b/reference-implementations/wyhash_final_3/wyhash_final_3_checksum_config.hpp index f3a5d9c..4021900 100644 --- a/reference-implementations/wyhash_final_3/wyhash_final_3_checksum_config.hpp +++ b/reference-implementations/wyhash_final_3/wyhash_final_3_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef WYHASH_FINAL_3_CHECKSUM_CONFIG_HPP #define WYHASH_FINAL_3_CHECKSUM_CONFIG_HPP -#include #include +#include class WyhashFinal3ChecksumConfig { public: + uint64_t getSeedSize() const { return 24; } - uint64_t getSeedSize() const { - return 24; - } - - uint64_t getHashSize() const { - return 32; - } - - std::string getName() const { - return "Wyhash final 3"; - } + uint64_t getHashSize() const { return 32; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Wyhash final 3"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // WYHASH_FINAL_3_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/wyhash_final_4/wyhash_final_4_checksum_config.hpp b/reference-implementations/wyhash_final_4/wyhash_final_4_checksum_config.hpp index cfc573c..4e8ddbd 100644 --- a/reference-implementations/wyhash_final_4/wyhash_final_4_checksum_config.hpp +++ b/reference-implementations/wyhash_final_4/wyhash_final_4_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef WYHASH_FINAL_4_CHECKSUM_CONFIG_HPP #define WYHASH_FINAL_4_CHECKSUM_CONFIG_HPP -#include #include +#include class WyhashFinal4ChecksumConfig { public: + uint64_t getSeedSize() const { return 24; } - uint64_t getSeedSize() const { - return 24; - } - - uint64_t getHashSize() const { - return 32; - } - - std::string getName() const { - return "Wyhash final 4"; - } + uint64_t getHashSize() const { return 32; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "Wyhash final 4"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // WYHASH_FINAL_4_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/xxh3/xxh3_checksum_config.hpp b/reference-implementations/xxh3/xxh3_checksum_config.hpp index e19d2ee..a9c60a2 100644 --- a/reference-implementations/xxh3/xxh3_checksum_config.hpp +++ b/reference-implementations/xxh3/xxh3_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef XXH3_CHECKSUM_CONFIG_HPP #define XXH3_CHECKSUM_CONFIG_HPP -#include #include +#include class XXH3ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 16; - } - - std::string getName() const { - return "XXH3"; - } + uint64_t getHashSize() const { return 16; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "XXH3"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // XXH3_CHECKSUM_CONFIG_HPP diff --git a/reference-implementations/xxh3_128/xxh3_128_checksum_config.cpp b/reference-implementations/xxh3_128/xxh3_128_checksum_config.cpp index 7b7658a..c71201b 100644 --- a/reference-implementations/xxh3_128/xxh3_128_checksum_config.cpp +++ b/reference-implementations/xxh3_128/xxh3_128_checksum_config.cpp @@ -18,15 +18,17 @@ #include void XXH3_128_ChecksumConfig::calculateHash(const uint8_t *seedBytes, - uint8_t *hashBytes, const uint8_t *dataBytes, uint64_t size) const { + uint8_t *hashBytes, + const uint8_t *dataBytes, + uint64_t size) const { - uint64_t seed; - memcpy(&seed, seedBytes, 8); + uint64_t seed; + memcpy(&seed, seedBytes, 8); - XXH128_hash_t hash0 = XXH3_128bits((char*) (&dataBytes[0]), size); - XXH128_hash_t hash1 = XXH3_128bits_withSeed((char*) (&dataBytes[0]), size, - seed); + XXH128_hash_t hash0 = XXH3_128bits((char *)(&dataBytes[0]), size); + XXH128_hash_t hash1 = + XXH3_128bits_withSeed((char *)(&dataBytes[0]), size, seed); - memcpy(hashBytes, &hash0, 16); - memcpy(hashBytes + 16, &hash1, 16); + memcpy(hashBytes, &hash0, 16); + memcpy(hashBytes + 16, &hash1, 16); } diff --git a/reference-implementations/xxh3_128/xxh3_128_checksum_config.hpp b/reference-implementations/xxh3_128/xxh3_128_checksum_config.hpp index 5ed4a0b..6093311 100644 --- a/reference-implementations/xxh3_128/xxh3_128_checksum_config.hpp +++ b/reference-implementations/xxh3_128/xxh3_128_checksum_config.hpp @@ -16,28 +16,20 @@ #ifndef XXH3_128_CHECKSUM_CONFIG_HPP #define XXH3_128_CHECKSUM_CONFIG_HPP -#include #include +#include class XXH3_128_ChecksumConfig { public: + uint64_t getSeedSize() const { return 8; } - uint64_t getSeedSize() const { - return 8; - } - - uint64_t getHashSize() const { - return 32; - } - - std::string getName() const { - return "XXH3_128"; - } + uint64_t getHashSize() const { return 32; } - void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, - const uint8_t *dataBytes, uint64_t size) const; + std::string getName() const { return "XXH3_128"; } + void calculateHash(const uint8_t *seedBytes, uint8_t *hashBytes, + const uint8_t *dataBytes, uint64_t size) const; }; #endif // XXH3_128_CHECKSUM_CONFIG_HPP