This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Validation API Backend for AD everywhere #221
Open
amitgalitz
wants to merge
25
commits into
opendistro-for-elasticsearch:main
Choose a base branch
from
amitgalitz:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f9a097d
starting validate API structure
ef8195b
starting validate method
faf0e73
pre validation steps begining
f8d6e88
working on feature aggregation
ffa20dd
works right now but random sampling is incosistent
8dcf2eb
this solved the asynch issues with search request and this works with…
2bbcb58
changed random sampling to nonrandom and no aggregation, filter query…
7dd7851
commit before switching to updated code
a0a5e82
merge conflict
6e46041
recomendation fully works now
890fa5b
fixed feature query validation bug
7afabb4
ready for PR
8ade35d
fixed style issue for build
e66d6a2
Merge branch 'master' into newbranch-validate-1.9
2f79363
fixed all changes from CR and added check for field type
2370d5e
Merge branch 'master' into newbranch-validate-1.9
4235849
style fixes
a05c272
added a datetimerange class plus some other fixes
4a523f8
creating new series of timerange with the DateTimeRange class
a2e56da
creating new series of timerange with the DateTimeRange class
143e5d8
style fix
3487c95
Merge pull request #1 from amitgalitz/newbranch-validate-1.9
amitgalitz ef0bddf
more unit tests added for models
e9fc63a
style fix
80c3a3e
Merge pull request #2 from amitgalitz/newbranch-validate-1.9
amitgalitz 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
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
56 changes: 56 additions & 0 deletions
56
src/main/java/com/amazon/opendistroforelasticsearch/ad/model/DateTimeRange.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,56 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.ad.model; | ||
|
||
import java.time.Instant; | ||
|
||
/** | ||
* A DateTimeRange is used to represent start and end time for a timeRange | ||
*/ | ||
public class DateTimeRange { | ||
|
||
private long start; | ||
private long end; | ||
|
||
public DateTimeRange(long start, long end) { | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
public static DateTimeRange rangeBasedOfInterval(long windowDelay, long intervalLength, int numOfIntervals) { | ||
long dataEndTime = Instant.now().toEpochMilli() - windowDelay; | ||
long dataStartTime = dataEndTime - ((long) (numOfIntervals) * intervalLength); | ||
return new DateTimeRange(dataStartTime, dataEndTime); | ||
|
||
} | ||
|
||
public long getStart() { | ||
return start; | ||
} | ||
|
||
public long getEnd() { | ||
return end; | ||
} | ||
|
||
public void setStart(long start) { | ||
this.start = start; | ||
} | ||
|
||
public void setEnd(long end) { | ||
this.end = end; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/com/amazon/opendistroforelasticsearch/ad/model/ValidateResponse.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,72 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.ad.model; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.elasticsearch.common.xcontent.ToXContent; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
public class ValidateResponse implements ToXContentObject { | ||
private Map<String, List<String>> failures; | ||
private Map<String, List<String>> suggestedChanges; | ||
|
||
public XContentBuilder toXContent(XContentBuilder builder) throws IOException { | ||
return toXContent(builder, ToXContent.EMPTY_PARAMS); | ||
} | ||
|
||
public ValidateResponse() { | ||
failures = null; | ||
suggestedChanges = null; | ||
} | ||
|
||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
XContentBuilder xContentBuilder = builder.startObject(); | ||
|
||
xContentBuilder.startObject("failures"); | ||
for (String key : failures.keySet()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if failures or suggestedChanges are null? |
||
xContentBuilder.field(key, failures.get(key)); | ||
} | ||
xContentBuilder.endObject(); | ||
|
||
xContentBuilder.startObject("suggestedChanges"); | ||
for (String key : suggestedChanges.keySet()) { | ||
xContentBuilder.field(key, suggestedChanges.get(key)); | ||
} | ||
xContentBuilder.endObject(); | ||
return xContentBuilder.endObject(); | ||
} | ||
|
||
public Map<String, List<String>> getFailures() { | ||
return failures; | ||
} | ||
|
||
public Map<String, List<String>> getSuggestedChanges() { | ||
return suggestedChanges; | ||
} | ||
|
||
public void setFailures(Map<String, List<String>> failures) { | ||
this.failures = failures; | ||
} | ||
|
||
public void setSuggestedChanges(Map<String, List<String>> suggestedChanges) { | ||
this.suggestedChanges = suggestedChanges; | ||
} | ||
|
||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only place that the method is different from the parse method?