38 if (docData.
empty())
return result;
39 result._size = docData.
size();
41 schema.
join(name,
"0"),
42 (boost::format(doc) % docData.
front()).str(), unit);
54 if (size == 0)
return result;
57 schema.
join(name,
"0"),
67 if (keys.empty())
return;
68 _begin = keys.front();
70 if (keys[i].getOffset() - _begin.getOffset() != (i *
sizeof(T))) {
72 "Keys passed to ArrayKey constructor are not contiguous");
89 if (current.
getOffset() - _begin.getOffset() != (_size *
sizeof(T))) {
91 "Keys discovered in Schema are not contiguous");
110 return ndarray::external(record.getElement(_begin), ndarray::makeVector(_size), ndarray::ROW_MAJOR,
111 record.getManager());
118 "Size of input array (%d) does not match size of array field (%d)");
124 return ndarray::external(record.
getElement(_begin), ndarray::makeVector(_size), ndarray::ROW_MAJOR,
130 return ndarray::external(record.
getElement(_begin), ndarray::makeVector(_size), ndarray::ROW_MAJOR,
144 if (begin >= end || end > _size) {
146 "ArrayKey slice range does not fit within valid range");
148 return ArrayKey((*
this)[begin], end - begin);
#define LSST_EXCEPT(type,...)
#define LSST_THROW_IF_NE(N1, N2, EXC_CLASS, MSG)
Tag types used to declare specialized field types.
A FunctorKey used to get or set a ndarray::Array from a sequence of scalar Keys.
Key< T > operator[](std::size_t i) const
Return a scalar Key for an element of the array.
ndarray::Array< T const, 1, 1 > get(BaseRecord const &record) const override
Get an array from the given record.
void set(BaseRecord &record, ndarray::Array< T const, 1, 1 > const &value) const override
Set an array in the given record.
std::size_t getSize() const noexcept
Return the number of elements in the array.
ArrayKey slice(std::size_t begin, std::size_t end) const
Return a FunctorKey corresponding to a range of elements.
ndarray::ArrayRef< T const, 1, 1 > getConstReference(BaseRecord const &record) const override
Get const reference array from the given record.
ArrayKey() noexcept
Default constructor; instance will not be usable unless subsequently assigned to.
static ArrayKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit, std::vector< T > const &docData)
Add an array of fields to a Schema, and return an ArrayKey that points to them.
ndarray::ArrayRef< T, 1, 1 > getReference(BaseRecord &record) const override
Get non-const reference array from the given record.
Base class for all records.
Field< T >::Element * getElement(Key< T > const &key)
Return a pointer to the underlying elements of a field (non-const).
ndarray::Manager::Ptr getManager() const
A class used as a handle to a particular field in a table.
std::size_t getOffset() const noexcept
Return the offset (in bytes) of this field within a record.
Defines the fields and offsets for a table.
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
A proxy type for name lookups in a Schema.
static Key< T > makeKey(std::size_t offset)