-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce remote store hash algo in customData in IndexMetadata (#12986…
…) (#13407) (cherry picked from commit 170ea7a) Signed-off-by: Ashish Singh <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
151a671
commit 4bea236
Showing
26 changed files
with
685 additions
and
270 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
48 changes: 48 additions & 0 deletions
48
server/src/main/java/org/opensearch/common/hash/FNV1a.java
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,48 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.hash; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* Provides hashing function using FNV1a hash function. @see <a href="http://www.isthe.com/chongo/tech/comp/fnv/#FNV-1">FNV author's website</a>. | ||
* 32 bit Java port of http://www.isthe.com/chongo/src/fnv/hash_32a.c | ||
* 64 bit Java port of http://www.isthe.com/chongo/src/fnv/hash_64a.c | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class FNV1a { | ||
private static final long FNV_OFFSET_BASIS_32 = 0x811c9dc5L; | ||
private static final long FNV_PRIME_32 = 0x01000193L; | ||
|
||
private static final long FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325L; | ||
private static final long FNV_PRIME_64 = 0x100000001b3L; | ||
|
||
// FNV-1a hash computation for 32-bit hash | ||
public static long hash32(String input) { | ||
long hash = FNV_OFFSET_BASIS_32; | ||
byte[] bytes = input.getBytes(StandardCharsets.UTF_8); | ||
for (byte b : bytes) { | ||
hash ^= (b & 0xFF); | ||
hash *= FNV_PRIME_32; | ||
} | ||
return hash; | ||
} | ||
|
||
// FNV-1a hash computation for 64-bit hash | ||
public static long hash64(String input) { | ||
long hash = FNV_OFFSET_BASIS_64; | ||
byte[] bytes = input.getBytes(StandardCharsets.UTF_8); | ||
for (byte b : bytes) { | ||
hash ^= (b & 0xFF); | ||
hash *= FNV_PRIME_64; | ||
} | ||
return hash; | ||
} | ||
} |
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
69 changes: 0 additions & 69 deletions
69
server/src/main/java/org/opensearch/index/remote/RemoteStoreDataEnums.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.