Class VersionUtils

Object
org.apache.spark.util.VersionUtils

public class VersionUtils extends Object
Utilities for working with Spark version strings
  • Constructor Details

    • VersionUtils

      public VersionUtils()
  • Method Details

    • majorVersion

      public static int majorVersion(String sparkVersion)
      Given a Spark version string, return the major version number. E.g., for 2.0.1-SNAPSHOT, return 2.
      Parameters:
      sparkVersion - (undocumented)
      Returns:
      (undocumented)
    • minorVersion

      public static int minorVersion(String sparkVersion)
      Given a Spark version string, return the minor version number. E.g., for 2.0.1-SNAPSHOT, return 0.
      Parameters:
      sparkVersion - (undocumented)
      Returns:
      (undocumented)
    • shortVersion

      public static String shortVersion(String sparkVersion)
      Given a Spark version string, return the short version string. E.g., for 3.0.0-SNAPSHOT, return '3.0.0'.
      Parameters:
      sparkVersion - (undocumented)
      Returns:
      (undocumented)
    • majorMinorVersion

      public static scala.Tuple2<Object,Object> majorMinorVersion(String sparkVersion)
      Given a Spark version string, return the (major version number, minor version number). E.g., for 2.0.1-SNAPSHOT, return (2, 0).
      Parameters:
      sparkVersion - (undocumented)
      Returns:
      (undocumented)
    • majorMinorPatchVersion

      public static scala.Option<scala.Tuple3<Object,Object,Object>> majorMinorPatchVersion(String version)
      Extracts the major, minor and patch parts from the input version. Note that if minor or patch version is missing from the input, this will return 0 for these parts. Returns None if the input is not of a valid format.

      Examples of valid version: - 1 (extracts to (1, 0, 0)) - 2.4 (extracts to (2, 4, 0)) - 3.2.2 (extracts to (3, 2, 2)) - 3.2.2.4 (extracts to 3, 2, 2)) - 3.3.1-SNAPSHOT (extracts to (3, 3, 1)) - 3.2.2.4SNAPSHOT (extracts to (3, 2, 2), only the first 3 components)

      Examples of invalid version: - ABC - 1X - 2.4XYZ - 2.4-SNAPSHOT - 3.4.5ABC

      Parameters:
      version - (undocumented)
      Returns:
      A non-empty option containing a 3-value tuple (major, minor, patch) iff the input is a valid version. None otherwise.