LSSTApplications
10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
|
A mapping between the keys of two Schemas, used to copy data between them. More...
#include <SchemaMapper.h>
Classes | |
struct | AddMappingsWhere |
Public Member Functions | |
Schema const | getInputSchema () const |
Return the input schema (copy-on-write). More... | |
Schema const | getOutputSchema () const |
Return the output schema (copy-on-write). More... | |
Schema & | editOutputSchema () |
Return a reference to the output schema that allows it to be modified in place. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<typename Predicate > | |
void | addMappingsWhere (Predicate predicate, bool doReplace=true) |
Add mappings for all fields that match criteria defined by a predicate. More... | |
void | addMinimalSchema (Schema const &minimal, bool doMap=true) |
Add the given minimal schema to the output schema. More... | |
void | invert () |
Swap the input and output schemas in-place. More... | |
template<typename T > | |
bool | isMapped (Key< T > const &inputKey) const |
Return true if the given input Key is mapped to an output Key. More... | |
template<typename T > | |
Key< T > | getMapping (Key< T > const &inputKey) const |
Return the output Key corresponding to the given input Key, or raise NotFoundError. More... | |
template<typename F > | |
void | forEach (F func) const |
Call the given functor for each key pair in the mapper. More... | |
SchemaMapper () | |
Construct an empty mapper; useless unless you assign a fully-constructed one to it. More... | |
SchemaMapper (Schema const &input, Schema const &output) | |
Construct a mapper from the given input Schema and initial output Schema. More... | |
SchemaMapper (Schema const &input, bool shareAliasMap=false) | |
Construct a mapper from the given input Schema. More... | |
SchemaMapper (SchemaMapper const &other) | |
Copy construct (copy-on-write). More... | |
SchemaMapper & | operator= (SchemaMapper const &other) |
Assignement (copy-on-write). More... | |
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. More... | |
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. More... | |
Private Types | |
typedef detail::SchemaMapperImpl | Impl |
Private Attributes | |
boost::scoped_ptr< Impl > | _impl |
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 19 of file SchemaMapper.h.
|
private |
Definition at line 223 of file SchemaMapper.h.
|
explicit |
Construct an empty mapper; useless unless you assign a fully-constructed one to it.
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.
|
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).
lsst.afw.table::SchemaMapper::SchemaMapper | ( | SchemaMapper const & | other | ) |
Copy construct (copy-on-write).
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.
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.
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.
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 229 of file SchemaMapper.h.
void lsst.afw.table::SchemaMapper::addMinimalSchema | ( | Schema const & | minimal, |
bool | doMap = true |
||
) |
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. |
|
inline |
Add a new field to the output Schema that is not connected to the input Schema.
Definition at line 33 of file SchemaMapper.h.
|
inline |
Return a reference to the output schema that allows it to be modified in place.
Definition at line 29 of file SchemaMapper.h.
|
inline |
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:
The order of iteration is the same as the order in which mappings were added.
Definition at line 141 of file SchemaMapper.h.
|
inline |
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.
|
inline |
void lsst.afw.table::SchemaMapper::invert | ( | ) |
Swap the input and output schemas in-place.
bool lsst.afw.table::SchemaMapper::isMapped | ( | Key< T > const & | inputKey | ) | const |
Return true if the given input Key is mapped to an output Key.
|
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.
SchemaMapper& lsst.afw.table::SchemaMapper::operator= | ( | SchemaMapper const & | other | ) |
Assignement (copy-on-write).
|
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. |
|
private |
Definition at line 225 of file SchemaMapper.h.