private static int packChunkHeader(int chunkLength,
                                       boolean reserveNextChunkIdField, boolean isPadding,
                                       int allocatedCursor,
                                       int committedCursor) {
      AlignmentUtils.assert64bAligned(chunkLength, "chunkLength");
      if (chunkLength <= 0 || chunkLength > CHUNK_LENGTH_MAX) {
        throw new IllegalArgumentException("totalChunkLength(=" + chunkLength + ") must be in (0," + CHUNK_LENGTH_MAX + "]");
      }
      if (allocatedCursor < 0 || allocatedCursor > CHUNK_LENGTH_MAX) {
        throw new IllegalArgumentException("allocatedCursor(=" + allocatedCursor + ") must be in [0," + CHUNK_LENGTH_MAX + "]");
      }
      if (committedCursor < 0 || committedCursor > CHUNK_LENGTH_MAX) {
        throw new IllegalArgumentException("committedCursor(=" + committedCursor + ") must be in [0," + CHUNK_LENGTH_MAX + "]");
      }

      int typeComponent = isPadding ? RECORD_TYPE_PADDING : RECORD_TYPE_DATA;
      int nextChunkIdComponent = reserveNextChunkIdField ? NEXT_CHUNK_ID_PRESENT : NEXT_CHUNK_ID_ABSENT;
      int lengthComponent = (chunkLength >> 3) << CHUNK_LENGTH_MASK_SHR;
      int committedCursorComponent = (committedCursor & 0b111_11111111) << 11;
      int allocatedCursorComponent = allocatedCursor & 0b111_11111111;
      if (lengthComponent == 0) {
        throw new AssertionError("chunkLength=" + chunkLength + " => lengthComponent is 0");
      }
      return typeComponent
             | nextChunkIdComponent
             | lengthComponent
             | committedCursorComponent
             | allocatedCursorComponent;
    }
private static int packChunkHeader(int chunkLength,
                                       boolean reserveNextChunkIdField, boolean isPadding,
                                       int allocatedCursor,
                                       int committedCursor)