LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
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: