Skip to content

Conversation

@expanded-for-real
Copy link
Collaborator

Add support for types described here - #25

Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Contributor

@agavra agavra left a 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();
Copy link
Contributor

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;
Copy link
Contributor

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

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants