private long executeUpdateDatasetVersionIfExpiredSqlStatement(PreparedStatement statement, int accountId,
      int containerId, String datasetName, long version, long timeToLiveInSeconds, long creationTimeInMs,
      Dataset dataset, boolean datasetVersionTtlEnabled, DatasetVersionState datasetVersionState)
      throws SQLException, AccountServiceException {
    statement.setLong(1, version);
    long updatedExpirationTimeMs;
    if (datasetVersionTtlEnabled || dataset.getRetentionTimeInSeconds() == null) {
      updatedExpirationTimeMs = Utils.addSecondsToEpochTime(creationTimeInMs, timeToLiveInSeconds);
    } else {
      updatedExpirationTimeMs = Utils.addSecondsToEpochTime(creationTimeInMs, dataset.getRetentionTimeInSeconds());
    }
    if (updatedExpirationTimeMs == Infinite_Time) {
      statement.setTimestamp(2, null);
    } else {
      statement.setTimestamp(2, new Timestamp(updatedExpirationTimeMs));
    }
    statement.setInt(3, datasetVersionState.ordinal());
    statement.setInt(4, accountId);
    statement.setInt(5, containerId);
    statement.setString(6, datasetName);
    statement.setLong(7, version);
    int count = statement.executeUpdate();
    if (count <= 0) {
      throw new AccountServiceException("The dataset version already exist", AccountServiceErrorCode.ResourceConflict);
    }
    return updatedExpirationTimeMs;
  }
Execute updateDatasetSqlIfExpiredStatement to update dataset version if it gets expired.
@param statement the mysql statement to update dataset version if it gets expired.
@param accountId the id for the parent account.
@param containerId the id of the container.
@param datasetName the name of the dataset.
@param version the version value of the dataset.
@param timeToLiveInSeconds The dataset version level ttl.
@param creationTimeInMs the creation time of the dataset version.
@param dataset the {@link Dataset} including the metadata.
@param datasetVersionTtlEnabled set to true if dataset version ttl want to override the dataset level default ttl.
@param datasetVersionState the {@link DatasetVersionState}
@return the updated expiration time.
@throws SQLException
@throws AccountServiceException
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java