gigl.src.data_preprocessor.lib.transform.parquet_writer#
Writes TFT output record batches as dense Parquet files.
The column layout and file naming are described in gigl.common.data.parquet_format.
features slots follow feature_keys order, with every feature cast to float32 and vectors flattened, matching the
tensors the TFRecord loader builds. Each label key is its own column (float32 for scalar labels,
FixedSizeList<float32> for vector labels). Quantized features are one FixedSizeBinary column of packed bytes per
row, named after the packed feature key recorded in the quantization metadata.
A node entity with three features (one scalar, one 3-vector, one scalar), a packed column and a label has the schema:
node_id: int64
features: fixed_size_list<item: float>[5]
node_packed_features: fixed_size_binary[16]
label: float
An edge entity with features and no label has the schema:
src: int64
dst: int64
features: fixed_size_list<item: float>[5]
Attributes#
Classes#
Converts a TFT |
|
Writes TFT output record batches to |
Module Contents#
- class gigl.src.data_preprocessor.lib.transform.parquet_writer.RecordBatchToDenseArrowTable(id_keys, id_columns, feature_keys, label_keys, packed_feature_key=None, packed_feature_dim=0)[source]#
Bases:
apache_beam.DoFnConverts a TFT
pa.RecordBatchinto apa.Tablewith the dense Parquet schema.Initializes the converter.
- Parameters:
id_keys (Sequence[str]) – TFT output names of the id columns, in output order (
[node_id_key]or[src_key, dst_key]).id_columns (Sequence[str]) – Parquet column names for
id_keys.feature_keys (Sequence[str]) – TFT output names concatenated, in order, into the
featurescolumn.label_keys (Sequence[str]) – TFT output names written as one float32 column each.
packed_feature_key (Optional[str]) – TFT output name of the packed quantized bytes, written as a
FixedSizeBinarycolumn of the same name.Nonewhen features are not quantized.packed_feature_dim (int) – Number of packed bytes per row. Required when
packed_feature_keyis set.
- process(batch)[source]#
Converts one record batch.
- Parameters:
batch (pyarrow.RecordBatch) – A TFT output batch in which every column holds one list (or one scalar) per row.
- Yields:
One table with the id,
features, packed and label columns. Nothing for an empty batch.- Raises:
ValueError – If a column holds nulls or a packed value is not
packed_feature_dimbytes long.- Return type:
Iterator[pyarrow.Table]
- class gigl.src.data_preprocessor.lib.transform.parquet_writer.WriteDenseParquet(parquet_uri_prefix, id_keys, id_columns, feature_keys, label_keys, num_shards, packed_feature_key=None, packed_feature_dim=0)[source]#
Bases:
apache_beam.PTransformWrites TFT output record batches to
<parquet_uri_prefix>part-XXXXX-of-YYYYY.parquetfiles.Initializes the transform.
- Parameters:
parquet_uri_prefix (str) – Directory prefix (ending in
/) of the output files.id_keys (Sequence[str]) – TFT output names of the id columns (one for nodes, two for edges).
id_columns (Sequence[str]) – Parquet column names for
id_keys.feature_keys (Sequence[str]) – TFT output names concatenated into the
featurescolumn. Empty for no features.label_keys (Sequence[str]) – TFT output names written as one float32 column each.
num_shards (int) – Number of output files. 0 starts a new file whenever the current one holds
TARGET_BYTES_PER_PARQUET_FILEof uncompressed data.packed_feature_key (Optional[str]) – TFT output name of the packed quantized bytes.
Nonewhen features are not quantized.packed_feature_dim (int) – Number of packed bytes per row. Required when
packed_feature_keyis set.
- gigl.src.data_preprocessor.lib.transform.parquet_writer.EDGE_ROW_GROUP_ROWS: Final[int] = 1000000[source]#
- gigl.src.data_preprocessor.lib.transform.parquet_writer.NODE_ROW_GROUP_ROWS: Final[int] = 100000[source]#
- gigl.src.data_preprocessor.lib.transform.parquet_writer.PARQUET_FILE_PREFIX: Final[str] = 'part'[source]#