Skip to content

convert byte[] to long error #537

@shiyuhang0

Description

@shiyuhang0

Bug Report

1. Describe the bug

convert bytes to long error in TiChunkColumnVector#getLongFromBinary

2. Minimal reproduce step (Required)

when one byte of the byte[] < 0, you may get the wrong answer.
For example

        // generate byte[]
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(255);
        byte[] bytes =  buffer.array();
        // copy the code from getLongFromBinary
        long result = 0;
        for (byte b : bytes) {
            result = (result << 8) | b;
        }
        // answer is -1 rather than 255
        System.out.println(result);

5. What is your Java Client and TiKV version? (Required)

  • Client Java: master

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions