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