private long getAutoIncrementedVersionBasedOnLatestAvailableVersionHelper(int accountId, int containerId,
      Dataset.VersionSchema versionSchema, String datasetName, String version)
      throws SQLException, AccountServiceException {
    long latestVersionValue;
    try {
      long startTimeMs = System.currentTimeMillis();
      PreparedStatement listLatestVersionStatement =
          dataAccessor.getPreparedStatement(listLatestVersionSqlForUpload, true);
      try {
        latestVersionValue =
            executeListLatestVersionStatementForUpload(listLatestVersionStatement, accountId, containerId, datasetName);
      } catch (AccountServiceException e) {
        if (AccountServiceErrorCode.NotFound.equals(e.getErrorCode())) {
          latestVersionValue = 0;
        } else {
          throw e;
        }
      }
      long autoIncrementedVersionBasedOnSchema =
          generateAutoIncrementedVersionBasedOnSchema(latestVersionValue, versionSchema, version);
      dataAccessor.onSuccess(Read, System.currentTimeMillis() - startTimeMs);
      return autoIncrementedVersionBasedOnSchema;
    } catch (SQLException | AccountServiceException e) {
      dataAccessor.onException(e, Read);
      throw e;
    }
  }
Get the auto incremented version based on latest version.
@param accountId the id for the parent account.
@param containerId the id of the container.
@param versionSchema the {@link Dataset.VersionSchema} of the dataset.
@param datasetName the name of the dataset.
@return the latest version.
@throws SQLException
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java