LSSTApplications  19.0.0-14-gb0260a2+64befe7c1c,20.0.0+0b340dd7c4,20.0.0+1540ce6389,20.0.0+7c6b12c2f9,20.0.0+ae956f52c5,20.0.0+be870186d9,20.0.0+e2e26847c2,20.0.0-1-g04bee24+7c6b12c2f9,20.0.0-1-g10df615+fbe45b1aff,20.0.0-1-g253301a+7c6b12c2f9,20.0.0-1-g2b7511a+46a6078777,20.0.0-1-g4d801e7+9d50d6c21a,20.0.0-1-g5b95a8c+8ebfc75efb,20.0.0-1-gb058bd0+46a6078777,20.0.0-1-gb88604f+acecce4127,20.0.0-1-gc96f8cb+016e330d09,20.0.0-1-gedffbd8+83814edeba,20.0.0-10-g0891cd99+a5f14e9acb,20.0.0-10-g9a20bd332+576ca7b471,20.0.0-17-gcdbda88+0e26bfb1e6,20.0.0-2-g4dae9ad+016e330d09,20.0.0-2-g61b8584+85c46248f3,20.0.0-2-gb780d76+f45b7d88f4,20.0.0-21-g9bbb7f7+016e330d09,20.0.0-22-gc512666+f30f3883a7,20.0.0-23-g8900aa8+68630f7098,20.0.0-3-g1653f94+85c46248f3,20.0.0-3-g4cc78c6+63636aeed8,20.0.0-3-g750bffe+e05f822de9,20.0.0-3-gbd60e8c+ff10c6d78d,20.0.0-32-g15a0e07c+a4c9d0309b,20.0.0-4-g97dc21a+68630f7098,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-6-g9a5b7a1+b0f8c2be93,20.0.0-60-gad89340+e4dd172200,20.0.0-7-gcda7bf1+673816f70c,w.2020.43
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst::afw::table::io::OutputArchive::Impl Class Reference

Public Member Functions

BaseCatalog makeCatalog (Schema const &schema)
 
std::shared_ptr< BaseRecordaddIndexRecord (int id, std::string const &name, std::string const &module)
 
void saveEmpty (int id, std::string const &name, std::string const &module)
 
void saveCatalog (BaseCatalog const &catalog, int id, std::string const &name, std::string const &module, int catPersistable)
 
int put (Persistable const *obj, std::shared_ptr< Impl > const &self, bool permissive)
 
int put (std::shared_ptr< Persistable const > obj, std::shared_ptr< Impl > const &self, bool permissive)
 
void writeFits (fits::Fits &fitsfile)
 
 Impl ()
 

Public Attributes

int _nextId
 
Map _map
 
BaseCatalog _index
 
CatalogVector _catalogs
 

Detailed Description

Definition at line 37 of file OutputArchive.cc.

Constructor & Destructor Documentation

◆ Impl()

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

Definition at line 142 of file OutputArchive.cc.

143  std::shared_ptr<daf::base::PropertyList> metadata(new daf::base::PropertyList());
144  metadata->set("EXTTYPE", "ARCHIVE_INDEX");
145  metadata->set("AR_CATN", 0, "# of this catalog relative to the start of this archive");
146  _index.getTable()->setMetadata(metadata);
147  }

Member Function Documentation

◆ addIndexRecord()

std::shared_ptr<BaseRecord> lsst::afw::table::io::OutputArchive::Impl::addIndexRecord ( int  id,
std::string const &  name,
std::string const &  module 
)
inline

Definition at line 60 of file OutputArchive.cc.

60  {
61  auto indexRecord = _index.addNew();
62  indexRecord->set(indexKeys.id, id);
63  indexRecord->set(indexKeys.name, name);
64  indexRecord->set(indexKeys.module, module);
65  return indexRecord;
66  }

◆ makeCatalog()

BaseCatalog lsst::afw::table::io::OutputArchive::Impl::makeCatalog ( Schema const &  schema)
inline

Definition at line 39 of file OutputArchive.cc.

39  {
40  int catArchive = 1;
41  CatalogVector::iterator iter = _catalogs.begin();
43  for (; iter != _catalogs.end(); ++iter, ++catArchive) {
44  if (iter->getSchema().compare(schema, flags) == flags) {
45  break;
46  }
47  }
48  if (iter == _catalogs.end()) {
50  }
51  if (!iter->getTable()->getMetadata()) {
52  std::shared_ptr<daf::base::PropertyList> metadata(new daf::base::PropertyList());
53  iter->getTable()->setMetadata(metadata);
54  metadata->set("EXTTYPE", "ARCHIVE_DATA");
55  metadata->set("AR_CATN", catArchive, "# of this catalog relative to the start of this archive");
56  }
57  return BaseCatalog(iter->getTable());
58  }

◆ put() [1/2]

int lsst::afw::table::io::OutputArchive::Impl::put ( Persistable const *  obj,
std::shared_ptr< Impl > const &  self,
bool  permissive 
)
inline

Definition at line 107 of file OutputArchive.cc.

107  {
108  if (!obj) return 0;
109  if (permissive && !obj->isPersistable()) return 0;
110  int const currentId = _nextId;
111  ++_nextId;
112  OutputArchiveHandle handle(currentId, obj->getPersistenceName(), obj->getPythonModule(), self);
113  obj->write(handle);
114  return currentId;
115  }

◆ put() [2/2]

int lsst::afw::table::io::OutputArchive::Impl::put ( std::shared_ptr< Persistable const >  obj,
std::shared_ptr< Impl > const &  self,
bool  permissive 
)
inline

Definition at line 117 of file OutputArchive.cc.

117  {
118  if (!obj) return 0;
119  if (permissive && !obj->isPersistable()) return 0;
120  MapItem item(obj, _nextId);
121  std::pair<Map::iterator, bool> r = _map.insert(item);
122  if (r.second) {
123  // We've never seen this object before. Save it.
124  return put(obj.get(), self, permissive);
125  } else {
126  // We had already saved this object, and insert returned an iterator
127  // to the ID we used before; return that.
128  return r.first->second;
129  }
130  }

◆ saveCatalog()

void lsst::afw::table::io::OutputArchive::Impl::saveCatalog ( BaseCatalog const &  catalog,
int  id,
std::string const &  name,
std::string const &  module,
int  catPersistable 
)
inline

Definition at line 76 of file OutputArchive.cc.

77  {
78  auto indexRecord = addIndexRecord(id, name, module);
79  indexRecord->set(indexKeys.catPersistable, catPersistable);
80  indexRecord->set(indexKeys.nRows, catalog.size());
81  int catArchive = 1;
82  CatalogVector::iterator iter = _catalogs.begin();
83  for (; iter != _catalogs.end(); ++iter, ++catArchive) {
84  if (iter->getTable() == catalog.getTable()) {
85  break;
86  }
87  }
88  if (iter == _catalogs.end()) {
89  throw LSST_EXCEPT(pex::exceptions::LogicError,
90  "All catalogs passed to saveCatalog must be created by makeCatalog");
91  }
92  // Add the name of the class to the header so anyone looking at it can
93  // tell what's stored there. But we don't want to add it multiple times.
94  try {
95  auto names = iter->getTable()->getMetadata()->getArray<std::string>("AR_NAME");
96  if (std::find(names.begin(), names.end(), name) == names.end()) {
97  iter->getTable()->getMetadata()->add("AR_NAME", name, "Class name for objects stored here");
98  }
99  } catch (pex::exceptions::NotFoundError &) {
100  iter->getTable()->getMetadata()->add("AR_NAME", name, "Class name for objects stored here");
101  }
102  indexRecord->set(indexKeys.row0, iter->size());
103  indexRecord->set(indexKeys.catArchive, catArchive);
104  iter->insert(iter->end(), catalog.begin(), catalog.end(), false);
105  }

◆ saveEmpty()

void lsst::afw::table::io::OutputArchive::Impl::saveEmpty ( int  id,
std::string const &  name,
std::string const &  module 
)
inline

Definition at line 68 of file OutputArchive.cc.

68  {
69  auto indexRecord = addIndexRecord(id, name, module);
70  indexRecord->set(indexKeys.nRows, 0);
71  indexRecord->set(indexKeys.catPersistable, ArchiveIndexSchema::NO_CATALOGS_SAVED);
72  indexRecord->set(indexKeys.row0, ArchiveIndexSchema::NO_CATALOGS_SAVED);
73  indexRecord->set(indexKeys.catArchive, ArchiveIndexSchema::NO_CATALOGS_SAVED);
74  }

◆ writeFits()

void lsst::afw::table::io::OutputArchive::Impl::writeFits ( fits::Fits fitsfile)
inline

Definition at line 132 of file OutputArchive.cc.

132  {
133  _index.getTable()->getMetadata()->set("AR_NCAT", int(_catalogs.size() + 1),
134  "# of catalogs in this archive, including the index");
135  _index.writeFits(fitsfile);
136  int n = 1;
137  for (CatalogVector::const_iterator iter = _catalogs.begin(); iter != _catalogs.end(); ++iter, ++n) {
138  iter->writeFits(fitsfile);
139  }
140  }

Member Data Documentation

◆ _catalogs

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

Definition at line 152 of file OutputArchive.cc.

◆ _index

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

Definition at line 151 of file OutputArchive.cc.

◆ _map

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

Definition at line 150 of file OutputArchive.cc.

◆ _nextId

int lsst::afw::table::io::OutputArchive::Impl::_nextId

Definition at line 149 of file OutputArchive.cc.


The documentation for this class was generated from the following file:
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::afw::table::io::OutputArchive::Impl::_map
Map _map
Definition: OutputArchive.cc:150
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::table::io::ArchiveIndexSchema::NO_CATALOGS_SAVED
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.
Definition: ArchiveIndexSchema.h:52
std::pair
std::find
T find(T... args)
std::vector::size
T size(T... args)
std::shared_ptr::get
T get(T... args)
lsst::afw::table::io::OutputArchive::Impl::_catalogs
CatalogVector _catalogs
Definition: OutputArchive.cc:152
lsst::afw::table::io::ArchiveIndexSchema::get
static ArchiveIndexSchema const & get()
Return the singleton instance.
Definition: ArchiveIndexSchema.cc:14
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::afw::table::io::OutputArchive::OutputArchiveHandle
friend class OutputArchiveHandle
Definition: OutputArchive.h:36
lsst::afw::table::Schema::EQUAL_KEYS
@ EQUAL_KEYS
Keys have the same types offsets, and sizes.
Definition: Schema.h:65
lsst::afw::table::io::OutputArchive::Impl::_index
BaseCatalog _index
Definition: OutputArchive.cc:151
lsst::afw::table::CatalogT::getTable
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::table::CatalogT::writeFits
void writeFits(std::string const &filename, std::string const &mode="w", int flags=0) const
Write a FITS binary table to a regular file.
Definition: Catalog.h:306
lsst::afw::table::BaseCatalog
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
std::vector::begin
T begin(T... args)
lsst::afw::table::io::OutputArchive::Impl::addIndexRecord
std::shared_ptr< BaseRecord > addIndexRecord(int id, std::string const &name, std::string const &module)
Definition: OutputArchive.cc:60
std::vector::insert
T insert(T... args)
lsst::afw::table::io::OutputArchive::Impl::_nextId
int _nextId
Definition: OutputArchive.cc:149
lsst::afw::table::io::OutputArchive::Impl::put
int put(Persistable const *obj, std::shared_ptr< Impl > const &self, bool permissive)
Definition: OutputArchive.cc:107
std::vector::end
T end(T... args)
lsst::afw::table::CatalogT::addNew
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485
lsst::afw::table::Schema::EQUAL_NAMES
@ EQUAL_NAMES
Fields have the same names (ordered).
Definition: Schema.h:66
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88
lsst::meas::modelfit.psf.psfContinued.module
module
Definition: psfContinued.py:42