-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chenyang Ji <[email protected]>
- Loading branch information
Showing
11 changed files
with
460 additions
and
120 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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/opensearch/plugin/insights/core/utils/ExporterReaderUtils.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,30 @@ | ||
package org.opensearch.plugin.insights.core.utils; | ||
|
||
import java.time.Instant; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Locale; | ||
|
||
/** | ||
* Util functions for exporter and reader | ||
* | ||
*/ | ||
public class ExporterReaderUtils { | ||
|
||
private ExporterReaderUtils() {} | ||
|
||
/** | ||
* Generates a consistent 5-digit numeric hash based on the current UTC date. | ||
* The generated hash is deterministic, meaning it will return the same result for the same date. | ||
* | ||
* @return A 5-digit numeric string representation of the current date's hash. | ||
*/ | ||
public static String generateLocalIndexDateHash() { | ||
// Get the current date in UTC (yyyy-MM-dd format) | ||
String currentDate = DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.ROOT) | ||
.format(Instant.now().atOffset(ZoneOffset.UTC).toLocalDate()); | ||
|
||
// Generate a 5-digit numeric hash from the date's hashCode | ||
return String.format(Locale.ROOT, "%05d", (currentDate.hashCode() % 100000 + 100000) % 100000); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/org/opensearch/plugin/insights/core/utils/package-info.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,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Util functions | ||
*/ | ||
package org.opensearch.plugin.insights.core.utils; |
Oops, something went wrong.