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

VariableByteEncoding for longs takes too much space #2748

Open
adamretter opened this issue May 26, 2019 · 0 comments
Open

VariableByteEncoding for longs takes too much space #2748

adamretter opened this issue May 26, 2019 · 0 comments
Labels
bug issue confirmed as bug

Comments

@adamretter
Copy link
Member

The Java long value 0xFFFFFFFF should at most take 8 bytes when using fixed-encoding. However, our variable byte encoding compression should theoretically compress this to 5 bytes, instead it seems to have a bug whereby the result is 10 bytes of storage :-/

Simple test case is below...

package org.exist.storage.io;

import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;

public class VariableByteArrayInputTest {

    @Test
    public void toooooLong() {
        VariableByteOutputStream os = new VariableByteOutputStream();
        os.writeLong(0xFFFFFFFF);
        byte[] data = os.toByteArray();
        assertEquals(5, data.length);
    }

}
@adamretter adamretter added the bug issue confirmed as bug label May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug
Projects
None yet
Development

No branches or pull requests

1 participant