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.
zMemtableExt - helper class for zMemTable
Re: zMemtableExt - helper class for zMemTable
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:
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 :)
[*] 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;
Kind of a big change as it would go back to TZAbstractRODataSet I think, so probably in 8.1 or later :)
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Re: zMemtableExt - helper class for zMemTable
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
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