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

The level of IntBlockPool slice is always 1

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/other
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      First slice is allocated by IntBlockPoo.newSlice(), and its level is 1,

       

      private int newSlice(final int size) {
       if (intUpto > INT_BLOCK_SIZE-size) {
       nextBuffer();
       assert assertSliceBuffer(buffer);
       }
       
       final int upto = intUpto;
       intUpto += size;
       buffer[intUpto-1] = 1;
       return upto;
      }

       

       

      If one slice is not enough, IntBlockPoo.allocSlice() is called to allocate more slices,

      as the following code shows, level is 1, newLevel is NEXT_LEVEL_ARRAY[0] which is also 1.

       

      The result is the level of IntBlockPool slice is always 1, the first slice is  2 bytes long, and all subsequent slices are 4 bytes long.

       

      private static final int[] NEXT_LEVEL_ARRAY = {1, 2, 3, 4, 5, 6, 7, 8, 9, 9};
      private int allocSlice(final int[] slice, final int sliceOffset) {
       final int level = slice[sliceOffset];
       final int newLevel = NEXT_LEVEL_ARRAY[level - 1];
       final int newSize = LEVEL_SIZE_ARRAY[newLevel];
       // Maybe allocate another block
       if (intUpto > INT_BLOCK_SIZE - newSize) {
       nextBuffer();
       assert assertSliceBuffer(buffer);
       }
      final int newUpto = intUpto;
       final int offset = newUpto + intOffset;
       intUpto += newSize;
       // Write forwarding address at end of last slice:
       slice[sliceOffset] = offset;
      // Write new level:
       buffer[intUpto - 1] = newLevel;
      return newUpto;
       } 
      

       

        Attachments

        1. LUCENE-9673.patch
          2 kB
          mashudong

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mashudong mashudong
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: