private long generateAutoIncrementedVersionBasedOnSchema(long versionValue, Dataset.VersionSchema versionSchema,
      String version) {
    long autoIncrementedVersionValue;
    switch (versionSchema) {
      case TIMESTAMP:
        throw new IllegalArgumentException("We don't support latest version for timestamp schema");
      case MONOTONIC:
        if (!LATEST.equals(version)) {
          throw new IllegalArgumentException(
              "The current version string " + version + " is not supported for Timestamp or Monotonic version schema");
        }
        autoIncrementedVersionValue = versionValue + 1;
        if (autoIncrementedVersionValue >= MAX_TIMESTAMP_MONOTONIC_VERSION_VALUE) {
          throw new IllegalArgumentException(
              "The largest version for Timestamp and Monotonic version should be less than "
                  + MAX_TIMESTAMP_MONOTONIC_VERSION_VALUE + ", currentVersion: " + versionValue);
        }
        return autoIncrementedVersionValue;
      case SEMANTIC:
        //Given a version number MAJOR.MINOR.PATCH, increment the:
        //1.MAJOR version when you make incompatible API changes
        //2.MINOR version when you add functionality in a backwards compatible manner
        //3.PATCH version when you make backwards compatible bug fixes
        //The MAJOR,MINOR and PATCH version are non-negative value.
        if (!MAJOR.equals(version) && !MINOR.equals(version) && !PATCH.equals(version)) {
          throw new IllegalArgumentException(
              "The current version string " + version + " is not supported for Semantic version schema");
        }
        long majorVersion = versionValue / 1000000;
        long minorVersion = ((versionValue % 1000000) / 1000);
        long patchVersion = versionValue % 1000;
        if (MAJOR.equals(version)) {
          majorVersion += 1;
          minorVersion = 0;
          patchVersion = 0;
          if (majorVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Major version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentMajorVersion: " + majorVersion);
          }
        } else if (MINOR.equals(version)) {
          minorVersion += 1;
          patchVersion = 0;
          if (minorVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Minor version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentMinorVersion: " + minorVersion);
          }
        } else {
          patchVersion += 1;
          if (patchVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Patch version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentPatchVersion: " + patchVersion);
          }
        }
        return majorVersion * 1000000 + minorVersion * 1000 + patchVersion;
      case SEMANTIC_LONG:
        //Given a version number MAJOR.MINOR.PATCH, increment the:
        //1.MAJOR version when you make incompatible API changes
        //2.MINOR version when you add functionality in a backwards compatible manner
        //3.PATCH version when you make backwards compatible bug fixes
        //4.REVISION   version when you make fixes atop an original major.minor.patch version.
        //The MAJOR, MINOR, PATCH, and REVISION version are non-negative value.
        if (!MAJOR.equals(version) && !MINOR.equals(version) && !PATCH.equals(version) && !REVISION.equals(version)) {
          throw new IllegalArgumentException(
              "The current version string " + version + " is not supported for Semantic Long version schema");
        }
        long majorLongVersion = versionValue / 1000000000L;
        long minorLongVersion = (versionValue % 1000000000L) / 1000000L;
        long patchLongVersion = (versionValue % 1000000L) / 1000L;
        long revisionLongVersion = versionValue % 1000L;
        if (MAJOR.equals(version)) {
          majorLongVersion += 1;
          minorLongVersion = 0;
          patchLongVersion = 0;
          revisionLongVersion = 0;
          if (majorLongVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Major version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentMajorVersion: " + majorLongVersion);
          }
        } else if (MINOR.equals(version)) {
          minorLongVersion += 1;
          patchLongVersion = 0;
          revisionLongVersion = 0;
          if (minorLongVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Minor version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentMinorVersion: " + minorLongVersion);
          }
        } else if (PATCH.equals(version)) {
          patchLongVersion += 1;
          revisionLongVersion = 0;
          if (patchLongVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Patch version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentPatchVersion: " + patchLongVersion);
          }
        } else {
          revisionLongVersion += 1;
          if (revisionLongVersion > MAX_SEMANTIC_VERSION_PART_VALUE) {
            throw new IllegalArgumentException("The largest version for Semantic Revision version should be less than "
                + MAX_SEMANTIC_VERSION_PART_VALUE + ", currentRevisionVersion: " + revisionLongVersion);
          }
        }
        return majorLongVersion * 1000000000 + minorLongVersion * 1000000 + patchLongVersion * 1000 + revisionLongVersion;
      default:
        throw new IllegalArgumentException("Unsupported version schema: " + versionSchema);
    }
  }
Generate the auto incremented version based on the latest valid version and the version schema.
@param versionValue the latest version value for current dataset.
@param versionSchema the {@link com.github.ambry.account.Dataset.VersionSchema} of the dataset.
@param version the version string to indicate if user provide LATEST, MAJOR, MINOR, PATCH, or REVISION option.
@return the auto incremented value base on latest version.
ambry-account/src/main/java/com/github/ambry/account/mysql/DatasetDao.java