private DataInputStream getSerializedStream(CosmosUpdateTimeFindToken token) {
    int size = 2 * Short.BYTES + 2 * Long.BYTES + Short.BYTES;
    for (String blobId : token.getLastUpdateTimeReadBlobIds()) {
      size += Short.BYTES; //for size of string
      size += blobId.length(); //for the string itself
    }
    byte[] buf = new byte[size];
    ByteBuffer bufWrap = ByteBuffer.wrap(buf);
    // add version
    bufWrap.putShort(token.getVersion());
    // add type
    bufWrap.putShort((short) token.getType().ordinal());
    // add latestUploadTime
    bufWrap.putLong(token.getLastUpdateTime());
    // add bytesRead
    bufWrap.putLong(token.getBytesRead());
    // add lastUpdateTimeReadBlobIds
    bufWrap.putShort((short) token.getLastUpdateTimeReadBlobIds().size());
    for (String blobId : token.getLastUpdateTimeReadBlobIds()) {
      bufWrap.putShort((short) blobId.length());
      bufWrap.put(blobId.getBytes());
    }
    return new DataInputStream(new ByteArrayInputStream(buf));
  }
helper to seriliaze token.
@param token {@code CloudFindToken} object to serialize
@return DataInputStream serialized stream
ambry-cloud/src/test/java/com/github/ambry/cloud/azure/CosmosUpdateTimeFindTokenTest.java