# 22. Virtuoso Functions Guide - string_output_gz_compress

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
gz_compress
gz_uncompress
string_output_gz_com...
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## string_output_gz_compress

compress a string_output with gzip algorithm
string_output_gz_compress (in str_out_in string_session, out str_out_out string_session);
Description

The string_output_gz_compress compresses its string_output argument using the gzip algorithm and writes the result to another string_output given as an argument. When successful, the number of bytes written to str_out_out is returned.

Parameters
str_out_in – A string session as returned by string_output function.
str_out_out – A string session as returned by string_output function.
Return Types

INTEGER number of bytes written to str_out_out

Examples
GZIP test

Test if the gzip implementation works.

    create procedure
    gz_test_1 (in fname varchar)
    {
      declare dta, dta_2, res any;
      declare len integer;

      res := string_output ();
      dta_2 := string_output ();
      dta := file_to_string_output (fname);

      result_names (len);

      -- send length of input to client

      result (length (dta));

      -- compress and return compressed size.

      result (string_output_gz_compress (dta, res));
      gz_uncompress (string_output_string (res), dta_2);

      if (md5 (dta) <> md5 (dta_2))
        signal ('SNAFU', 'GZIP algorithm implementation is faulty.');

      result (length (dta));
      end_result();
    }
    ;

    SQL> gz_test_1 ('tmp/test.dat');
    len
    INTEGER
    _______________________________________________________________________________

    11689
    2477
    11689

    3 Rows. -- 11 msec.

See Also

string_output