[TR-336] readMinimalBinary in BitInBase.java does not match with its writeMinimalBinary counterpart Created: 15/Jun/15  Updated: 06/Nov/15  Resolved: 06/Nov/15

Status: Resolved
Project: Terrier Core
Component/s: .compression
Affects Version/s: None
Fix Version/s: 4.1

Type: Bug Priority: Trivial
Reporter: Saúl Vargas Assignee: Craig Macdonald
Resolution: Fixed  
Labels: None

Attachments: Java Source File TestCompressedBitFilesGolomb-1.java     Java Source File TestCompressedBitFilesGolomb.java    

 Description   
The original code (in comment) does not work properly. Next line after each comment fixes this (at least in my experiments):

    public int readMinimalBinary(final int b) throws IOException {
        final int log2b = BitUtilities.mostSignificantBit(b);
        final int m = (1 << log2b + 1) - b;
        final int x = readBinary(log2b);
        if (x < m) {
// return x + 1;
            return x;
        } else {
// int temp = (x << 1) + readBinary(1);
            int temp = (x << 1) + readBinary(1) - m;
            return temp;
        }
    }


 Comments   
Comment by Craig Macdonald [ 16/Jun/15 ]

Great. Do you have a test case patch for the TestCompressedBitFiles ?

Craig

Comment by Saúl Vargas [ 16/Jun/15 ]

I created a copy of the TestCompreesedBitFiles.java in which every call to the gamma code is replaced by Golomb. After applying the change suggested in the initial report in BitInBase.java AS WELL AS IN BitFile.java all the tests pass.

Comment by Craig Macdonald [ 06/Nov/15 ]

tagging for 4.1

Comment by Craig Macdonald [ 06/Nov/15 ]

Saul, do you have a version of this patch that doesn't require Java 8?

Thanks

Craig

Comment by Saúl Vargas [ 06/Nov/15 ]

Check the new file.

Comment by Craig Macdonald [ 06/Nov/15 ]

Committed.

Generated at Wed Dec 13 10:53:43 GMT 2017 using JIRA 7.1.1#71004-sha1:d6b2c0d9b7051e9fb5e4eb8ce177ca56d91d7bd8.