stratified_packager.processing.staging

Per-layer staging decisions (SPEC §8.2).

Staging is no longer a correctness requirement. QgsVectorFileWriter reads a layer through its QGIS provider, so memory providers, joins, virtual/expression fields and unsaved edits are written directly, and per-stratum matching is computed against the very layer that is written — the QGIS-fid ↔ OGR-FID equivalence problem that once forced staging is gone. Staging is now a pure read-amortization optimization: a source read many times (every whole_export layer, any layer of a STAGE_PROVIDERS provider, or any layer the user marks) is copied once into a local GeoPackage holding only the features some stratum uses (or every feature when EXPORT_FULL_PACKAGE is on, since the <full> stratum reads the whole copy), and every stratum then reads its slice from that fast local copy instead of re-fetching from a slow source.

The decision is the layer’s tri-state stratified_packager_stage variable: true / false force it, unset (or auto) stages iff the matching method is whole_export (the data that lands, identically, in every stratum) or the layer’s data provider is in the resolved STAGE_PROVIDERS set (a provider the user declared slow enough that every read beyond the first must hit a local copy). The staging write itself reuses write_vector_table(); this module only decides.

Functions

effective_stage(layer, *, method, ...)

Resolve whether layer's data is staged into a local GeoPackage (SPEC §8.2).

staged_layer_uri(staging_gpkg, table, /)

Build the OGR uri of a staged table, for the algorithm thread's read layer.

stratified_packager.processing.staging.effective_stage(layer, *, method, stage_providers)[source]

Resolve whether layer’s data is staged into a local GeoPackage (SPEC §8.2).

The layer’s stratified_packager_stage variable is tri-state: true/false force the decision; unset (or auto) stages iff method is whole_export — the layer whose features land, identically, in every stratum — or the layer’s data provider is in stage_providers, the resolved STAGE_PROVIDERS set of providers whose layers would otherwise be re-read from a slow source once per stratum.

Parameters:
Return type:

bool

Returns:

Whether the layer is staged.

Raises:

ValueError – If the variable holds a value that is neither boolean nor auto.

stratified_packager.processing.staging.staged_layer_uri(staging_gpkg, table, /)[source]

Build the OGR uri of a staged table, for the algorithm thread’s read layer.

Parameters:
  • staging_gpkg (Path) – The staging GeoPackage.

  • table (str) – The staged table name.

Return type:

str

Returns:

The path|layername=table uri.