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; }
34 IntT r =
std::find_if(_items.begin(), _items.end(), MatchKey(key)) - _items.begin();
43 IntT r =
std::find_if(_items.begin(), _items.end(), MatchName(name)) - _items.begin();
51 BitsColumn::BitsColumn(
int size) : _array(ndarray::allocate(size)) { _array.deep() =
IntT(0); }
62 ndarray::Manager::Ptr
const &manager_)
63 : recordCount(recordCount_), buf(buf_), table(table_), manager(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(
int(_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(
int(_impl->table->getSchema().getRecordSize() /
sizeof(T)), 1),
100 ndarray::result_of::vectorize<detail::FlagExtractor, ndarray::Array<Field<Flag>::Element
const, 1> >
::type 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(
int(_impl->table->getSchema().getRecordSize() /
119 ndarray::ArrayRef<BitsColumn::IntT, 1, 1> array = result._array.deep();
129 result._items.push_back(getSchema().find(
keys[i]));
136 struct ExtractFlagItems {
137 template <
typename T>
149 ExtractFlagItems func = {&result._items};
150 getSchema().forEach(func);
153 (
boost::format(
"Too many Flag keys in schema; %d > %d.") % result._items.size() %
157 ndarray::ArrayRef<BitsColumn::IntT, 1, 1> array = result._array.deep();
174 ndarray::Manager::Ptr
const &manager)
175 : _impl(
std::make_shared<
Impl>(table, recordCount, buf, manager)) {}
179 #define INSTANTIATE_COLUMNVIEW_SCALAR(r, data, elem) \ 180 template ndarray::ArrayRef<elem, 1> const BaseColumnView::operator[](Key<elem> const &) const; 185 #define INSTANTIATE_COLUMNVIEW_ARRAY(r, data, elem) \ 186 template ndarray::ArrayRef<elem, 2, 1> const BaseColumnView::operator[](Key<Array<elem> > const &) const; #define AFW_TABLE_SCALAR_FIELD_TYPE_N
Column-wise view into a sequence of records that have been allocated contiguously.
A packed representation of a collection of Flag field columns.
int getOffset() const noexcept
Return the offset (in bytes) of this field within a record.
BaseColumnView & operator=(BaseColumnView const &)
BitsColumn getAllBits() const
Return an integer array with all Flag fields repacked into individual bits.
std::shared_ptr< BaseTable > getTable() const
Return the table that owns the records.
Reports attempts to exceed implementation-defined length limits for some classes. ...
IntT getBit(Key< Flag > const &key) const
BitsColumn getBits(std::vector< Key< Flag > > const &keys) const
Return an integer array with the given Flag fields repacked into individual bits. ...
bool isValid() const
Return true if the key was initialized to valid offset.
std::shared_ptr< BaseTable > table
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Reports attempts to access elements using an invalid key.
A base class for image defects.
#define AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE
#define AFW_TABLE_ARRAY_FIELD_TYPE_N
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Impl(std::shared_ptr< BaseTable > const &table_, int recordCount_, void *buf_, ndarray::Manager::Ptr const &manager_)
A description of a field in a table.
Tag types used to declare specialized field types.
BaseColumnView(BaseColumnView const &)
Reports errors in the logical structure of the program.
Key< Flag > const & target
ndarray::ArrayRef< T, 1 > const operator[](Key< T > const &key) const
Return a 1-d array corresponding to a scalar field (or subfield).
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
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define INSTANTIATE_COLUMNVIEW_ARRAY(r, data, elem)
A class used as a handle to a particular field in a table.
Key specialization for Flag.
#define INSTANTIATE_COLUMNVIEW_SCALAR(r, data, elem)
ndarray::Manager::Ptr manager
std::vector< SchemaItem< Flag > > * items
int getOffset() const
Return the offset in bytes of the integer element that holds this field's bit.
#define AFW_TABLE_ARRAY_FIELD_TYPE_TUPLE
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...