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

[IOTDB-4633] Fix bugs of longToBytes in BytesUtils of tsfile #7669

Merged
merged 3 commits into from
Oct 28, 2022

Conversation

FrankHWD
Copy link
Contributor

Since I have met a problem of "unequal value after bytes transformation by BytesUtils in tsfile" as mentioned in IOTDB-4633. After modifying the right arithmetic shift (算术右移) to right logical shift (逻辑右移) in longToBytes function of BytesUtils in tsfile, the problem has been solved successfully.

@@ -523,7 +523,7 @@ public static void longToBytes(long srcNum, byte[] result, int pos, int width) {
width -= m;
int mask = 1 << (8 - cnt);
cnt += m;
byte y = (byte) (srcNum >> width);
byte y = (byte) (srcNum >>> width);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a UT for this bug?

Besides, intToBytes seems have a same bug...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The UT tests for this bug have been added.

@HTHou HTHou merged commit fb1e23b into apache:master Oct 28, 2022
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.

None yet

3 participants