objectstore · API

objectstore.path

objectstore.path — URI parsing and location handling.

Iceberg stores absolute locations everywhere: a table's location, a snapshot's manifest-list, a manifest entry's file_path. Those strings are the only addressing this stack has, so parsing them precisely — and rewriting them when a warehouse is copied somewhere else — is a first-class concern rather than string fiddling scattered across call sites.

Grammar handled here:

s3://bucket/key/parts        object stores (s3, s3a, s3n, gs, gcs, abfs*, wasb*)
https://host/path?query      HTTP(S), including presigned URLs
file:///abs/path             a local file, RFC 8089 style
file://host/abs/path         tolerated; the host is ignored
/abs/path or rel/path        a bare filesystem path, scheme `file`

Structs

Uri

struct Uri

A parsed location.

bucket is the authority: an S3/GCS bucket, an Azure container's account host, or an HTTP host[:port]. key is everything after it with no leading slash — which is exactly what an S3 request needs, and exactly what a filesystem path needs once the leading slash is put back for file.

Implements Copyable, Movable, Writable

Fields
scheme: String
bucket: String
key: String
query: String
raw: String

__init__

def __init__(out self, var scheme: String, var bucket: String, var key: String, var query: String, var raw: String)

is_local

def is_local(self) -> Bool

is_object_store

def is_object_store(self) -> Bool

local_path

def local_path(self) -> String

The filesystem path for a file: URI.

file:///a/b and /a/b both give /a/b; a relative bare path is returned unchanged so tests/fixtures/x keeps working.

canonical

def canonical(self) -> String

The location rebuilt from its parts — round-trips parse_uri.

write_to

def write_to(self, mut writer: T)

Functions

parse_uri

def parse_uri(location: String) -> Uri

join

def join(base: String, child: String) -> String

Joins a location with a relative child. An absolute child wins.

basename

def basename(location: String) -> String

parent

def parent(location: String) -> String

The containing directory/prefix, with no trailing slash.

s3://b/a/b/c -> s3://b/a/b; s3://b/c -> s3://b; a bare name with no slash has no parent and yields "".

strip_scheme

def strip_scheme(location: String) -> String

file:///a/b -> /a/b; other schemes are returned unchanged.

Kept byte-compatible with iceberg.io.strip_scheme so iceberg.mojo can swap its copy for this one.

url_encode

def url_encode(s: String, encode_slash: Bool = True) -> String

RFC 3986 percent-encoding of everything outside the unreserved set.

SigV4 needs both variants: path segments keep / literal, query keys and values do not (SigV4 §canonical query string).

Aliases

comptime SCHEME_FILE = String("file")
comptime SCHEME_S3 = String("s3")
comptime SCHEME_HTTP = String("http")
comptime SCHEME_HTTPS = String("https")
comptime SCHEME_GS = String("gs")
comptime SCHEME_ABFS = String("abfs")