LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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  }
table::Schema schema
Definition: python.h:134
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
static ArchiveIndexSchema const & get()
Return the singleton instance.

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  }
table::Key< std::string > name
Definition: Amplifier.cc:116
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

◆ 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  }
T begin(T... args)
@ EQUAL_NAMES
Fields have the same names (ordered).
Definition: Schema.h:66
@ EQUAL_KEYS
Keys have the same types offsets, and sizes.
Definition: Schema.h:65
T end(T... args)
T insert(T... args)
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71

◆ 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  }
int put(Persistable const *obj, std::shared_ptr< Impl > const &self, bool permissive)
T get(T... args)

◆ 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  }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::shared_ptr< BaseRecord > addIndexRecord(int id, std::string const &name, std::string const &module)
T find(T... args)

◆ 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  }
static constexpr int const NO_CATALOGS_SAVED
Special value used for catArchive, catPersistable, and row0 when an object with no state is saved.

◆ 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  }
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
T size(T... args)

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: