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

Spark, API: Enhance hashing efficiency by operating on raw UTF-8 bytes #12657

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xiaoxuandev
Copy link
Contributor

This change removes unnecessary toString() conversions by directly processing UTF-8 bytes, improving efficiency and reducing memory allocations.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xiaoxuandev I think the general fix is great, just had a comment about keeping the existing hash(String)

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xiaoxuandev! Just had some non-blocking nits. I'll leave it open for just a bit in case others wanted to review.

@@ -82,7 +82,12 @@ public void testSpecValues() {
Assert.assertEquals(
"Spec example: hash(\"iceberg\") = 1210000089",
1210000089,
new BucketFunction.BucketString().hash("iceberg"));
new BucketFunction.BucketString().hash("iceberg".getBytes(StandardCharsets.UTF_8)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could just leave this the same as before just to keep the diff smaller.

@@ -74,10 +74,14 @@ public void testSpecValues() {
.as("Spec example: hash(2017-11-16T22:31:08) = -2047944441")
.isEqualTo(-2047944441);

assertThat(new BucketFunction.BucketString().hash("iceberg"))
assertThat(new BucketFunction.BucketString().hash("iceberg".getBytes(StandardCharsets.UTF_8)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Same as above, we could just leave this assertion the same as earlier just to keep the diff smaller.

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

Successfully merging this pull request may close these issues.

2 participants