-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
runtime: Add getDouble functionality to snapshot #8265
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
343b013
runtime: Add getDouble functionality to snapshot
tonya11en a3e0d15
Fix test
tonya11en a4ae5d2
Store both double and uint
372ff42
Always parse uints/doubles together
tonya11en a31daf3
Address negative doubles
df5dcb7
add large int test
4022659
format
c5cfcc6
docs
a6000b7
alpha order
5f80c13
Merge remote-tracking branch 'upstream/master' into get_double
590b542
ordering of release note
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 |
---|---|---|
|
@@ -92,6 +92,7 @@ class SnapshotImpl : public Snapshot, | |
uint64_t random_value) const override; | ||
const std::string& get(const std::string& key) const override; | ||
uint64_t getInteger(const std::string& key, uint64_t default_value) const override; | ||
double getDouble(const std::string& key, double default_value) const override; | ||
const std::vector<OverrideLayerConstPtr>& getLayers() const override; | ||
|
||
static Entry createEntry(const std::string& value); | ||
|
@@ -106,14 +107,21 @@ class SnapshotImpl : public Snapshot, | |
if (parseEntryBooleanValue(entry)) { | ||
return; | ||
} | ||
if (parseEntryUintValue(entry)) { | ||
|
||
if (parseEntryDoubleValue(entry) && entry.double_value_ >= 0 && | ||
entry.double_value_ <= std::numeric_limits<uint64_t>::max()) { | ||
// Valid uint values will always be parseable as doubles, so we assign the value to both the | ||
// uint and double fields. In cases where the value is something like "3.1", we will floor the | ||
// number by casting it to a uint and assigning the uint value. | ||
entry.uint_value_ = entry.double_value_; | ||
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. Let's add a test for negative double values and positive double values >= 2^64. I think we'll want to handle those specially. Probably also need a warning on getInteger that values greater than approximately 2^53 will not be accurately converted to integers. |
||
return; | ||
} | ||
|
||
parseEntryFractionalPercentValue(entry); | ||
} | ||
|
||
static bool parseEntryBooleanValue(Entry& entry); | ||
static bool parseEntryUintValue(Entry& entry); | ||
static bool parseEntryDoubleValue(Entry& entry); | ||
static void parseEntryFractionalPercentValue(Entry& entry); | ||
|
||
const std::vector<OverrideLayerConstPtr> layers_; | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
23.2 |
2 changes: 2 additions & 0 deletions
2
test/common/runtime/test_data/root/envoy/file_with_double_comment
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,2 @@ | ||
# Here's a comment! | ||
2.718 |
4 changes: 4 additions & 0 deletions
4
test/common/runtime/test_data/root/envoy/file_with_double_newlines
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,4 @@ | ||
3.141 | ||
|
||
|
||
|
2 changes: 2 additions & 0 deletions
2
test/common/runtime/test_data/root/envoy/file_with_large_integer
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,2 @@ | ||
# 2^64 * 10 | ||
184467440737095516160 |
1 change: 1 addition & 0 deletions
1
test/common/runtime/test_data/root/envoy/file_with_negative_double
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 @@ | ||
-4.2 |
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 @@ | ||
bogus string |
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
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.
Sorry needs another merge fix.
/wait