3#include "boost/format.hpp"
22struct 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;
58 (boost::format(
"Inconsistent name in index for ID %d; got '%s', expected '%s'") %
63 module = indexIter->get(indexKeys.module);
68 "Inconsistent module in index for ID %d; got '%s', expected '%s'") %
81 "Invalid catalog number in index for ID %d; got '%d', max is '%d'") %
90 (boost::format(
"Index and data catalogs do not agree for ID %d; "
91 "catalog %d has %d rows, not %d") %
104 (boost::format(
"loading object with id=%d, name='%s'") %
id %
name).str());
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;
189 boost::format(
"Wrong value for archive index EXTTYPE: '%s'") %
198 metadata =
catalogs.back().getTable()->popMetadata();
201 boost::format(
"Wrong value for archive data EXTTYPE: '%s'") %
204 if (metadata->
get<
int>(
"AR_CATN") != n) {
207 boost::format(
"Incorrect order for archive catalogs: AR_CATN=%d found at position %d") %
208 metadata->
get<
int>(
"AR_CATN") % n);
table::Key< std::string > name
#define LSST_EXCEPT_ADD(e, m)
#define LSST_EXCEPT(type,...)
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...
Tag types used to declare specialized field types.
static CatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
iterator begin()
Iterator access.
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Schema getSchema() const
Return the schema associated with the catalog's table.
A vector of catalogs used by Persistable.
A base class for factory classes used to reconstruct objects from records.
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.
static PersistableFactory const & lookup(std::string const &name, std::string const &module="")
Return the factory that has been registered with the given name.
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...
CatalogT< BaseRecord > BaseCatalog
Schema for the index catalog that specifies where objects are stored in the data catalogs.
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.
static ArchiveIndexSchema const & get()
Return the singleton instance.