gigl.common.data.parquet_manifest#
Row-count manifest of a directory of Parquet files.
Reading the footer of every Parquet file of an entity to learn its row-group sizes costs one storage request per file on
every rank. The manifest _row_counts.json is written once, next to the data files, and holds the same information:
{"version": 2,
"files": {"part-00000-of-00002.parquet": {"row_groups": [100000, 100000, 523], "size_bytes": 81234567},
...}}
Keys are file names relative to the directory. Each value holds:
row_groups: the row counts of the file’s row groups, in order.size_bytes: the file’s size. Reading the manifest compares it with the size in the directory listing, so a file rewritten after the manifest was written fails the read unless its size is unchanged. Listings already return sizes, so the check costs no extra storage requests.
The name does not end in .parquet, so file listings of the data never include it.
The data preprocessor writes one directory per node type and per edge type. The manifest sits next to the data files:
Node type
user:gs://<temp bucket>/<job name>/data_preprocess/staging/transformed_node_features_dir/user/parquet/_row_counts.json gs://<temp bucket>/<job name>/data_preprocess/staging/transformed_node_features_dir/user/parquet/part-00000-of-00042.parquet gs://<temp bucket>/<job name>/data_preprocess/staging/transformed_node_features_dir/user/parquet/part-00001-of-00042.parquet
Edge type
user-follows-user. The directory below the edge type is the edge usage type:mainfor the graph edges,positiveandnegativefor label edges:gs://<temp bucket>/<job name>/data_preprocess/staging/transformed_edge_features_dir/user-follows-user/main/parquet/_row_counts.json gs://<temp bucket>/<job name>/data_preprocess/staging/transformed_edge_features_dir/user-follows-user/main/parquet/part-00000-of-00042.parquet
Attributes#
Functions#
|
Builds the manifest of the Parquet files under |
|
Returns the filesystem for |
|
Returns the Parquet data files directly under |
|
Returns the path of the manifest in the directory |
|
Returns the row-group row counts of |
|
Builds the manifest of the Parquet files under |
Module Contents#
- gigl.common.data.parquet_manifest.build_manifest(uri_prefix, num_threads=_DEFAULT_THREADS)[source]#
Builds the manifest of the Parquet files under
uri_prefixby reading each footer once.- Parameters:
uri_prefix (Uri) – The directory that holds the Parquet files.
num_threads (int) – The number of threads that read footers in parallel.
- Returns:
The manifest, with the keys
versionandfiles.- Return type:
dict[str, Any]
- Raises:
ValueError – If the listing does not report a file’s size.
- gigl.common.data.parquet_manifest.filesystem_and_path(uri)[source]#
Returns the filesystem for
uriand the path ofuriwithin it.GCS URIs get a GCS filesystem with a longer retry limit, and the path is
<bucket>/<object path>. Any other URI is resolved by pyarrow.- Parameters:
uri (Uri) – The location of the directory or file.
- Returns:
The filesystem and the scheme-less path within it, such as
my-bucket/my_job/parquet/.- Return type:
tuple[pafs.FileSystem, str]
- gigl.common.data.parquet_manifest.list_parquet_files(fs, path)[source]#
Returns the Parquet data files directly under
path, sorted by path.- Parameters:
fs (pafs.FileSystem) – The filesystem that holds
path.path (str) – The scheme-less directory path within
fs.
- Returns:
- The files that end in
.parquet, sorted by full path. Each has thepathand sizefrom the listing. The manifest itself is not included.
- The files that end in
- Return type:
list[pafs.FileInfo]
- gigl.common.data.parquet_manifest.manifest_path(path)[source]#
Returns the path of the manifest in the directory
path.- Parameters:
path (str) – The scheme-less directory path, with or without a trailing slash.
- Returns:
pathjoined with the manifest file name.- Return type:
str
- gigl.common.data.parquet_manifest.read_manifest_row_groups(fs, path, files)[source]#
Returns the row-group row counts of
files(as listed underpath) from the manifest underpath.- Parameters:
fs (pafs.FileSystem) – The filesystem that holds
path.path (str) – The scheme-less directory path within
fs.files (list[pafs.FileInfo]) – The data files listed under
path, as returned bylist_parquet_files.
- Returns:
One list of row-group row counts per entry of
files, in the same order.- Return type:
list[list[int]]
- Raises:
FileNotFoundError – If there is no manifest.
ValueError – If the manifest is malformed, has an unknown version, does not list exactly
files, or lists a size that differs from a file’s listed size.
- gigl.common.data.parquet_manifest.write_manifest(uri_prefix, num_threads=_DEFAULT_THREADS)[source]#
Builds the manifest of the Parquet files under
uri_prefixand writes it there.- Parameters:
uri_prefix (Uri) – The directory that holds the Parquet files.
num_threads (int) – The number of threads that read footers in parallel.
- Returns:
The manifest that was written.
- Return type:
dict[str, Any]
- Raises:
ValueError – If the listing does not report a file’s size.