4D v12.4

BLOB PROPERTIES

Home

 
4D v12.4
BLOB PROPERTIES

 

BLOB PROPERTIES 


 

BLOB PROPERTIES ( blob ; compressed {; expandedSize {; currentSize}} )  
Parameter Type   Description
blob  BLOB in BLOB for which to get information
compressed  Longint in 0 = BLOB is not compressed, 1 = BLOB compressed compact, 2 = BLOB compressed fast
expandedSize  Longint in Size of BLOB (in bytes) when not compressed
currentSize  Longint in Current size of BLOB (in bytes)

The BLOB PROPERTIES command returns information about the BLOB blob.

The compressed parameter tells whether or not the BLOB is compressed, and returns one of the following values.

Constant Type Value Comment
Compact compression mode Longint 1 Compressed as much as possible (at the expense of the speed of compression and decompression operations). Default method.
Fast compression mode Longint 2 Compressed as fast as possible (and will be decompressed as fast as possible), at the expense of the compression ratio (the compressed BLOB will be bigger).
Is not compressed Longint 0

Note: 4D provides the predefined constants.

Whatever the compression status of the BLOB, the expandedSize parameter returns the size of the BLOB when it is not compressed.

The parameter currentSize returns the current size of the BLOB. If the BLOB is compressed, you will usually obtain currentSize less than expandedSize. If the BLOB is not compressed, you will always obtain currentSize equal to expandedSize.

See examples for the commands COMPRESS BLOB and EXPAND BLOB.

After a BLOB has been compressed, the following project method obtains the percentage of space saved by the compression:

  ` Space saved by compression project method
  ` Space saved by compression (Pointer {; Pointer } ) -> Long integer
  ` Space saved by compression ( -> BLOB {; -> savedBytes } ) -> Percentage
 
 C_POINTER($1;$2)
 C_LONGINT($0;$vlCompressed;$vlExpandedSize;$vlCurrentSize)
 
 BLOB PROPERTIES($1->;$vlCompressed;$vlExpandedSize;$vlCurrentSize)
 If($vlExpandedSize=0)
    $0:=0
    If(Count parameters>=2)
       $2->:=0
    End if
 Else
    $0:=100-(($vlCurrentSize/$vlExpandedSize)*100)
    If(Count parameters>=2)
       $2->:=$vlExpandedSize-$vlCurrentSize
    End if
 End if

After this method has been added to your application, you can use it this way:

  ` ...
 COMPRESS BLOB(vxBlob)
 $vlPercent:=Space saved by compression(->vxBlob;->vlBlobSize)
 ALERT("The compression saved "+String(vlBlobSize)+" bytes, so "+String($vlPercent;"#0%")+
 " of space.")

 
PROPERTIES 

Product: 4D
Theme: BLOB
Number: 536

 
HISTORY 

Created: 4D v6

 
SEE ALSO 

COMPRESS BLOB
EXPAND BLOB

 
TAGS 

blob compression, Compression***