-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[Star tree] Adding date field rounding support in star tree #15249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sachinpkale
merged 16 commits into
opensearch-project:main
from
bharath-techie:timestamp-support
Oct 8, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3f82b5a
Adding timestamp rounding support in star tree
bharath-techie fc9614f
adding half hour and quarter hour calendar intervals
bharath-techie da9b146
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie 014f123
adding tests
bharath-techie 0b4bfb2
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie 221aee6
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie 078aafa
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie a52b29c
resolving conflicts
bharath-techie 4387345
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie 7243dd1
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie 9a4e7f3
Adding support for date dim and adding back tests resolving conflicts
bharath-techie eb43e37
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie ffb6426
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie d34a36f
addressing comments
bharath-techie 65f1fa4
addressing comments
bharath-techie 8215865
Merge branch 'main' of github.com:opensearch-project/OpenSearch into …
bharath-techie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
221 changes: 190 additions & 31 deletions
221
server/src/internalClusterTest/java/org/opensearch/index/mapper/StarTreeMapperIT.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
77 changes: 77 additions & 0 deletions
77
server/src/main/java/org/opensearch/index/compositeindex/datacube/DataCubeDateTimeUnit.java
This file contains hidden or 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,77 @@ | ||
/* | ||
* 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.index.compositeindex.datacube; | ||
|
||
import org.opensearch.index.compositeindex.datacube.startree.utils.date.DateTimeUnitRounding; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static java.util.Collections.unmodifiableMap; | ||
|
||
/** | ||
* Enum representing the extended date time units supported for star tree index as part of index mapping. | ||
* The enum values are: | ||
* <ul> | ||
* <li>HALF_HOUR_OF_DAY: Represents half hour of day rounding</li> | ||
* <li>QUARTER_HOUR_OF_DAY: Represents quarter hour of day rounding</li> | ||
* </ul> | ||
* <p> | ||
* The enum also provides a static map of date field units to their corresponding ExtendedDateTimeUnit instances. | ||
* | ||
* @see org.opensearch.common.Rounding.DateTimeUnit for more information on the dateTimeUnit enum and rounding logic. | ||
* | ||
* @opensearch.experimental | ||
*/ | ||
public enum DataCubeDateTimeUnit implements DateTimeUnitRounding { | ||
HALF_HOUR_OF_DAY("half-hour") { | ||
@Override | ||
public long roundFloor(long utcMillis) { | ||
return utcMillis - (utcMillis % TimeUnit.MINUTES.toMillis(30)); | ||
} | ||
}, | ||
QUARTER_HOUR_OF_DAY("quarter-hour") { | ||
@Override | ||
public long roundFloor(long utcMillis) { | ||
return utcMillis - (utcMillis % TimeUnit.MINUTES.toMillis(15)); | ||
} | ||
}; | ||
|
||
public static final Map<String, DataCubeDateTimeUnit> DATE_FIELD_UNITS; | ||
static { | ||
Map<String, DataCubeDateTimeUnit> dateFieldUnits = new HashMap<>(); | ||
dateFieldUnits.put("30m", DataCubeDateTimeUnit.HALF_HOUR_OF_DAY); | ||
dateFieldUnits.put("half-hour", DataCubeDateTimeUnit.HALF_HOUR_OF_DAY); | ||
dateFieldUnits.put("15m", DataCubeDateTimeUnit.QUARTER_HOUR_OF_DAY); | ||
dateFieldUnits.put("quarter-hour", DataCubeDateTimeUnit.QUARTER_HOUR_OF_DAY); | ||
DATE_FIELD_UNITS = unmodifiableMap(dateFieldUnits); | ||
} | ||
|
||
private final String shortName; | ||
|
||
DataCubeDateTimeUnit(String shortName) { | ||
this.shortName = shortName; | ||
} | ||
|
||
/** | ||
* This rounds down the supplied milliseconds since the epoch down to the next unit. In order to retain performance this method | ||
* should be as fast as possible and not try to convert dates to java-time objects if possible | ||
* | ||
* @param utcMillis the milliseconds since the epoch | ||
* @return the rounded down milliseconds since the epoch | ||
*/ | ||
@Override | ||
public abstract long roundFloor(long utcMillis); | ||
|
||
@Override | ||
public String shortName() { | ||
return shortName; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.