19 void operator()(Key<U>
const& inputKey, Key<U>
const& outputKey)
const {
21 std::copy(inputElem, inputElem + inputKey.getElementCount(), _outputRecord->getElement(outputKey));
25 void operator()(Key<Array<U> >
const& inputKey, Key<Array<U> >
const& outputKey)
const {
26 if (inputKey.isVariableLength() != outputKey.isVariableLength()) {
28 "At least one input array field is variable-length" 29 " and the correponding output is not, or vice-versa");
31 if (inputKey.isVariableLength()) {
32 ndarray::Array<U, 1, 1> value = ndarray::copy(_inputRecord->get(inputKey));
33 _outputRecord->set(outputKey, value);
37 std::copy(inputElem, inputElem + inputKey.getElementCount(), _outputRecord->getElement(outputKey));
40 void operator()(Key<std::string>
const& inputKey, Key<std::string>
const& outputKey)
const {
41 if (inputKey.isVariableLength() != outputKey.isVariableLength()) {
43 "At least one input string field is variable-length " 44 "and the correponding output is not, or vice-versa");
46 if (inputKey.isVariableLength()) {
48 _outputRecord->set(outputKey, value);
51 char const* inputElem = _inputRecord->getElement(inputKey);
52 std::copy(inputElem, inputElem + inputKey.getElementCount(), _outputRecord->getElement(outputKey));
55 void operator()(Key<Flag>
const& inputKey, Key<Flag>
const& outputKey)
const {
56 _outputRecord->set(outputKey, _inputRecord->get(inputKey));
60 void operator()(SchemaItem<U>
const& item)
const {
61 (*this)(item.key, item.key);
64 CopyValue(BaseRecord
const* inputRecord, BaseRecord* outputRecord)
65 : _inputRecord(inputRecord), _outputRecord(outputRecord) {}
68 BaseRecord
const* _inputRecord;
69 BaseRecord* _outputRecord;
75 if (this->getSchema() != other.
getSchema()) {
78 this->getSchema().forEach(CopyValue(&other,
this));
85 "Unequal schemas between input record and mapper.");
89 "Unequal schemas between output record and mapper.");
91 mapper.
forEach(CopyValue(&other,
this));
96 getSchema().forEach([&os,
this](
auto const& item) {
97 os << item.field.getName() <<
": " << this->
get(item.key) <<
std::endl;
void forEach(F &&func) const
Call the given functor for each key pair in the mapper.
Schema const getInputSchema() const
Return the input schema (copy-on-write).
A mapping between the keys of two Schemas, used to copy data between them.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
ItemVariant const * other
virtual void _stream(std::ostream &os) const
Called by operator<<.
A base class for image defects.
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Schema getSchema() const
Return the Schema that holds this record's fields and keys.
std::ostream & operator<<(std::ostream &os, BaseRecord const &record)
#define LSST_EXCEPT(type,...)
Base class for all records.
FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
void assign(BaseRecord const &other)
Copy all field values from other to this, requiring that they have equal schemas. ...