-
Notifications
You must be signed in to change notification settings - Fork 5
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
c-s: parser refactor #47
Merged
piodul
merged 4 commits into
scylladb:master
from
muzarski:cassandra-stress-cli-parser-refactor
Aug 30, 2023
Merged
c-s: parser refactor #47
piodul
merged 4 commits into
scylladb:master
from
muzarski:cassandra-stress-cli-parser-refactor
Aug 30, 2023
Conversation
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
Changed error print to `:?` format, which displays the context stack.
Adjusted the types of `duration`, `consistency_level` and `serial_consistency_level` parameters. - `duration`: from `u64` to `std::time::Duration`. - `consistency_level`: from `ConsistencyLevel` to `scylla::statement::Consistency`. - `serial_consistency_level`: from `SerialConsistencyLevel` to `scylla::statement::SerialConsistency`.
piodul
approved these changes
Aug 28, 2023
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.
Just one nitpick.
src/bin/cql-stress-cassandra-stress/settings/param/simple_param.rs
Outdated
Show resolved
Hide resolved
muzarski
force-pushed
the
cassandra-stress-cli-parser-refactor
branch
from
August 28, 2023 13:04
b082ae4
to
8479f91
Compare
wprzytula
reviewed
Aug 28, 2023
src/bin/cql-stress-cassandra-stress/settings/command/read_write.rs
Outdated
Show resolved
Hide resolved
This commit introduces `Parsable` trait. It's implemented for the types that handle the string-to-Parsable::Parsed parsing logic. In this commit, we implement it for the most common types, as well as for some enum types such as `ConsistencyLevel`, etc.
Before this commit, the parser would only be responsible for input VALIDATION. The parameters' handles would return the strings that were matched to the given parameter (and validated). However, the ideal approach is so the user can retrieve the parsed value instead of validated String. This commit introduces the changes addressing this issue. The `SimpleParam` is now generic over `Parsable` trait, which is responsible for parsing strings to the specified type (`type Parsable::Parsed`). Adjusted the rest of the code to this change, including fixups in read/write command parsing.
muzarski
force-pushed
the
cassandra-stress-cli-parser-refactor
branch
from
August 29, 2023 09:52
8479f91
to
cd409f9
Compare
v2:
|
piodul
approved these changes
Aug 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Before the changes, the parser would only validate the input, returning the validated string to the user (which still needs to be parsed to the according type).
Changes
This PR introduces the changes that address this issue. The major change is the introduction of
Parsable
trait described in the code. TheSimpleParam
is now generic overParsable
trait.Most of the changes include adjusting the rest of the code to
Parsable
trait + some fixups.Parsable
traitSimpleParam
be generic overParsable
SimpleParam
duration
, orconsistency_level
parameters