docs: synchronized public int encodeIntoByteBuffer(final ByteBuffer buffer) {
          final long maxValue = getMaxValue();
          final int relevantLength = countsArrayIndex(maxValue) + 1;
          if (buffer.capacity() < getNeededByteBufferCapacity(relevantLength)) {
              throw new ArrayIndexOutOfBoundsException("buffer does not have capacity for " +
                      getNeededByteBufferCapacity(relevantLength) + " bytes");
          }
          int initialPosition = buffer.position();
          buffer.putInt(getEncodingCookie());
          buffer.putInt(0); // Placeholder for payload length in bytes.
          buffer.putInt(getNormalizingIndexOffset());
          buffer.putInt(numberOfSignificantValueDigits);
          buffer.putLong(lowestDiscernibleValue);
          buffer.putLong(highestTrackableValue);
          buffer.putDouble(getIntegerToDoubleValueConversionRatio());
  
          int payloadStartPosition = buffer.position();
          fillBufferFromCountsArray(buffer);
          buffer.putInt(initialPosition + 4, buffer.position() - payloadStartPosition); // Record the payload length
  
  
          return buffer.position() - initialPosition;
      }