Writers¶
Base¶
geoembed.io.writers.base
¶
Abstract base class for embedding writers.
EmbeddingWriter
¶
Bases: ABC
Abstract interface for persisting embedding results.
Implementations handle different storage backends (Parquet, Delta Lake, etc.) while presenting a uniform interface to the pipeline.
write_batch(chip_ids, embeddings)
abstractmethod
¶
Write a batch of embeddings to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chip_ids
|
list[str]
|
List of chip identifiers. |
required |
embeddings
|
ndarray
|
Array of shape (N, D) where N = len(chip_ids) and D = embedding dim. |
required |
Source code in src/geoembed/io/writers/base.py
finalize()
abstractmethod
¶
Perform any cleanup or optimisation after all batches have been written.
E.g., Z-ordering a Delta table, closing file handles, flushing buffers.
Parquet Writer¶
geoembed.io.writers.parquet_writer
¶
Parquet-based embedding writer for local and cloud storage.
ParquetWriter(path, mode='overwrite')
¶
Bases: EmbeddingWriter
Writes embeddings to a local Parquet file.
Accumulates batches in memory and writes once on finalize(), or appends
to an existing file if mode="append".
Suitable for local development and small-to-medium datasets.
Initialise the Parquet writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output file path. |
required |
mode
|
str
|
"overwrite" replaces the file, "append" adds to existing. |
'overwrite'
|
Source code in src/geoembed/io/writers/parquet_writer.py
write_batch(chip_ids, embeddings)
¶
Buffer a batch of embeddings.
finalize()
¶
Write all buffered batches to the Parquet file.
Source code in src/geoembed/io/writers/parquet_writer.py
Delta Writer¶
geoembed.io.writers.delta_writer
¶
Delta Lake embedding writer for Databricks / Unity Catalog.
DeltaWriter(table_name, mode='append', optimize_write=True, cluster_columns=None)
¶
Bases: EmbeddingWriter
Writes embeddings to a Delta Lake table via Spark.
Designed for production use on Databricks with Unity Catalog governance. Supports append mode and optional liquid clustering.
Requires: geoembed[spark] extras.
Initialise the Delta writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_name
|
str
|
Full Unity Catalog table name (e.g., "catalog.schema.table"). |
required |
mode
|
str
|
Spark write mode ("append" or "overwrite"). |
'append'
|
optimize_write
|
bool
|
Enable Delta's optimizeWrite for auto-compaction. |
True
|
cluster_columns
|
list[str] | None
|
Columns for liquid clustering (e.g., ["chip_id"]). Liquid clustering is incremental and automatic — no manual OPTIMIZE runs needed after initial setup. |
None
|
Source code in src/geoembed/io/writers/delta_writer.py
write_batch(chip_ids, embeddings)
¶
Write a batch of embeddings directly to Delta.
Source code in src/geoembed/io/writers/delta_writer.py
finalize()
¶
Apply liquid clustering if configured.