$GZip: Difference between revisions
(Automatically generated page update) |
(Automatically generated page update) |
||
Line 71: | Line 71: | ||
<li>[[Janus Web Server]]</li> | <li>[[Janus Web Server]]</li> | ||
<li>[[Japanese functions]]</li> | <li>[[Japanese functions]]</li> | ||
<li>[ | <li>[http://m204wiki.rocketsoftware.com/images/4/4b/SirfieldNew.pdf Sir2000 Field Migration Facility]</li> | ||
</ul> | </ul> |
Revision as of 17:24, 13 September 2013
Compress a longstring with GZip
Note: Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the Gzip method.
This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. The GZIP format is described in RFC 1952. It is very effective with HTML and XML data.
The $GZip function accepts four arguments and returns a longstring result.
Syntax
%lstrc = $GZip(%lstr, level, filename, datetime)
Syntax terms
%lstrc | The returned longstring. |
---|---|
%lstrc | The longstring to be compressed. This argument is required. |
level | A string or integer value that describes the type of compression to perform on the longstring. This argument is optional; if it is not specified, DYNAMIC (type 2) compression is used. The type values are described below in "Compressions options". |
filename | This optional string contains the internal name of the compressed string. Decompression programs will use this name for the output file when the string is un-zipped. The maximum length of the filename is 32 bytes. |
datetime | This optional string contains the file modification date and time. This must be a string in the format YYYY-MM-DD HH:MI:SS or YY-MM-DD HH:MI:SS If a two-digit year is supplied, the CENTSPAN value used is 75. |
Compressions options
FIXED | Indicates that compression is done with fixed codes. The fixed code tables used for compression (defined as part of RFC 1951) are somewhat optimized for ASCII character data, but slightly decrease the amount of CPU required to perform compression. Also, since the codes are already defined as part of the specification, they are not included in the compressed data. |
---|---|
DYNAMIC | Indicates that the compression code tables are generated based on the input data. Dynamic tables typically provide somewhat better compression on most types of data. There is a very slight CPU overhead in computing the frequencies of byte values in the input data. Also, since the code tables are dynamic, they are included as part of the compressed data. This will increase the size of the compressed longstring, but these tables are small, since they are also stored in a compressed form. |
0-6 | Indicates the type of compression used. Specifying 0 indicates the default should be used, which is the same as specifying DYNAMIC. Values 1 through 6 specify a tradeoff in speed and compression factor: The value 1 uses the least CPU and compresses the string quickly; the value 6 uses the most CPU but gets the best compression. Higher numbers may increase the CPU considerably without significantly improving the compression. |
Usage notes
- If an invalid option is passed, or if compression is not enabled for the current run, the request is cancelled.
- The NCMPBUF parameter must be set by User 0 before the $GZip function can be used. If $GZip is called with NCMPBUF = 0, the request is cancelled.
- As with any compression scheme, it is possible that a particular string will become longer after compression. This would happen, for example, if a deflated string were passed to $GZip.
- Short strings (less than 128 bytes) will typically compress better with the FIXED option.
- Multiple files are not currently supported.
Examples
In the following example,
%lsgz
is set to the compressed version of the given string:
%ls = 'Ive got sunshine on a cloudy day' %dt = $date and $time %lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)
Note: No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with $GunZip.
Products authorizing $GZip
- Sirius functions
- Fast/Unload User Language Interface
- Janus Open Client
- Janus Open Server
- Janus Sockets
- Janus Web Server
- Japanese functions
- Sir2000 Field Migration Facility