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
Use checked casts when reading vints as ints #2043
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.
+1 assuming we all agree on the name =). It sounds like readUnsignedVInt32
, but I am cool with other names
src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java
Outdated
Show resolved
Hide resolved
d77e4c4
to
8a3574a
Compare
So I think one thing to be aware of is that we aren't reading an unsigned int32. There is maybe zero code that handles unsigned int32s? We are casting to a signed int and the checked cast is for a signed ints range of values. |
a423bc6
to
11ee42d
Compare
For consistency with the existing API though the valid thing to do would be to simply check its populating at most 32 bits, and if the 32nd bit is set it’s a negative int that may (or may not) be interpreted by the caller as an unsigned value. That said, we could instead introduce eg readNaturalInt32 which would expect at most 31bits to be set, which might be better. |
db79471
to
6016e68
Compare
OK, this looks like it is passing tests now https://app.circleci.com/pipelines/github/aweisberg/cassandra?branch=cassandra-18099-trunk |
src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/columniterator/AbstractSSTableIterator.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/rows/UnfilteredSerializer.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/db/streaming/ComponentManifest.java
Outdated
Show resolved
Hide resolved
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.
My feedback is all pretty minor around documentation, import order, etc.
Otherwise, LGTM
8d04806
to
ca2e88e
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.
can we address the interface comment? Rest are nits
Hint.serializer.serialize(hint, out, descriptor.messagingVersion()); | ||
long actualSize = out.position() - startPosition; | ||
checkState(actualSize == hintSize); |
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.
can we have a useful error msg? If this triggers we don't have enough info on what happened
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.
would be great to improve the error message of hint, but will leave that as a nit and not a blocker.
+1
b02d470
to
1d0438d
Compare
1d0438d
to
eaec8de
Compare
patch by Ariel Weisberg; reviewed by David Capwell and Caleb Rackliffe for CASSANDRA-18099
eaec8de
to
90c67ec
Compare
patch by Ariel Weisberg; reviewed by ? and ? for CASSANDRA-18099