-
Notifications
You must be signed in to change notification settings - Fork 167
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
Add logic to generate a new snapshot-id #37
Conversation
ad933c3
to
6fd84e2
Compare
6fd84e2
to
bfa8143
Compare
pyiceberg/table/__init__.py
Outdated
|
||
Returns: An 64 bit long | ||
""" | ||
return uuid.uuid4().int & (1 << 64) - 1 |
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.
Why not use the same approach as in Java, which will xor the most-significant int with the least-significant int and then make sure it's positive?
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.
Yes, this is actually not a great idea:
E Caused by: java.lang.IllegalArgumentException: Cannot parse to a long value: snapshot-id: 9330031330511797673
E at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:435)
E at org.apache.iceberg.util.JsonUtil.getLong(JsonUtil.java:135)
E at org.apache.iceberg.SnapshotParser.fromJson(SnapshotParser.java:116)
A >64 bit int
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.
It was because I read unsigned. Fixed that.
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.
Looks okay to me. I think this works but it isn't quite what we do in Java and I don't see why we'd change it.
In Python, you cannot xor on ints/longs (probably because they are also unbound in terms of size :), so I had to deviate a bit there. |
d0425b3
to
11b3c5d
Compare
No description provided.