-
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.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 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,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 "xxh3_checksum_config.hpp" | ||
#include "xxhash/xxhash.h" | ||
#include <cstring> | ||
|
||
void XXH3ChecksumConfig::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 = XXH3_64bits((char*) (&dataBytes[0]), size); | ||
uint64_t hash1 = XXH3_64bits_withSeed((char*) (&dataBytes[0]), size, seed); | ||
|
||
memcpy(hashBytes, &hash0, 8); | ||
memcpy(hashBytes + 8, &hash1, 8); | ||
} |
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,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 XXH3_CHECKSUM_CONFIG_HPP | ||
#define XXH3_CHECKSUM_CONFIG_HPP | ||
|
||
#include <string> | ||
|
||
class XXH3ChecksumConfig { | ||
|
||
public: | ||
|
||
uint64_t getSeedSize() const { | ||
return 8; | ||
} | ||
|
||
uint64_t getHashSize() const { | ||
return 16; | ||
} | ||
|
||
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 |