zMemtableExt - helper class for zMemTable

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
kjteng
Senior Boarder
Senior Boarder
Posts: 54
Joined: 10.05.2015, 15:02

zMemtableExt - helper class for zMemTable

Post by kjteng »

This is a helper class for zMemTable developed for my personal project. I have and made it (with demo program) available at https://github.com/kjteng/zMemTableExt

Methods implemented (using zstream.pas to compress the data)
procedure SaveToBlob(BField: TBlobField);
procedure LoadFromBlob(BField: TBlobField);
procedure SaveToFile(Filename: TFilename; zip: Boolean =True);
procedure LoadFromFile(Filename: TFilename);
procedure CopyStru(src: TDataSet; xcFields: TByteSet =[]; DeleteOldfields: Boolean=True);

I have only tested it on Lazarus ver2.0.12.
All are welcome to try it. Comments and suggestions would be highly appreciated.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: zMemtableExt - helper class for zMemTable

Post by aehimself »

Remarks:

[*] You don't need to "mark" zipped content. Just check if the ZLIB header is present in the first 2 bytes:

https://stackoverflow.com/questions/905 ... -look-like

[*] Use a TArray<Integer> for xcFields. FieldDefs is an Integer indexed property, your solution will work until only 255 fields.

[*] This kind of "protection" is also missing from LoadFromStream I think. In case a value can not be assigned to a field, dataset remains in dsInsert. To prevent this, in CopyData use the loading like this:

Code: Select all

Append;
Try
 [...]
Except
 On E:Exception Do
 Begin
   src.Cancel;
   Raise;
 End;
End;
Your idea of "LoadFromBlob" and "SaveToBlob" got me thinking. This actually can be used for nested datasets, like how FireDAC does it (there is a FieldType called ftDataSet after all).... maybe we can discuss it in a separate thread.
Kind of a big change as it would go back to TZAbstractRODataSet I think, so probably in 8.1 or later :)
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
kjteng
Senior Boarder
Senior Boarder
Posts: 54
Joined: 10.05.2015, 15:02

Re: zMemtableExt - helper class for zMemTable

Post by kjteng »

Hi aehimself:
Thank you so much for your valuable feedback.
I have made the necessary changes based on your advice. I used array of integer instead of TArray<Integer> because I am not familiar with the use of generic type (and will study further on this subject).
Regards,
kjteng
Post Reply