Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-5759

Add PackedInts.unsignedBitsRequired

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.9, 6.0
    • None
    • None
    • New

    Description

      Across the code base, we have lots of:

      long minValue, maxValue;
      final long delta = maxValue - minValue;
      final int bitsRequired = delta < 0 64 : Packedints.bitsRequired(delta);
      

      Packedints.bitsRequired(delta) doesn't work directly in that case since it expects a positive value. And that is important that it does so in order to get an error instead of silently being super wasteful if a negative value is provided.

      Yet in some cases such as the one depicted above, the value should be interpreted as an unsigned long. So I propose to add another bitsRequired method that would interpret the value as unsigned.

      Attachments

        1. LUCENE-5759.patch
          15 kB
          Adrien Grand
        2. LUCENE-5759.patch
          15 kB
          Adrien Grand
        3. LUCENE-5759.patch
          9 kB
          Adrien Grand

        Activity

          People

            jpountz Adrien Grand
            jpountz Adrien Grand
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: