ByteBuffer getBytes() {
    ByteBuffer value;
    switch (formatVersion) {
      case PersistentIndex.VERSION_0:
        value = ByteBuffer.allocate(INDEX_VALUE_SIZE_IN_BYTES_V0);
        value.putLong(size);
        value.putLong(offset.getOffset());
        value.put(flags);
        value.putLong(expiresAtMs);
        value.putLong(originalMessageOffset);
        value.position(0);
        break;
      case PersistentIndex.VERSION_1:
      case PersistentIndex.VERSION_2:
        value = ByteBuffer.allocate(INDEX_VALUE_SIZE_IN_BYTES_V1_V2);
        value.putLong(size);
        value.putLong(offset.getOffset());
        value.put(flags);
        value.putInt(expiresAtMs != Utils.Infinite_Time ? (int) (expiresAtMs / Time.MsPerSec) : (int) expiresAtMs);
        value.putLong(originalMessageOffset);
        value.putInt(operationTimeInMs != Utils.Infinite_Time ? (int) (operationTimeInMs / Time.MsPerSec)
            : (int) operationTimeInMs);
        value.putShort(accountId);
        value.putShort(containerId);
        value.position(0);
        break;
      case PersistentIndex.VERSION_3:
      case PersistentIndex.VERSION_4:
        value = ByteBuffer.allocate(INDEX_VALUE_SIZE_IN_BYTES_V3_V4);
        value.putLong(size);
        value.putLong(offset.getOffset());
        value.put(flags);
        value.putInt(expiresAtMs != Utils.Infinite_Time ? (int) (expiresAtMs / Time.MsPerSec) : (int) expiresAtMs);
        value.putLong(originalMessageOffset);
        value.putInt(operationTimeInMs != Utils.Infinite_Time ? (int) (operationTimeInMs / Time.MsPerSec)
            : (int) operationTimeInMs);
        value.putShort(accountId);
        value.putShort(containerId);
        value.putShort(lifeVersion);
        value.position(0);
        break;
      default:
        throw new IllegalArgumentException("Unsupported formatVersion " + formatVersion + " for IndexValue ");
    }
    return value;
  }
@return the {@link ByteBuffer} representation of this {@link IndexValue}
ambry-store/src/main/java/com/github/ambry/store/IndexValue.java