Skip to content

DF_FILE_COMPRESSION

See Also: Get_Attribute, Set_Attribute

The type of table compression used by the table.

Level

Table

Supported by

The Embedded Database and the DataFlex Pervasive.SQL Driver

Type

Enumeration list, permanent

Access

Read / Write

Values

  • DF_FILE_COMPRESS_NONE
  • DF_FILE_COMPRESS_FAST
  • DF_FILE_COMPRESS_STANDARD
  • DF_FILE_COMPRESS_CUSTOM

Remarks

The Embedded Database and Pervasive.SQL support table compression. When table compression is used, the amount of data that a table needs on disk is reduced. The way the data in the table is compressed is set up by the DF_FILE_COMPRESSION attribute.

This attribute can only be set inside of a Structure_Start ... Structure_End operation.

The Pervasive.SQL Driver supports the values DF_FILE_COMPRESS_NONE and DF_FILE_COMPRESS_STANDARD.

Value Descriptions

Value Meaning
DF_FILE_COMPRESS_NONE Indicates there will be no data compression.
DF_FILE_COMPRESS_STANDARD Uses Pervasive.SQL’s table compression.

The Embedded Database supports all possible values. The meanings of the values for the Embedded Database are:

Value Meaning
DF_FILE_COMPRESS_NONE Indicates there will be no data compression.
DF_FILE_COMPRESS_FAST Uses run-length encoding for data compression. In run-length encoding, a repeating sequence of the same characters is replaced by the number of times the character is repeated and the character itself. For example, a value of “aaaaaaaaaa” would be replaced by “10a”.
DF_FILE_COMPRESS_STANDARD Uses Huffman encoding compression. The frequency table used is based on the English language.
DF_FILE_COMPRESS_CUSTOM Uses Huffman encoding compression. The frequency table used is based on the contents of the table. When custom compression is used on tables whose contents change frequently, it is possible to recompress the table. Recompressing will rebuild the frequency table and then recompress the data.

This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make sense in some back ends. That is why DataFlex SQL Drivers will return DF_FILE_COMPRESS_NONE for every table accessed; trying to set the attribute will be ignored.

Example Procedure

Procedure RecompressTables
    Handle hTable
    Handle hStruct
    Integer iCompression
    String sTable

    Move 0 To hTable
    Repeat
        Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
        If (hTable > 0) Begin
            Get_Attribute DF_FILE_ROOT_NAME Of hTable To sTable
            If (Uppercase(sTable) <> "FLEXERRS") Begin
                Open hTable Mode DF_EXCLUSIVE
                Get_Attribute DF_FILE_COMPRESSION Of hTable To iCompression
                Get_Attribute DF_FILE_ROOT_NAME Of hTable To sTable
                If (iCompression = DF_FILE_COMPRESS_CUSTOM) Begin
                    Showln "Recompressing table: " sTable
                    Move hTable To hStruct
                    Structure_Start hStruct
                    Structure_End hStruct DF_STRUCTEND_OPT_RECOMPRESS
                End
                Else Begin
                    Showln "Table " sTable " not custom compressed."
                    Close hTable
                End
            End
        End
    Until (hTable = 0)
End_Procedure // RecompressTables

The sample procedure above will recompress all tables that use custom compression.