LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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.