Changeset 16805 for trunk/FACT++
- Timestamp:
- 06/11/13 16:37:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fitsCompressor.cc
r16799 r16805 405 405 private: 406 406 ///@brief compresses one buffer of data, the one given by threadIndex 407 uint 32_t compressBuffer(uint32_t threadIndex);407 uint64_t compressBuffer(uint32_t threadIndex); 408 408 409 409 ///@brief writes an already compressed buffer to disk … … 455 455 #define COMPRESSED_FLAG 0x1 456 456 #define UNCOMPRESSED_FLAG 0x0 457 458 typedef struct TileHeader 459 { 460 char id[4]; 461 uint64_t size; 462 TileHeader() 463 { 464 id[0]='T'; 465 id[1]='I'; 466 id[2]='L'; 467 id[3]='E'; 468 size=0; 469 }; 470 } __attribute__((__packed__)) TileHeader; 457 471 458 472 template<> … … 633 647 { 634 648 _transposedBuffer[i] = new char[_rowWidth*_numRowsPerTile]; 635 _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + _columns.size() ]; //use a bit more memory for compression flags649 _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + _columns.size() + sizeof(TileHeader)]; //use a bit more memory for compression flags 636 650 if (_transposedBuffer[i] == NULL || _compressedBuffer[i] == NULL) 637 651 return false; … … 639 653 memset(_compressedBuffer[i], 0, 4); 640 654 _compressedBuffer[i] = _compressedBuffer[i]+4; 655 //initialize the tile header 656 TileHeader tileHeader; 657 memcpy(_compressedBuffer[i], &tileHeader, sizeof(TileHeader)); 641 658 } 642 659 return true; … … 1073 1090 int64_t compressedOffset = 0; 1074 1091 for (uint32_t i=0;i<_catalog.size();i++) 1092 { 1093 compressedOffset += sizeof(TileHeader); 1094 heapSize += compressedOffset; 1075 1095 for (uint32_t j=0;j<_catalog[i].size();j++) 1076 1096 { 1077 1097 heapSize += _catalog[i][j].first; 1078 1098 //set the catalog offsets to their actual values 1079 if (compressedOffset < 0) return false;1080 1099 _catalog[i][j].second = compressedOffset; 1081 1100 compressedOffset += _catalog[i][j].first; … … 1083 1102 if (_catalog[i][j].first == 0) _catalog[i][j].second = 0; 1084 1103 } 1104 } 1085 1105 setHeaderKey(HeaderEntry("PCOUNT", heapSize, "size of special data area")); 1086 1106 } … … 1157 1177 while (_threadStatus[_threadLooper] != _THREAD_WAIT_) 1158 1178 usleep(100000); 1179 1159 1180 _threadNumRows[_threadLooper] = _totalNumRows; 1160 1181 _threadStatus[_threadLooper] = _THREAD_COMPRESS_; … … 1223 1244 * COMPRESS BUFFER 1224 1245 ****************************************************************/ 1225 uint 32_t CompressedFitsWriter::compressBuffer(uint32_t threadIndex)1246 uint64_t CompressedFitsWriter::compressBuffer(uint32_t threadIndex) 1226 1247 { 1227 1248 uint32_t thisRoundNumRows = (_threadNumRows[threadIndex]%_numRowsPerTile) ? _threadNumRows[threadIndex]%_numRowsPerTile : _numRowsPerTile; 1228 1249 uint32_t offset=0; 1229 1250 uint32_t currentCatalogRow = (_threadNumRows[threadIndex]-1)/_numRowsPerTile; 1230 int64_t compressedOffset = 0;1251 uint64_t compressedOffset = sizeof(TileHeader); //skip the 'TILE' marker and tile size entry 1231 1252 1232 1253 //now compress each column one by one by calling compression on arrays … … 1239 1260 if (_columns[i].numElems() == 0) continue; 1240 1261 //set the default byte telling if uncompressed the compressed Flag 1241 int64_t previousOffset = compressedOffset;1262 uint64_t previousOffset = compressedOffset; 1242 1263 _compressedBuffer[threadIndex][compressedOffset++] = COMPRESSED_FLAG; 1243 1264 switch (compression) … … 1264 1285 _catalog[currentCatalogRow][i].first = compressedOffset - _catalog[currentCatalogRow][i].second; 1265 1286 } 1287 memcpy(&(_compressedBuffer[threadIndex][4]), &compressedOffset, sizeof(uint64_t)); 1266 1288 return compressedOffset; 1267 1289 }
Note:
See TracChangeset
for help on using the changeset viewer.