1#include "boost/preprocessor/seq/for_each.hpp"
2#include "boost/preprocessor/tuple/to_seq.hpp"
16 bool operator()(SchemaItem<Flag>
const &item)
const {
return item.key ==
target; }
18 explicit MatchKey(Key<Flag>
const &t) :
target(t) {}
24 bool operator()(SchemaItem<Flag>
const &item)
const {
return item.field.getName() ==
target; }
37 (boost::format(
"'%s' not found in BitsColumn") % key).str());
46 (boost::format(
"'%s' not found in BitsColumn") %
name).str());
62 ndarray::Manager::Ptr
const &
manager_)
75 "Key is not valid (if this is a SourceCatalog, make sure slot aliases have been set up).");
77 return ndarray::external(
reinterpret_cast<T *
>(
reinterpret_cast<char *
>(_impl->buf) + key.getOffset()),
78 ndarray::makeVector(_impl->recordCount),
79 ndarray::makeVector(_impl->table->getSchema().getRecordSize() /
sizeof(T)),
88 "Key is not valid (if this is a SourceCatalog, make sure slot aliases have been set up).");
90 if (key.isVariableLength()) {
93 return ndarray::external(
94 reinterpret_cast<T *
>(
reinterpret_cast<char *
>(_impl->buf) + key.getOffset()),
95 ndarray::makeVector(_impl->recordCount, key.getSize()),
96 ndarray::makeVector(_impl->table->getSchema().getRecordSize() /
sizeof(T),
std::size_t(1)),
100ndarray::result_of::vectorize<detail::FlagExtractor, ndarray::Array<Field<Flag>::Element
const, 1> >
::type
102 if (!key.isValid()) {
105 "Key is not valid (if this is a SourceCatalog, make sure slot aliases have been set up).");
110 reinterpret_cast<char *
>(_impl->buf) + key.getOffset()),
111 ndarray::makeVector(_impl->recordCount),
112 ndarray::makeVector(_impl->table->getSchema().getRecordSize() /
119 using AngleArray = ndarray::Array<lsst::geom::Angle, 1>;
121 return ndarray::detail::ArrayAccess<DoubleArray>::construct(
123 ndarray::detail::ArrayAccess<AngleArray>::getCore(
angle_array)
129 ndarray::ArrayRef<BitsColumn::SizeT, 1, 1> array = result._array.deep();
132 (boost::format(
"Too many keys passed to getBits(); %d > %d.") % keys.size() %
146struct ExtractFlagItems {
147 template <
typename T>
150 void operator()(SchemaItem<Flag>
const &item)
const { items->push_back(item); }
159 ExtractFlagItems
func = {&result._items};
163 (boost::format(
"Too many Flag keys in schema; %d > %d.") % result._items.size() %
167 ndarray::ArrayRef<BitsColumn::SizeT, 1, 1> array = result._array.deep();
184 ndarray::Manager::Ptr
const &manager)
185 : _impl(
std::make_shared<
Impl>(table, recordCount, buf, manager)) {}
189#define INSTANTIATE_COLUMNVIEW_SCALAR(r, data, elem) \
190 template ndarray::ArrayRef<elem, 1> const BaseColumnView::operator[](Key<elem> const &) const;
195#define INSTANTIATE_COLUMNVIEW_ARRAY(r, data, elem) \
196 template ndarray::ArrayRef<elem, 2, 1> const BaseColumnView::operator[](Key<Array<elem> > const &) const;
table::Key< std::string > name
#define INSTANTIATE_COLUMNVIEW_SCALAR(r, data, elem)
Key< Flag > const & target
#define INSTANTIATE_COLUMNVIEW_ARRAY(r, data, elem)
#define LSST_EXCEPT(type,...)
Tag types used to declare specialized field types.
Column-wise view into a sequence of records that have been allocated contiguously.
BaseColumnView & operator=(BaseColumnView const &)
BitsColumn getBits(std::vector< Key< Flag > > const &keys) const
Return an integer array with the given Flag fields repacked into individual bits.
Schema getSchema() const
Return the schema that defines the fields.
BaseColumnView(BaseColumnView const &)
BitsColumn getAllBits() const
Return an integer array with all Flag fields repacked into individual bits.
ndarray::Array< double, 1 > const get_radians_array(Key< Angle > const &key) const
Return an array column as a double array in radians.
std::shared_ptr< BaseTable > getTable() const
Return the table that owns the records.
ndarray::ArrayRef< T, 1 > const operator[](Key< T > const &key) const
Return a 1-d array corresponding to a scalar field (or subfield).
A packed representation of a collection of Flag field columns.
SizeT getBit(Key< Flag > const &key) const
A class used as a handle to a particular field in a table.
void forEach(F &func) const
Apply a functor to each SchemaItem in the Schema.
SchemaItem< T > find(std::string const &name) const
Find a SchemaItem in the Schema by name.
BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_SCALAR, _, BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE)) BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_ARRAY
std::shared_ptr< BaseTable > table
Impl(std::shared_ptr< BaseTable > const &table_, size_t recordCount_, void *buf_, ndarray::Manager::Ptr const &manager_)
ndarray::Manager::Ptr manager
typename FieldBase< T >::Element Element
Type used to store field data in the table (a field may have multiple elements).
#define AFW_TABLE_ARRAY_FIELD_TYPE_TUPLE
#define AFW_TABLE_ARRAY_FIELD_TYPE_N
#define AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE
#define AFW_TABLE_SCALAR_FIELD_TYPE_N