LSST Applications g063fba187b+fee0456c91,g0f08755f38+ea96e5a5a3,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+90257ff92a,g20f6ffc8e0+ea96e5a5a3,g217e2c1bcf+937a289c59,g28da252d5a+daa7da44eb,g2bbee38e9b+253935c60e,g2bc492864f+253935c60e,g3156d2b45e+6e55a43351,g32e5bea42b+31359a2a7a,g347aa1857d+253935c60e,g35bb328faa+a8ce1bb630,g3a166c0a6a+253935c60e,g3b1af351f3+a8ce1bb630,g3e281a1b8c+c5dd892a6c,g414038480c+416496e02f,g41af890bb2+afe91b1188,g599934f4f4+0db33f7991,g7af13505b9+e36de7bce6,g80478fca09+da231ba887,g82479be7b0+a4516e59e3,g858d7b2824+ea96e5a5a3,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+bc6ab8dfbd,gb58c049af0+d64f4d3760,gc28159a63d+253935c60e,gcab2d0539d+3f2b72788c,gcf0d15dbbd+4ea9c45075,gda6a2b7d83+4ea9c45075,gdaeeff99f8+1711a396fd,ge79ae78c31+253935c60e,gef2f8181fd+3031e3cf99,gf0baf85859+c1f95f4921,gfa517265be+ea96e5a5a3,gfa999e8aa5+17cd334064,w.2024.50
LSST Data Management Base Package
|
A mapping between the keys of two Schemas, used to copy data between them. More...
#include <SchemaMapper.h>
Public Member Functions | |
Schema const | getInputSchema () const |
Return the input schema (copy-on-write). | |
Schema const | getOutputSchema () const |
Return the output schema (copy-on-write). | |
Schema & | editOutputSchema () |
Return a reference to the output schema that allows it to be modified in place. | |
template<typename T > | |
Key< T > | addOutputField (Field< T > const &newField, bool doReplace=false) |
Add a new field to the output Schema that is not connected to the input Schema. | |
template<typename T > | |
Key< T > | addMapping (Key< T > const &inputKey, bool doReplace=false) |
Add a new field to the output Schema that is a copy of a field in the input Schema. | |
template<typename T > | |
Key< T > | addMapping (Key< T > const &inputKey, Field< T > const &outputField, bool doReplace=false) |
Add a new mapped field to the output Schema with new descriptions. | |
template<typename T > | |
Key< T > | addMapping (Key< T > const &inputKey, std::string const &outputName, bool doReplace=true) |
Add a new mapped field to the output Schema with a new name. | |
template<typename T > | |
Key< T > | addMapping (Key< T > const &inputKey, char const *outputName, bool doReplace=true)=delete |
This deliberately deleted overload ensures we don't accidentally cast string literals to bool. | |
template<typename Predicate > | |
void | addMappingsWhere (Predicate predicate, bool doReplace=true) |
Add mappings for all fields that match criteria defined by a predicate. | |
void | addMinimalSchema (Schema const &minimal, bool doMap=true) |
Add the given minimal schema to the output schema. | |
void | invert () |
Swap the input and output schemas in-place. | |
template<typename T > | |
bool | isMapped (Key< T > const &inputKey) const |
Return true if the given input Key is mapped to an output Key. | |
template<typename T > | |
Key< T > | getMapping (Key< T > const &inputKey) const |
Return the output Key corresponding to the given input Key, or raise NotFoundError. | |
template<typename F > | |
void | forEach (F &func) const |
Call the given functor for each key pair in the mapper. | |
template<typename F > | |
void | forEach (F const &func) const |
SchemaMapper () | |
Construct an empty mapper; useless unless you assign a fully-constructed one to it. | |
SchemaMapper (Schema const &input, Schema const &output) | |
Construct a mapper from the given input Schema and initial output Schema. | |
SchemaMapper (Schema const &input, bool shareAliasMap=false) | |
Construct a mapper from the given input Schema. | |
SchemaMapper (SchemaMapper const &other) | |
Copy construct (copy-on-write). | |
SchemaMapper (SchemaMapper &&other) | |
SchemaMapper & | operator= (SchemaMapper const &other) |
Assignment (copy-on-write). | |
SchemaMapper & | operator= (SchemaMapper &&other) |
~SchemaMapper () | |
Static Public Member Functions | |
static SchemaMapper | removeMinimalSchema (Schema const &input, Schema const &minimal) |
Create a mapper by removing fields from the front of a schema. | |
static std::vector< SchemaMapper > | join (std::vector< Schema > const &inputs, std::vector< std::string > const &prefixes=std::vector< std::string >()) |
Combine a sequence of schemas into one, creating a SchemaMapper for each. | |
A mapping between the keys of two Schemas, used to copy data between them.
SchemaMapper is initialized with its input Schema, and contains member functions to add mapped or unmapped fields to the output Schema.
Definition at line 21 of file SchemaMapper.h.
|
explicit |
Construct an empty mapper; useless unless you assign a fully-constructed one to it.
Definition at line 105 of file SchemaMapper.cc.
|
explicit |
Construct a mapper from the given input Schema and initial output Schema.
[in] | input | The Schema that fields will be mapped from. |
[in] | output | The starting point for the Schema that fields will be mapped to (no mappings will be created automaticaly). Use addMapping() with doReplace=true to connect input fields to preexisting fields in the output schema. |
Note that the addMapping() methods will not connect input schema fields to existing output schema fields unless doReplace=true; instead, these will by default append new fields to the output schema. So most often you'll want to start with an empty output schema and construct it as fields are mapped from the input schema, or be sure to always pass doReplace=true to addMapping.
Definition at line 111 of file SchemaMapper.cc.
|
explicit |
Construct a mapper from the given input Schema.
[in] | input | The Schema that fields will be mapped from. |
[in] | shareAliasMap | If true, install the input Schema's AliasMap in the output Schema. |
Note that the addMapping() methods will not connect input schema fields to existing output schema fields unless doReplace=true; instead, these will by default append new fields to the output schema. So most often you'll want to start with an empty output schema and construct it as fields are mapped from the input schema, or be sure to always pass doReplace=true to addMapping.
The initial (empty) output schema will have the same version as the input schema, and they will share the same AliasMap (use editOutputSchema().disconnectAliases() to use a copy of the AliasMap).
Definition at line 113 of file SchemaMapper.cc.
lsst::afw::table::SchemaMapper::SchemaMapper | ( | SchemaMapper const & | other | ) |
Copy construct (copy-on-write).
Definition at line 107 of file SchemaMapper.cc.
lsst::afw::table::SchemaMapper::SchemaMapper | ( | SchemaMapper && | other | ) |
Definition at line 109 of file SchemaMapper.cc.
|
default |
Key< T > lsst::afw::table::SchemaMapper::addMapping | ( | Key< T > const & | inputKey, |
bool | doReplace = false ) |
Add a new field to the output Schema that is a copy of a field in the input Schema.
If the input Key has already been mapped, the existing output Key will be reused but the associated Field in the output Schema will be reset to a copy of the input Field.
If doReplace=True and a field with same name already exists in the output schema, that field will be mapped instead of adding a new field to the output schema. If doReplace=false and a name conflict occurs, an exception will be thrown.
Definition at line 130 of file SchemaMapper.cc.
|
delete |
This deliberately deleted overload ensures we don't accidentally cast string literals to bool.
See DM-13787 for more information.
Key< T > lsst::afw::table::SchemaMapper::addMapping | ( | Key< T > const & | inputKey, |
Field< T > const & | outputField, | ||
bool | doReplace = false ) |
Add a new mapped field to the output Schema with new descriptions.
If the input Key has already been mapped, the existing output Key will be reused but the associated Field will be replaced with the given one.
If doReplace=True and a field with same name already exists in the output schema, that field will be mapped instead of adding a new field to the output schema. If doReplace=false and a name conflict occurs, an exception will be thrown.
Definition at line 146 of file SchemaMapper.cc.
Key< T > lsst::afw::table::SchemaMapper::addMapping | ( | Key< T > const & | inputKey, |
std::string const & | outputName, | ||
bool | doReplace = true ) |
Add a new mapped field to the output Schema with a new name.
If the input Key has already been mapped, the existing output Key will be reused but the associated Field will be replaced with one with the given name.
If doReplace=True and a field with same name already exists in the output schema, that field will be mapped instead of adding a new field to the output schema. If doReplace=false and a name conflict occurs, an exception will be thrown.
Definition at line 161 of file SchemaMapper.cc.
void lsst::afw::table::SchemaMapper::addMappingsWhere | ( | Predicate | predicate, |
bool | doReplace = true ) |
Add mappings for all fields that match criteria defined by a predicate.
A mapping in the output Schema will be created for each SchemaItem 'i' in the input Schema such that 'predicate(i)' is true. Note that the predicate must have a templated and/or sufficiently overloaded operator() to match all supported field types, not just those present in the input Schema.
If doReplace=True and a field with same name already exists in the output schema, that field will be mapped instead of adding a new field to the output schema. If doReplace=false and a name conflict occurs, an exception will be thrown.
Definition at line 247 of file SchemaMapper.h.
Add the given minimal schema to the output schema.
This is intended to be used to ensure the output schema starts with some minimal schema. It must be called before any other fields are added to the output schema.
[in] | minimal | Minimal schema to be added to the beginning of the output schema. |
[in] | doMap | Whether to map minimal schema fields that are also present in the input schema. |
Definition at line 179 of file SchemaMapper.cc.
|
inline |
Add a new field to the output Schema that is not connected to the input Schema.
Definition at line 34 of file SchemaMapper.h.
|
inline |
Return a reference to the output schema that allows it to be modified in place.
Definition at line 30 of file SchemaMapper.h.
Call the given functor for each key pair in the mapper.
Function objects should have a template and/or overloaded operator() that takes two Key objects with the same type:
struct Functor { template <typename T> void operator()(Key<T> const & input, Key<T> const & output) const; };
The order of iteration is the same as the order in which mappings were added.
Definition at line 150 of file SchemaMapper.h.
Definition at line 156 of file SchemaMapper.h.
Return the input schema (copy-on-write).
Definition at line 24 of file SchemaMapper.h.
Key< T > lsst::afw::table::SchemaMapper::getMapping | ( | Key< T > const & | inputKey | ) | const |
Return the output Key corresponding to the given input Key, or raise NotFoundError.
Definition at line 206 of file SchemaMapper.cc.
Return the output schema (copy-on-write).
Definition at line 27 of file SchemaMapper.h.
void lsst::afw::table::SchemaMapper::invert | ( | ) |
Swap the input and output schemas in-place.
Definition at line 195 of file SchemaMapper.cc.
bool lsst::afw::table::SchemaMapper::isMapped | ( | Key< T > const & | inputKey | ) | const |
Return true if the given input Key is mapped to an output Key.
Definition at line 201 of file SchemaMapper.cc.
|
static |
Combine a sequence of schemas into one, creating a SchemaMapper for each.
[in] | inputs | A vector of input schemas to merge. |
[in] | prefixes | An optional vector of prefixes for the output field names, either empty or of the same size as the inputs vector. |
Each of the returned SchemaMappers has the same output schema.
Definition at line 215 of file SchemaMapper.cc.
SchemaMapper & lsst::afw::table::SchemaMapper::operator= | ( | SchemaMapper && | other | ) |
Definition at line 125 of file SchemaMapper.cc.
SchemaMapper & lsst::afw::table::SchemaMapper::operator= | ( | SchemaMapper const & | other | ) |
Assignment (copy-on-write).
Definition at line 119 of file SchemaMapper.cc.
|
static |
Create a mapper by removing fields from the front of a schema.
The returned mapper maps all fields in the input schema to all fields that are not in the minimal schema (compared by keys, so the overlap must appear at the beginning of the input schema).
[in] | input | Input schema for the mapper. |
[in] | minimal | The minimal schema the input schema starts with. |
Definition at line 188 of file SchemaMapper.cc.