Skip to content

fix: make byte hashing independent of char signedness#361

Merged
lxy-9602 merged 3 commits into
alibaba:mainfrom
wgtmac:fix_signed_char
Jun 12, 2026
Merged

fix: make byte hashing independent of char signedness#361
lxy-9602 merged 3 commits into
alibaba:mainfrom
wgtmac:fix_signed_char

Conversation

@wgtmac

@wgtmac wgtmac commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix ARM bucket mismatches caused by platform-dependent char signedness.

This change makes byte hashing explicit:

  • Hive TINYINT hashing now treats row bytes as signed Java bytes.
  • Hive string/binary byte-array hashing now treats high-bit bytes as signed Java bytes.
  • Murmur tail-byte hashing now reads tail bytes as int8_t, avoiding unsigned plain-char drift.

Tests

Pass existing CI.

API and Format

N/A

Documentation

N/A

Generative AI tooling

Generated-by: OpenAI Codex

Copilot AI review requested due to automatic review settings June 11, 2026 12:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts byte handling in hashing code paths to treat bytes as signed 8-bit values (consistent with Java/Hive semantics), improving hash compatibility across languages.

Changes:

  • Update Hive hashing for raw bytes and TINYINT to use signed-byte interpretation.
  • Update MurmurHash byte mixing and change GetByte to return int8_t.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/paimon/core/bucket/hive_hasher.h Interprets char bytes as signed 8-bit when computing hash.
src/paimon/core/bucket/hive_bucket_function.cpp Ensures TINYINT values are sign-extended before hashing.
src/paimon/common/utils/murmurhash_utils.h Applies signed-byte mixing and changes GetByte return type to int8_t.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/paimon/common/utils/murmurhash_utils.h Outdated
Comment thread src/paimon/core/bucket/hive_bucket_function.cpp Outdated
Comment thread src/paimon/core/bucket/hive_hasher.h Outdated
@wgtmac
wgtmac force-pushed the fix_signed_char branch from 4a05ebe to a69ecc3 Compare June 11, 2026 13:06
@wgtmac
wgtmac requested a review from Copilot June 11, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/paimon/core/bucket/hive_hasher.h Outdated
Comment thread src/paimon/core/bucket/hive_bucket_function.cpp Outdated
Comment thread src/paimon/common/utils/murmurhash_utils.h Outdated
@wgtmac
wgtmac force-pushed the fix_signed_char branch 2 times, most recently from bb7fca9 to 59b29fb Compare June 11, 2026 14:34
- Treat Hive byte and byte-array hashing as signed Java bytes
- Make Murmur tail-byte hashing use explicit int8_t values
@wgtmac
wgtmac force-pushed the fix_signed_char branch from 59b29fb to 10bf085 Compare June 11, 2026 14:34
@zjw1111

zjw1111 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix! Could you add a compatibility test that compares the results with Java, covering negative tinyint values, high-byte UTF-8/binary data, and the Murmur unaligned tail-byte case?

@wgtmac

wgtmac commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the fix! Could you add a compatibility test that compares the results with Java, covering negative tinyint values, high-byte UTF-8/binary data, and the Murmur unaligned tail-byte case?

I would love to do this. But unfortunately I cannot build and run the test on my macOS laptop and I do not yet have access to the Java code. What I tried is to make sure it does not break existing CI and work as expected on our internal ARM environment.

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1

@lxy-9602
lxy-9602 merged commit fd5f618 into alibaba:main Jun 12, 2026
9 of 10 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.

4 participants