Skip to content
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

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented Oct 3, 2023

No description provided.


Returns: An 64 bit long
"""
return uuid.uuid4().int & (1 << 64) - 1
Copy link
Contributor

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?

Copy link
Contributor Author

@Fokko Fokko Oct 3, 2023

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

Copy link
Contributor Author

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.

Copy link
Contributor

@rdblue rdblue left a 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.

@Fokko
Copy link
Contributor Author

Fokko commented Oct 5, 2023

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.

@Fokko Fokko merged commit 6a77195 into apache:main Oct 5, 2023
6 checks passed
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.

2 participants