Uploaded image for project: 'Terrier Core'
  1. Terrier Core
  2. TR-336

readMinimalBinary in BitInBase.java does not match with its writeMinimalBinary counterpart

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1
    • Component/s: .compression
    • Labels:
      None

      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;
              }
          }

        Attachments

          Activity

          Hide
          craigm Craig Macdonald added a comment -

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

          Craig

          Show
          craigm Craig Macdonald added a comment - Great. Do you have a test case patch for the TestCompressedBitFiles ? Craig
          Hide
          saulvargas Saúl Vargas added a comment -

          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.

          Show
          saulvargas Saúl Vargas added a comment - 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.
          Hide
          craigm Craig Macdonald added a comment -

          tagging for 4.1

          Show
          craigm Craig Macdonald added a comment - tagging for 4.1
          Hide
          craigm Craig Macdonald added a comment -

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

          Thanks

          Craig

          Show
          craigm Craig Macdonald added a comment - Saul, do you have a version of this patch that doesn't require Java 8? Thanks Craig
          Hide
          saulvargas Saúl Vargas added a comment -

          Check the new file.

          Show
          saulvargas Saúl Vargas added a comment - Check the new file.
          Hide
          craigm Craig Macdonald added a comment -

          Committed.

          Show
          craigm Craig Macdonald added a comment - Committed.

            People

            • Assignee:
              craigm Craig Macdonald
              Reporter:
              saulvargas Saúl Vargas
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: