LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
lsst::afw::table::io::InputArchive::Impl Class Reference

Public Member Functions

std::shared_ptr< Persistableget (int id, InputArchive const &self)
 
Map constgetAll (InputArchive const &self)
 
 Impl ()
 
 Impl (BaseCatalog const &index, CatalogVector const &catalogs)
 
 Impl (const Impl &)=delete
 
Imploperator= (const Impl &)=delete
 
 Impl (Impl &&)=delete
 
Imploperator= (Impl &&)=delete
 

Public Attributes

Map _map
 
BaseCatalog _index
 
CatalogVector _catalogs
 

Detailed Description

Definition at line 38 of file InputArchive.cc.

Constructor & Destructor Documentation

◆ Impl() [1/4]

lsst::afw::table::io::InputArchive::Impl::Impl ( )
inline

Definition at line 137 of file InputArchive.cc.

137: _index(ArchiveIndexSchema::get().schema) {}
static ArchiveIndexSchema const & get()
Return the singleton instance.

◆ Impl() [2/4]

lsst::afw::table::io::InputArchive::Impl::Impl ( BaseCatalog const & index,
CatalogVector const & catalogs )
inline

Definition at line 139 of file InputArchive.cc.

139 : _index(index), _catalogs(catalogs) {
140 if (index.getSchema() != indexKeys.schema) {
141 throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Incorrect schema for index catalog");
142 }
144 _index.sort(IndexSortCompare());
145 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
Definition Catalog.h:755
T insert(T... args)
T make_pair(T... args)

◆ Impl() [3/4]

lsst::afw::table::io::InputArchive::Impl::Impl ( const Impl & )
delete

◆ Impl() [4/4]

lsst::afw::table::io::InputArchive::Impl::Impl ( Impl && )
delete

Member Function Documentation

◆ get()

std::shared_ptr< Persistable > lsst::afw::table::io::InputArchive::Impl::get ( int id,
InputArchive const & self )
inline

Definition at line 40 of file InputArchive.cc.

40 {
42 if (id == 0) return empty;
44 if (r.second) {
45 // insertion successful means we haven't reassembled this object yet; do that now.
46 CatalogVector factoryArgs;
47 // iterate over records in index with this ID; we know they're sorted by ID and then
48 // by catPersistable, so we can just append to factoryArgs.
50 std::string module;
51 for (BaseCatalog::iterator indexIter = _index.find(id, indexKeys.id);
52 indexIter != _index.end() && indexIter->get(indexKeys.id) == id; ++indexIter) {
53 if (name.empty()) {
54 name = indexIter->get(indexKeys.name);
55 } else if (name != indexIter->get(indexKeys.name)) {
56 throw LSST_EXCEPT(
57 MalformedArchiveError,
58 (boost::format("Inconsistent name in index for ID %d; got '%s', expected '%s'") %
59 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.name) % name)
60 .str());
61 }
62 if (module.empty()) {
63 module = indexIter->get(indexKeys.module);
64 } else if (module != indexIter->get(indexKeys.module)) {
65 throw LSST_EXCEPT(
66 MalformedArchiveError,
67 (boost::format(
68 "Inconsistent module in index for ID %d; got '%s', expected '%s'") %
69 indexIter->get(indexKeys.id) % indexIter->get(indexKeys.module) % module)
70 .str());
71 }
72 int catArchive = indexIter->get(indexKeys.catArchive);
73 if (catArchive == ArchiveIndexSchema::NO_CATALOGS_SAVED) {
74 break; // object was written with saveEmpty, and hence no catalogs.
75 }
76 std::size_t catN = catArchive - 1;
77 if (catN >= _catalogs.size()) {
78 throw LSST_EXCEPT(
79 MalformedArchiveError,
80 (boost::format(
81 "Invalid catalog number in index for ID %d; got '%d', max is '%d'") %
82 indexIter->get(indexKeys.id) % catN % _catalogs.size())
83 .str());
84 }
85 BaseCatalog& fullCatalog = _catalogs[catN];
86 std::size_t i1 = indexIter->get(indexKeys.row0);
87 std::size_t i2 = i1 + indexIter->get(indexKeys.nRows);
88 if (i2 > fullCatalog.size()) {
89 throw LSST_EXCEPT(MalformedArchiveError,
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)
94 .str());
95 }
96 factoryArgs.push_back(BaseCatalog(fullCatalog.getTable(), fullCatalog.begin() + i1,
97 fullCatalog.begin() + i2));
98 }
99 try {
100 PersistableFactory const& factory = PersistableFactory::lookup(name, module);
101 r.first->second = factory.read(self, factoryArgs);
102 } catch (pex::exceptions::Exception& err) {
103 LSST_EXCEPT_ADD(err,
104 (boost::format("loading object with id=%d, name='%s'") % id % name).str());
105 throw;
106 }
107 // If we're loading the object for the first time, and we've failed, we should have already
108 // thrown an exception, and we assert that here.
109 assert(r.first->second);
110 } else if (!r.first->second) {
111 // If we'd already tried and failed to load this object before - but we'd caught the exception
112 // previously (because the calling code didn't consider that to be a fatal error) - we'll
113 // just throw an exception again. While we can't know exactly what was thrown before,
114 // it's most likely it was a NotFoundError because a needed extension package was not setup.
115 // And conveniently it's appropriate to throw that here too, since now the problem is that
116 // the object should have been loaded into the cache and it wasn't found there.
117 throw LSST_EXCEPT(pex::exceptions::NotFoundError,
118 (boost::format("Not trying to reload object with id=%d; a previous attempt to "
119 "load it already failed.") %
120 id)
121 .str());
122 }
123 return r.first->second;
124 }
table::Key< std::string > name
Definition Amplifier.cc:116
table::Key< int > id
Definition Detector.cc:162
#define LSST_EXCEPT_ADD(e, m)
Add the current location and a message to an existing exception before rethrowing it.
Definition Exception.h:54
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
Definition Catalog.h:762
CatalogIterator< typename Internal::iterator > iterator
Definition Catalog.h:110
static PersistableFactory const & lookup(std::string const &name, std::string const &module="")
Return the factory that has been registered with the given name.
CatalogT< BaseRecord > BaseCatalog
Definition fwd.h:72
T size(T... args)
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.

◆ getAll()

Map const & lsst::afw::table::io::InputArchive::Impl::getAll ( InputArchive const & self)
inline

Definition at line 126 of file InputArchive.cc.

126 {
127 int id = 0;
128 for (BaseCatalog::iterator indexIter = _index.begin(); indexIter != _index.end(); ++indexIter) {
129 if (indexIter->get(indexKeys.id) != id) {
130 id = indexIter->get(indexKeys.id);
131 get(id, self);
132 }
133 }
134 return _map;
135 }
iterator begin()
Iterator access.
Definition Catalog.h:400
std::shared_ptr< Persistable > get(int id, InputArchive const &self)

◆ operator=() [1/2]

Impl & lsst::afw::table::io::InputArchive::Impl::operator= ( const Impl & )
delete

◆ operator=() [2/2]

Impl & lsst::afw::table::io::InputArchive::Impl::operator= ( Impl && )
delete

Member Data Documentation

◆ _catalogs

CatalogVector lsst::afw::table::io::InputArchive::Impl::_catalogs

Definition at line 157 of file InputArchive.cc.

◆ _index

BaseCatalog lsst::afw::table::io::InputArchive::Impl::_index

Definition at line 156 of file InputArchive.cc.

◆ _map

Map lsst::afw::table::io::InputArchive::Impl::_map

Definition at line 155 of file InputArchive.cc.


The documentation for this class was generated from the following file: