-
Notifications
You must be signed in to change notification settings - Fork 455
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
[query] Add resolution exceeds query range warning #2429
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c0f9809
[query] Add step size exceeds resolution warning
arnikola 7250ff7
Update warning message
arnikola d68d7e3
Merge branch 'master' into arnikola/step-size-warning
arnikola 93f81f1
PR response
arnikola 37abf0a
Merge branch 'master' into arnikola/step-size-warning
arnikola b88a130
Protogen
arnikola 8adebc0
Merge branch 'arnikola/step-size-warning' of github.com:m3db/m3 into …
arnikola 0bc9709
Delete string
arnikola b0fe401
Separate imports
arnikola d61e57d
Merge branch 'master' into arnikola/step-size-warning
arnikola 8dd8377
Merge branch 'master' into arnikola/step-size-warning
arnikola b6c0210
Merge branch 'master' into arnikola/step-size-warning
arnikola 67ed2dd
Merge branch 'master' into arnikola/step-size-warning
arnikola f4fd465
Merge branch 'master' into arnikola/step-size-warning
arnikola ad8cc9f
Merge branch 'master' into arnikola/step-size-warning
arnikola bc43532
Merge branch 'master' into arnikola/step-size-warning
arnikola 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
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 |
---|---|---|
|
@@ -22,6 +22,9 @@ package block | |
|
||
import ( | ||
"fmt" | ||
"sort" | ||
"strings" | ||
"time" | ||
|
||
"github.com/m3db/m3/src/query/models" | ||
) | ||
|
@@ -158,6 +161,37 @@ func (m ResultMetadata) IsDefault() bool { | |
return m.Exhaustive && m.LocalOnly && len(m.Warnings) == 0 | ||
} | ||
|
||
// VerifyTemporalRange will verify that each resolution seen is below the | ||
// given step size, adding warning headers if it is not. | ||
func (m *ResultMetadata) VerifyTemporalRange(step time.Duration) { | ||
fmt.Println("Verifying with step size", step, "as int", int64(step), "Resos", m.Resolutions) | ||
stepSize := int64(step) | ||
// NB: this map is unlikely to have more than 2 elements in real execution, | ||
// since these correspond to namespace count. | ||
invalidResolutions := make(map[int64]struct{}, 10) | ||
for _, res := range m.Resolutions { | ||
fmt.Println("here res is", res) | ||
fmt.Println("step res is", stepSize) | ||
fmt.Println("res > stepSize", res > stepSize) | ||
if res > stepSize { | ||
invalidResolutions[res] = struct{}{} | ||
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. Do we really need this map and also the sorting? Probably simpler to just compile |
||
} | ||
} | ||
|
||
fmt.Println("invalid", invalidResolutions) | ||
robskillington marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if len(invalidResolutions) > 0 { | ||
warnings := make([]string, 0, len(invalidResolutions)) | ||
for k := range invalidResolutions { | ||
warnings = append(warnings, fmt.Sprintf("%v", time.Duration(k))) | ||
} | ||
|
||
sort.Strings(warnings) | ||
warning := fmt.Sprintf("range: %v, resolutions: %s", | ||
step, strings.Join(warnings, ", ")) | ||
m.AddWarning("resolution larger than query range", warning) | ||
} | ||
} | ||
|
||
// AddWarning adds a warning to the result metadata. | ||
// NB: warnings are expected to be small in general, so it's better to iterate | ||
// over the array rather than introduce a map. | ||
|
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
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.
nit: Separate internal/external imports?