Changeset 16805


Ignore:
Timestamp:
06/11/13 16:37:00 (11 years ago)
Author:
lyard
Message:
Added TILE marker and size between tile data
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fitsCompressor.cc

    r16799 r16805  
    405405    private:
    406406        ///@brief compresses one buffer of data, the one given by threadIndex
    407         uint32_t compressBuffer(uint32_t threadIndex);
     407        uint64_t compressBuffer(uint32_t threadIndex);
    408408
    409409        ///@brief writes an already compressed buffer to disk
     
    455455#define COMPRESSED_FLAG 0x1
    456456#define UNCOMPRESSED_FLAG 0x0
     457
     458typedef 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;
    457471
    458472template<>
     
    633647    {
    634648        _transposedBuffer[i] = new char[_rowWidth*_numRowsPerTile];
    635         _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + _columns.size()]; //use a bit more memory for compression flags
     649        _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + _columns.size() + sizeof(TileHeader)]; //use a bit more memory for compression flags
    636650        if (_transposedBuffer[i] == NULL || _compressedBuffer[i] == NULL)
    637651            return false;
     
    639653        memset(_compressedBuffer[i], 0, 4);
    640654        _compressedBuffer[i] = _compressedBuffer[i]+4;
     655        //initialize the tile header
     656        TileHeader tileHeader;
     657        memcpy(_compressedBuffer[i], &tileHeader, sizeof(TileHeader));
    641658    }
    642659    return true;
     
    10731090        int64_t compressedOffset = 0;
    10741091        for (uint32_t i=0;i<_catalog.size();i++)
     1092        {
     1093            compressedOffset += sizeof(TileHeader);
     1094            heapSize += compressedOffset;
    10751095            for (uint32_t j=0;j<_catalog[i].size();j++)
    10761096            {
    10771097                heapSize += _catalog[i][j].first;
    10781098                //set the catalog offsets to their actual values
    1079                 if (compressedOffset < 0) return false;
    10801099                _catalog[i][j].second = compressedOffset;
    10811100                compressedOffset += _catalog[i][j].first;
     
    10831102                if (_catalog[i][j].first == 0) _catalog[i][j].second = 0;
    10841103            }
     1104        }
    10851105        setHeaderKey(HeaderEntry("PCOUNT", heapSize, "size of special data area"));
    10861106    }
     
    11571177        while (_threadStatus[_threadLooper] != _THREAD_WAIT_)
    11581178            usleep(100000);
     1179
    11591180        _threadNumRows[_threadLooper] = _totalNumRows;
    11601181        _threadStatus[_threadLooper] = _THREAD_COMPRESS_;
     
    12231244 *                  COMPRESS BUFFER
    12241245 ****************************************************************/
    1225 uint32_t CompressedFitsWriter::compressBuffer(uint32_t threadIndex)
     1246uint64_t CompressedFitsWriter::compressBuffer(uint32_t threadIndex)
    12261247{
    12271248    uint32_t thisRoundNumRows = (_threadNumRows[threadIndex]%_numRowsPerTile) ? _threadNumRows[threadIndex]%_numRowsPerTile : _numRowsPerTile;
    12281249    uint32_t offset=0;
    12291250    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
    12311252
    12321253    //now compress each column one by one by calling compression on arrays
     
    12391260        if (_columns[i].numElems() == 0) continue;
    12401261        //set the default byte telling if uncompressed the compressed Flag
    1241         int64_t previousOffset = compressedOffset;
     1262        uint64_t previousOffset = compressedOffset;
    12421263        _compressedBuffer[threadIndex][compressedOffset++] = COMPRESSED_FLAG;
    12431264        switch (compression)
     
    12641285        _catalog[currentCatalogRow][i].first = compressedOffset - _catalog[currentCatalogRow][i].second;
    12651286    }
     1287    memcpy(&(_compressedBuffer[threadIndex][4]), &compressedOffset, sizeof(uint64_t));
    12661288    return compressedOffset;
    12671289}
Note: See TracChangeset for help on using the changeset viewer.