private static ByteBuffer putEntryHeader(ByteBuffer buffer,
                                             int encodedAttributeId,
                                             int sizeOrRefId) {
      assert encodedAttributeId <= MAX_SUPPORTED_ATTRIBUTE_ID
        : "attributeId: " + encodedAttributeId + " > max " + MAX_SUPPORTED_ATTRIBUTE_ID;

      if (fitsTinyEntry(encodedAttributeId, sizeOrRefId)) {
        byte firstByte = (byte)((encodedAttributeId << TINY_ENTRY_SIZE_BITS) | sizeOrRefId);
        return buffer.put(firstByte);
      }
      else if (fitsMediumEntry(encodedAttributeId, sizeOrRefId)) {
        byte firstByte = (byte)(encodedAttributeId | TINY_ENTRY_MASK);
        return buffer.put(firstByte)
          .put((byte)sizeOrRefId);
      }
      else {
        int attributeLow8Bits = encodedAttributeId & 0xFF;
        int attributeHigh6Bits = encodedAttributeId >> 8;
        assert (attributeHigh6Bits & BIG_ENTRY_MASK) == 0 : "attributeId: " + encodedAttributeId + " is larger than possible";
        byte firstByte = (byte)(attributeHigh6Bits | BIG_ENTRY_MASK);
        return buffer.put(firstByte)
          .put((byte)attributeLow8Bits)
          .putInt(sizeOrRefId);
      }
    }
private static ByteBuffer putEntryHeader(ByteBuffer buffer,
                                             int encodedAttributeId,
                                             int sizeOrRefId)