With the introduction of classes in the 4D environment, the need to store your data in objects, and especially blobs, has increased. That’s why 4D v19 R2 lets you encapsulate blobs in objects.
Beyond the storage aspect, since the blob object is a reference type, your performance in terms of memory occupation and speed will be greatly improved.
You can now assign a blob as an attribute of an object like you do for numbers, text, or other types:
$o:=New object("blob"; $blob)
or by implicit conversion:
$o:=New object
$o.blob:=$blob
or with a shared object:
$sObj:=New shared object("blob"; $blob)
In a lot of cases, it is better to use a blob object (4D.Blob type) instead of a Blob type. For example, when you pass a blob object in a method or a command parameter, it is not duplicated like a Blob type but passed by reference, just like any other 4D object. This is faster and less memory-consuming:
var $blobObj : Object
// Download your MIME in a blob object
$blobObj:=IMAP_transporter.getMIMEAsBlob ( $msgID )
// The BLOB object is then passed to the AddToArchives method by reference.
AddToArchives($blobObj)
// Unlike when you pass a Blob type, the blob is not duplicated when handled using a blob object.
But the standard Blob type is not deprecated. Each blob type has its advantages. Use the following table to determine which one suits your needs:
Blob | 4D.Blob | |
---|---|---|
Alterable | Yes | No |
Shareable in objects and collections | No | Yes |
Passed by reference* | No | Yes |
Performance when accessing bytes | + | – |
Maximum size | 2GB* | Memory |
*This size limit may be lower depending on your OS and how much space is available.
Check out the documentation to learn more about this new attribute type!
Now that blobs are managed in objects, there is only one more step for it to be managed in ORDA. Stay tuned!