Compress API - Compress a block of data

Compress a block of data. The src parameter points to a block of data that is srcLen bytes in size. The tgt parameter points to a buffer that is tgtSize bytes in size. The plug-in library compresses the data at address src and writes the compressed data to the buffer at address tgt. The actual amount of uncompressed data that was compressed is stored in srcAct. The actual size of the compressed data is returned as tgtAct.

Authorization

None

Required connection

None

API include file

sqlucompr.h

API and data structure syntax

int Compress(
      struct COMPR_CB *pCB,
      const char *src,
      db2int32 srcSize,
      db2Uint32 srcGran,
      char *tgt,
      db2int32 tgtSize,
      db2int32 *srcAct,
      db2int32 *tgtAct,
      db2Uint32 *tgtCRC);

Compress API parameters

pCB
Input. This is the control block that was returned by the InitCompression API call.
src
Input. Pointer to the block of data to be compressed.
srcLen
Input. Size in bytes of the block of data to be compressed.
srcGran
Input. If the library returned a value of 1 for piInfo->useGran, srcGran specifies the log2 of the page size of the data. (For example, if the page size of the data is 4096 bytes, srcGran is 12.) The library ensures that the amount of data actually compressed (srcAct) is an exact multiple of this page size. If the library sets the useGran flag, Db2® is able to use a more efficient algorithm for fitting the compressed data into the backup image. This means that both the performance of the plug-in will be better and that the compressed backup image will be smaller. If the library returned a value of 0 for piInfo->srcGran, the granularity is 1 byte.
tgt
Input and output. Target buffer for compressed data. Db2 will supply this target buffer and the plug-in will compress the data at src and write compressed data here.
tgtSize
Input. Size in bytes of the target buffer.
srcAct
Output. Actual amount in bytes of uncompressed data from src that was compressed.
tgtAct
Output. Actual amount in bytes of compressed data stored in tgt.
tgtCRC
Output. If the library returned a value of 1 for piInfo->useCRC, the CRC value of the uncompressed block is returned as tgtCRC. If the library returned a value of 0 for piInfo->useCRC, tgtCRC will be a null pointer.