Processor¶
- class lsst.daf.relation.Processor¶
Bases:
ABCAn inheritable framework for processing multi-engine relation trees.
Individual
Engineclasses have different definitions of what it means to process a relation tree, and no single engine can handle a tree with engines. This class provides a recursive algorithm that fills that role, with abstract method hooks for implementingTransferandMaterializeoperations.Notes
The
Processoralgorithm walks the tree recursively until it either finds:a
Relationwith aRelation.payloadthat is notNone, which is returned as-is;a
Materializationoperation, for which a payload is computed via a call to thematerializehook, and then attached to both the original relation (modifying it in-place) and the returned one;a
Transferoperation, for which a payload is computed via a call to thetransferhook, and then the attached to the returned relation only.
In addition,
Processornever calls either hook ontrivialmethods -Engine.get_join_identity_payloadandEngine.get_doomed_payloadare called instead. This can (for example) avoid executing asking a database to execute a SQL query when the relation tree knows in advance the result will have no real content. It also special-casesTransferoperations that are followed immediately by aMaterialization, allowing both operations to be handled by a single call.Methods Summary
materialize(target, name)Hook for implementing materialization operations.
process(relation)Main entry point for processing a relation tree.
transfer(source, destination, materialize_as)Hook for implementing transfers between engines.
Methods Documentation
- abstract materialize(target: Relation, name: str) Any¶
Hook for implementing materialization operations.
This method should be called only by the
Processorbase class.- Parameters:
- target
Relation Relation to be materialized. Any upstream
Transferoperations in this tree are guaranteed to already have apayloadalready attached (or some intervening relation does), so the relation’s own engine should be capable of processing it on its own.- name
str The name of the
Materializationoperation, to be used as needed in the engine-specific payload.
- target
- Returns:
- payload
Payload for this relation that should be cached.
- process(relation: Relation) Relation¶
Main entry point for processing a relation tree.
- Parameters:
- relation
Relation Root of the relation tree to process. On return, relations that hold a
Materializationrelation will have a newpayloadattached, if they did not have one already.
- relation
- Returns:
- abstract transfer(source: Relation, destination: Engine, materialize_as: str | None) Any¶
Hook for implementing transfers between engines.
This method should be called only by the
Processorbase class.- Parameters:
- source
Relation Relation to be transferred. Any upstream
Transferoperations in this tree are guaranteed to already have apayloadalready attached (or some intervening relation does), so the relation’s own engine should be capable of processing it on its own.- destination
Engine Engine the relation is being transferred to.
- materialize_as
strorNone If not
None, the name of aMaterializationoperation that immediately follows the transfer being implemented, in which case the returnedpayloadshould be appropriate for caching with theMaterialization.
- source
- Returns:
- payload
Payload for this relation in the
destinationengine.