FACT++  1.0
void CompressedFitsWriter::writeCatalog ( bool  closingFile = false)
private

write the compressed data catalog. If closingFile is set to true, checksum is calculated

Definition at line 1016 of file fitsCompressor.cc.

References CompressedFitsFile::_catalog, CompressedFitsFile::_checksum, CompressedFitsFile::_file, Checksum::add(), and i.

Referenced by writeHeader().

1017 {
1018  uint32_t sizeWritten = 0;
1019  for (uint32_t i=0;i<_catalog.size();i++)
1020  {
1021  for (uint32_t j=0;j<_catalog[i].size();j++)
1022  {
1023  //swap the bytes
1024  int8_t swappedEntry[16];
1025  swappedEntry[0] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[7];
1026  swappedEntry[1] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[6];
1027  swappedEntry[2] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[5];
1028  swappedEntry[3] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[4];
1029  swappedEntry[4] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[3];
1030  swappedEntry[5] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[2];
1031  swappedEntry[6] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[1];
1032  swappedEntry[7] = reinterpret_cast<int8_t*>(&_catalog[i][j].first)[0];
1033 
1034  swappedEntry[8] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[7];
1035  swappedEntry[9] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[6];
1036  swappedEntry[10] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[5];
1037  swappedEntry[11] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[4];
1038  swappedEntry[12] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[3];
1039  swappedEntry[13] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[2];
1040  swappedEntry[14] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[1];
1041  swappedEntry[15] = reinterpret_cast<int8_t*>(&_catalog[i][j].second)[0];
1042  if (closingFile)
1043  {
1044  _checksum.add(reinterpret_cast<char*>(swappedEntry), 16);
1045  }
1046  _file.write(reinterpret_cast<char*>(&swappedEntry[0]), 2*sizeof(int64_t));
1047  sizeWritten += 2*sizeof(int64_t);
1048  }
1049  }
1050 
1051  //we do not reserve space for now because fverify does not like that.
1052  //TODO bug should be fixed in the new version. Install it on the cluster and restor space reservation
1053  return ;
1054 
1055  //write the padding so that the HEAP section starts at a 2880 bytes boundary
1056  if (sizeWritten % 2880 != 0)
1057  {
1058  vector<char> nullVec(2880 - sizeWritten%2880, 0);
1059  _file.write(nullVec.data(), 2880 - sizeWritten%2880);
1060  }
1061 }
CatalogType _catalog
Catalog, i.e. the main table that points to the compressed data.
int i
Definition: db_dim_client.c:21
fstream _file
The actual file streamer for accessing disk data.
Checksum _checksum
Checksum for asserting the consistency of the data.
bool add(const char *buf, size_t len, bool big_endian=true)
Definition: checksum.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function: