-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for new native types #26
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: main
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.
Need to settle on and add a style file
| /** | ||
| * Serialize an Instant as milliseconds since Unix epoch (UTC). | ||
| */ | ||
| public static void serializeTimestamp(Instant value, ImprintBuffer buffer) { |
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.
@agavra I think we had mentioned that timestamp should be milliseconds and that would be milliseconds since midnight, but Avro does milliseconds since Unix epoch and I think that's what we wanted to do here too which means this would need to be 8 bytes after all. If that's the case then I can go back to the main readme and update it again and clarify - just wanted to double check this again to make sure I wasn't getting myself too confused
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 believe we said that timestamp would be 8 bytes millis since midnight but "time" (which is time of day) would be millis since midnight.
EDIT: I just looked at the README and didn't notice that we changed both to 4 bytes. Good catch, "timestamp" should definitely be 8 bytes. I'll change that in the core README as well.
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.
LGTM! A few inline comments
| long leastSignificantBits = buffer.getLong(); | ||
| return new UUID(mostSignificantBits, leastSignificantBits); | ||
| case DECIMAL: | ||
| int scale = VarInt.decode(buffer).getValue(); |
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.
should we check buffer.remaining here?
| if (code == TypeCode.DECIMAL.getCode()) { | ||
| var decimal = (BigDecimal) value; | ||
| byte[] unscaledBytes = decimal.unscaledValue().toByteArray(); | ||
| return 2 + 2 + unscaledBytes.length; |
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.
should we get the exact size of the varint? should probably add test for size computations
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.
Yeah we can do that, I had been trying to aggressively pare down the estimation cost but I don't think the varint calculation really adds that much anyways here
Add support for types described here - #25