0x26res commented on code in PR #3113:
URL: https://github.com/apache/parquet-java/pull/3113#discussion_r1917122080
##########
parquet-protobuf/src/main/java/org/apache/parquet/proto/ProtoSchemaConverter.java:
##########
@@ -260,7 +260,7 @@ private <T> Builder<? extends Builder<?, GroupBuilder<T>>,
GroupBuilder<T>> addF
return builder.primitive(INT32, getRepetition(descriptor));
}
if (messageType.equals(UInt32Value.getDescriptor())) {
- return builder.primitive(INT64, getRepetition(descriptor));
+ return builder.primitive(INT32, getRepetition(descriptor));
Review Comment:
Here's my understanding.
`uint32` is not a java concept. Therefore a protobuf field of type `uint32`,
in the java generated code, will be treated as signed 32 bit integer. What java
calls an `int`.
Something like:
```proto
message TestMessage {
uint32 value = 1;
}
```
Will generate setters and getters that use an `int`:
```java
public Builder setValue(int value) // ....
```
However if I set the value to a negative value, for example
`builder.setValue(-1)` and call `toString`, it will correctly interpret it as
4294967295.
Again what's important to note is that the underlying representation of a
uint32 protobuf type in java is (32bit) int. Say I am to store, from a language
that support unsigned integers (eg python), the value of a `uint32` to
`4294967295`. Then if I read it in java I would get `-1`. But if I serialize
the message again and pass it back to C or python, I would get back
`4294967295` which is what I want.
I've extended the test to illustrate the behaviour better (adding calls to
`toString`). Also I've added `-1` on top of `Integer.MIN_VALUE` and
`Integer.MAX_VALUE` to correctly test the full spectrum of unsigned integer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]