lsst.afw
20.0.0-4-gde602ef96+5
|
Go to the documentation of this file.
3 #include "boost/format.hpp"
22 struct IndexSortCompare {
23 bool operator()(BaseRecord
const&
a, BaseRecord
const&
b)
const {
24 if (
a.get(indexKeys.id) <
b.get(indexKeys.id)) {
27 if (
a.get(indexKeys.id) ==
b.get(indexKeys.id)) {
28 return a.get(indexKeys.catPersistable) <
b.get(indexKeys.catPersistable);
42 if (
id == 0)
return empty;
52 indexIter !=
_index.
end() && indexIter->get(indexKeys.id) ==
id; ++indexIter) {
54 name = indexIter->get(indexKeys.name);
55 }
else if (
name != indexIter->get(indexKeys.name)) {
58 (boost::format(
"Inconsistent name in index for ID %d; got '%s', expected '%s'") %
59 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.name) %
name)
63 module = indexIter->get(indexKeys.module);
64 }
else if (module != indexIter->get(indexKeys.module)) {
68 "Inconsistent module in index for ID %d; got '%s', expected '%s'") %
69 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.module) % module)
72 int catArchive = indexIter->get(indexKeys.catArchive);
81 "Invalid catalog number in index for ID %d; got '%d', max is '%d'") %
87 std::size_t i2 = i1 + indexIter->get(indexKeys.nRows);
88 if (i2 > fullCatalog.
size()) {
90 (boost::format(
"Index and data catalogs do not agree for ID %d; "
91 "catalog %d has %d rows, not %d") %
92 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.catArchive) %
93 fullCatalog.
size() % i2)
97 fullCatalog.
begin() + i2));
101 r.first->second = factory.
read(
self, factoryArgs);
104 (boost::format(
"loading object with id=%d, name='%s'") %
id %
name).str());
109 assert(r.first->second);
110 }
else if (!r.first->second) {
118 (boost::format(
"Not trying to reload object with id=%d; a previous attempt to "
119 "load it already failed.") %
123 return r.first->second;
129 if (indexIter->get(indexKeys.id) !=
id) {
130 id = indexIter->get(indexKeys.id);
140 if (index.
getSchema() != indexKeys.schema) {
167 : _impl(new
Impl(index, catalogs)) {}
192 boost::format(
"Wrong value for archive index EXTTYPE: '%s'") %
195 int nCatalogs = metadata->
get<
int>(
"AR_NCAT");
198 for (
int n = 1; n < nCatalogs; ++n) {
201 metadata = catalogs.back().getTable()->popMetadata();
204 boost::format(
"Wrong value for archive data EXTTYPE: '%s'") %
207 if (metadata->
get<
int>(
"AR_CATN") != n) {
210 boost::format(
"Incorrect order for archive catalogs: AR_CATN=%d found at position %d") %
211 metadata->
get<
int>(
"AR_CATN") % n);
static PersistableFactory const & lookup(std::string const &name, std::string const &module="")
Return the factory that has been registered with the given name.
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.
An exception thrown when problems are found when reading or writing FITS files.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
#define LSST_EXCEPT_ADD(e, m)
static ArchiveIndexSchema const & get()
Return the singleton instance.
size_type size() const
Return the number of elements in the catalog.
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...
Schema for the index catalog that specifies where objects are stored in the data catalogs.
ItemVariant const * other
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
void setHdu(int hdu, bool relative=false)
Set the current HDU.
A vector of catalogs used by Persistable.
Schema getSchema() const
Return the schema associated with the catalog's table.
virtual std::shared_ptr< Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const =0
Construct a new object from the given InputArchive and vector of catalogs.
Iterator class for CatalogT.
A base class for factory classes used to reconstruct objects from records.
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
static CatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
A base class for image defects.
#define LSST_EXCEPT(type,...)
CatalogT< BaseRecord > BaseCatalog
iterator begin()
Iterator access.