-
Notifications
You must be signed in to change notification settings - Fork 1
FromNapiValue trait for parameters #183
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
base: second-iteration
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/requests/parameter_wrappers.rs:132
- The error message contains a typo ('ii8' should be 'i8').
try_into().map_err(|_| js_error("Value must fit in ii8 type to be small int"))?,
5712c85
to
6f4c9e6
Compare
085c3ca
to
83b32f5
Compare
f048cb6
to
5e438d8
Compare
83b32f5
to
7335f04
Compare
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.
I have a lot of doubts about the quality of this PR. Please:
- use spell checkers (even Copilot could do the job);
- pay extra attention when changing existing code, as we don't won't to introduce new bugs;
- add comments and docstrings;
- write a bird-eye view of the new way of passing values to and from Rust.
7335f04
to
0244e25
Compare
90bc4e7
to
0489f49
Compare
9496daa
to
dc585c4
Compare
types[i], | ||
value.get(i) !== undefined ? value.get(i) : null, | ||
); | ||
newTypes.push(element[0]); |
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.
Please explain WDYM by newTypes. Can getWrapped
return type other then type given to it as parameter?
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.
If some of the types are not provided (as it's a possible case in type guessing) then the returned type will have this information, while provided argument -- not.
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.
Add in-code documentation for this parameter in every place where it is used.
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.
I'm not sure I understand your comment.
Now I also realized that tuples do not support type guessing.
dc585c4
to
2c66fb1
Compare
2c66fb1
to
d00d256
Compare
d00d256
to
1dfdd1c
Compare
Before, we created QueryParameterWrapper with from_... functions, and then cloning this object when executing query. Now, with implementation of FromNapiValue trait, we pass parameters to queries directly, without any additional conversion steps. In order to correctly handle value types, each parameter is passed as a pair (type, value). Information about type is then used on the rust side to create correct CqlValue object.
1dfdd1c
to
95900c8
Compare
/// Create a new ComplexType for tuple with provided inner types. | ||
#[napi] |
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.
This comment should be under #[napi]
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.
i beg to differ
Before, we created QueryParameterWrapper with from_... functions, and then cloning this object when executing query.
Now, with implementation of FromNapiValue trait, we pass parameters to queries directly, without any additional conversion steps. In order to correctly handle value types, each parameter is passed as a pair (type, value). Information about type is then used on the rust side to create correct CqlValue object.
This significantly improves performance for concurrent inserts benchmark, and slightly for plain inserts benchmark.
Concurrent inset. Around 30% improvement in time elapsed, 20% in task clock
After:
Before
Plain insert. Around 10% improvement in user time and number of instructions, 90% drop in page faults!
After:
Before: