Class LocationUtil

java.lang.Object
org.apache.iceberg.util.LocationUtil

public class LocationUtil extends Object
  • Field Details

  • Method Details

    • stripTrailingSlash

      public static String stripTrailingSlash(String path)
    • tableLocation

      public static String tableLocation(TableIdentifier tableIdentifier, boolean useUniqueLocation)
      Returns a path component derived from the tableIdentifier, used as part of the table location URI.

      If useUniqueLocation is true, the returned component will include a random UUID suffix. Otherwise, the plain table name is returned.

      Parameters:
      tableIdentifier - Iceberg table identifier
      useUniqueLocation - whether to ensure uniqueness
      Returns:
      a string representing the table name component for a location URI
    • hasScheme

      public static boolean hasScheme(String location)
      Returns true if the location contains a URI scheme (e.g. s3:, hdfs:, file:), per RFC 3986 section 3.1.
    • resolveLocation

      public static String resolveLocation(String tableLocation, String location)
      Resolves a location against a table location. If the location has a URI scheme, it is returned as-is. Otherwise, the table location and the relative location are joined by the URI separator character /.

      The separator is appended unconditionally; tableLocation is expected not to end with / and location is expected not to start with /. Otherwise the result will contain a duplicate //.

    • relativizeLocation

      public static String relativizeLocation(String tableLocation, String location)
      Relativizes a location against a table location. If the location starts with the table location immediately followed by the URI separator character /, the prefix and separator are removed and the remaining relative portion is returned. Otherwise, the location is returned as-is.

      tableLocation is expected not to end with /. A trailing separator on the table location will cause locations that would otherwise match to be returned unchanged.