FACT++  1.0
bool CompressedFitsWriter::writeCompressedDataToDisk ( uint32_t  threadID,
uint32_t  sizeToWrite 
)
private

writes an already compressed buffer to disk

Definition at line 1377 of file fitsCompressor.cc.

References _checkOffset, CompressedFitsFile::_checksum, CompressedFitsFile::_compressedBuffer, CompressedFitsFile::_file, and Checksum::add().

Referenced by close(), and threadFunction().

1378 {
1379  char* checkSumPointer = _compressedBuffer[threadID];
1380  int32_t extraBytes = 0;
1381  uint32_t sizeToChecksum = sizeToWrite;
1382  if (_checkOffset != 0)
1383  {//should we extend the array to the left ?
1384  sizeToChecksum += _checkOffset;
1385  checkSumPointer -= _checkOffset;
1386  memset(checkSumPointer, 0, _checkOffset);
1387  }
1388  if (sizeToChecksum%4 != 0)
1389  {//should we extend the array to the right ?
1390  extraBytes = 4 - (sizeToChecksum%4);
1391  memset(checkSumPointer+sizeToChecksum, 0,extraBytes);
1392  sizeToChecksum += extraBytes;
1393  }
1394  //do the checksum
1395  _checksum.add(checkSumPointer, sizeToChecksum);
1396 // cout << endl << "Checksum: " << _checksum.val() << endl;
1397  _checkOffset = (4 - extraBytes)%4;
1398  //write data to disk
1399  _file.write(_compressedBuffer[threadID], sizeToWrite);
1400  return _file.good();
1401 }
int32_t _checkOffset
offset to the data pointer to calculate the checksum
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
vector< char * > _compressedBuffer
Memory buffer to store rows while they are compressed.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: